Questions tagged [glsl]

GLSL is the OpenGL shading language. Use this tag for questions which are specifically about shaders written in this language. For generic shader questions use [shader] instead.

44 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
1 answer
2k views

Manually fetching 8 neighboring texels from 3D texture greatly decreases performance

I'm implementing manual interpolation between texels in a 3D texture to be able to discard some of them when needed. Compared to hardware interpolation, this process takes a lot of time. If I simply ...
user avatar
4 votes
0 answers
310 views

Indexing gl_TessLevelOuter[] with gl_InvocationID on a tessellation control shader

I'm using hardware tessellation to render a terrain mesh with variable LOD. I have this snippet on my tessellation control shader: ...
user avatar
  • 218
3 votes
0 answers
417 views

How to implement PCSS correctly?

I'm trying to implement PCSS in OpenGL/GLSL, but I have problems understanding the details especially the conversions between the coordinate spaces. The existing implementations are so different from ...
user avatar
  • 31
3 votes
0 answers
271 views

Comparing different sampling methods for GGX IBL

I have made a demo that shades a sphere with an environment map. I wanted to compare 3 different ways of sampling the environment. Uniform sampling. Importance sampling with the NDF as suggested in ...
user avatar
3 votes
0 answers
123 views

IBL looks too dark with uniform sampling

I'm making a program that illuminates a sphere using an environment map. For each fragment in the sphere, I compute a many random directions in the hemisphere along the surface normal (no importance ...
user avatar
3 votes
0 answers
145 views

Projective Texture / Shadow Mapping -- Why is the perspective division performed in the fragment shader?

I've just worked my way through this OpenGL shadow mapping tutorial. While I understand the basic algorithm, one thing puzzles me: During the 2nd render pass all vertices are transformed into the clip ...
user avatar
3 votes
0 answers
280 views

Circular pattern aliasing in voxel ray tracer

I am doing a voxel based raytracer. In other words, I first voxelize the scene using rasterization and I proceed to raytrace the volume in a 3D image to generate a final frame. Currently I noticed ...
user avatar
  • 1,449
2 votes
0 answers
38 views

GLSL, Fragment Shader: How to separate functions (like noise, transform...) to reuse in different projects

I'm a total newbie to coding and recently got interested into generative art. This is my problem: I have to copy all of the functions I need (and there are a lot) in every single fragment file I'm ...
user avatar
2 votes
0 answers
73 views

Atmospheric scattering band/seperation artifact

I am currently experimenting with some atmospheric scattering in glsl in my OpenGL engine. I am experiencing a strange phenomena where a strange band / separation artifact appears along the middle of ...
user avatar
2 votes
0 answers
50 views

Per-object screen space uv issue

I am currently trying to sample a texture in screen space. This works well : ...
user avatar
  • 1,169
2 votes
0 answers
174 views

Calculate the distance between two 3d points in screen coordinates

Given the Point A with the coordinates gl_FragCoord.xy, I have to find the distance to the Center of the cube face to which it belongs in screen coordinates. ...
user avatar
2 votes
0 answers
62 views

Communication between vertex shader executions

Look at this vertex shader: ...
user avatar
2 votes
0 answers
104 views

GLSL broken access operator

I've been following a guide to learn OpenGL, and I'm now learning how to do post-processing. In particular, I'm trying to apply a blur to my rendering through the following kernel: $\frac{\begin{...
user avatar
  • 21
2 votes
0 answers
95 views

Artifacts (numerical errors?) in rasterisation renderer

This might be not laser precision question but this issue appeared a long time ago when first trying to render some scene with 3D models in rasterisation renderer and apply some lighting, ...
user avatar
  • 2,047
2 votes
0 answers
68 views

Implementation of the paper "unified texture management of arbitrary meshes"

I briefly read the paper and I think I got the basic idea of it. The paper doesn't really go into implementation details though so my question is mostly on that. In the paper, needed tiles are ...
user avatar
2 votes
0 answers
253 views

How to output a 32 floating value in a render buffer with fragment shader

I would like to downsample my depth buffer and my normals. For that, I take in input of my shader, the corresponding textures (depth, normal), and I write my new values in a multi render target. I ...
user avatar
1 vote
0 answers
92 views

Binary image blob movement prediction with optical flow

I got stuck with a problem: I have two binary images A and B, which differ by a few seconds. There are Blobs in the images which move (imagine a binary image of a lava lamp). Now I calculate the ...
user avatar
  • 11
1 vote
0 answers
128 views

OpenGL: "invalid value" error after call to `glGetBufferSubData`

My first question in this community. I have following code.The code is shortened for clarity, error checks skipped: ...
user avatar
1 vote
0 answers
189 views

Combine box shadow with a signed distance field

I'm using 2d signed distance fields in my current project for drawing shapes (example: https://www.shadertoy.com/view/4llXD7) and I want to add drop shadows to them. At first I thought I could exploit ...
user avatar
  • 111
1 vote
0 answers
209 views

How could I remove this colour interpolation artefact across a quad?

I've been reading up on a vulkan tutorial online, here: https://vulkan-tutorial.com. This question should apply to any 3D rendering API however. In this lesson https://vulkan-tutorial.com/...
user avatar
  • 165
1 vote
0 answers
243 views

How to hide a part of a geometry dynamically using a shader in three.js

I have a very big geometry in three.js and I want to hide a section of that geometry along an axis (for example every vertex with a Z>N must be hidden). My idea is to create a custom shader in GLSL ...
user avatar
1 vote
0 answers
74 views

Convey screenspace bounding box of rendering result

Imagine I render to an FBO some arbitrary geometry. Geometry can be rendered via single or multiple draw calls. For the sake of the question, assume I know nothing about geometry or transformation ...
user avatar
  • 19
1 vote
0 answers
113 views

glTexSubImage3D throws GL_INVALID_ENUMERATION on NVIDIA

I'm having problems when using the following statement on different GPUs: glTexSubImage3D(target, 0, 0, 0, 0, width, height, layers, format, type, NULL); on ...
user avatar
  • 121
1 vote
0 answers
758 views

How Skia uses OpenGL backend?

Skia 2D's one notable backend in OpenGL, but how does it work under the hood to render? Say, we need to draw an anti-aliased circle. Does Skia: make a quad (using 2 triangles) and paint the circle ...
user avatar
1 vote
0 answers
142 views

GLSL can't calculate texture and reflection

I'm working on a universal shader, and have a function for calculating reflections and a function for textures. When I run the shader, it seems to give up and discard all fragments. The texture and ...
user avatar
1 vote
0 answers
385 views

Nearest depth upsampling

Nvidia in this article presented a way to upsample low res buffer to full res buffer called Nearest Depth Upsampling. This works by comparing four depth values from downsampled low res depth buffer ...
user avatar
  • 2,047
1 vote
0 answers
303 views

Subdivision vertex normal interpolation

I'm using GLSL 4.0 to write a subdivision routine that divides the triangles on an object through a geometry shader. I'm not using barycentric co-ordinates but vector arithmetic to output the triangle ...
user avatar
  • 111
0 votes
0 answers
22 views

void main{vec4 rgba;} wont work on OpenGL

I´m very newbie in OpenGL and I'm trying to tweak a triangle example on Android. I got this ...
user avatar
  • 101
0 votes
0 answers
39 views

Problem when passing a readonly image2D to a function

I would like to declare a function which reads from an image2D and modifies the output. My shader is written like so: ...
user avatar
  • 147
0 votes
0 answers
32 views

Getting something close to the convex full of SDFs using CSG operations

Inigo Quilez has an explanation of smooth operations to join sdfs. I am trying to get something close to the convex hull of multiple sdfs. For starters let;s consider a simple case of 3 cubes int eh ...
user avatar
  • 1,449
0 votes
0 answers
70 views

GLSL texture() vs textureLOD causing odd texture filtering

I've got a fragment shader sampling an environment texture for world reflections, and in testing, there seems to be a major difference in the result for texture() ...
user avatar
0 votes
0 answers
132 views

Wavefront Path Tracing: Implementation and Performance Issues

I'm writting a real-time unidirecional path tracer that runs entirely on the GPU. After successfully implementing it using a "megakernel" approach, I decided to switch to a "Wavefront&...
user avatar
0 votes
0 answers
75 views

OpenGL Compute Shader Vector Subtraction Not Working As Expected

all. I am currently working on a compute shader in GLSL intended to simulate visualizations of general relativity by ray tracing in the Schwarzchild spacetime geometry. I'm about halfway through ...
user avatar
0 votes
0 answers
59 views

Precision problems when rendering whole planets

I'm trying to implement a camera, which is able to go very close to a planet/moon surface, without flickering surface. The problem: Right now the position of a planet / moon is saved at the center of ...
user avatar
  • 499
0 votes
0 answers
61 views

Achieving bokeh blur with custom shapes

I have a 2D texture, without any depth maps, which I'd like to blur to achieve a bokeh effect. The catch, however, is that I want the effect to be custom bitmaps/shapes (e.g. a heart). Here's a part ...
user avatar
0 votes
0 answers
38 views

Obtaining sample position z value when using positions from depth buffer for SSAO

I was looking to implement SSAO; demonstrated on learnopeng (https://learnopengl.com/Advanced-Lighting/SSAO). While I have implemented the way they have done it i.e using a position texture for ...
user avatar
0 votes
1 answer
362 views

Ray-Marching: Rendering a Voxel Grid with Proper Normals

Dear Computer Graphics SE, I have a RAYMARCHING renderer, that looks up voxel data from a 3D texture. Each cell in the texture can be 0 or 1. I have a very simple algorithm for calculating the signed ...
user avatar
0 votes
0 answers
72 views

Numerical error in GLSL vector reflection

If I reflect a vector over a mirror, I expect it to end up on the other side of the mirror, even if there's a bit of numerical error. More precisely, if I run the GLSL code ...
user avatar
0 votes
0 answers
138 views

Specifying Fragment Shader Colors per Fragment (Instead of per Vertex)

I am learning about fragment shaders and have seen how by setting the colours of each vertex a triangle can be coloured via interpolation. However what if we want to use our own function to manually ...
user avatar
0 votes
0 answers
125 views

Problem with Quad-based Tessellation in GLSL generating incorrect vertex ordered tessellation

I am trying to perform quad-based tessellation using GLSL on Unity to be able to render polynomial-based parametric surfaces on a Unity quad. The quad-based tessellation using GLSL seems to be ...
user avatar
0 votes
0 answers
162 views

What quad will fill the screen, which can be inverse-projection-view transformed to map to the near frustum plane?

I've been experimenting with raytracing using GLSL. I had success rendering a cube which encloses the object. Now I want to do a full-screen raytrace, and I want to construct a quad which covers the ...
user avatar
  • 279
0 votes
0 answers
407 views

How to properly modify a ray in a raytracer to achieve camera rotation

I am trying to make a particular kind of raytracer, but there is some strange bug occurring when I attempt to rotate the camera. As you can see, there is some important distortion ocurring when the ...
user avatar
  • 1,449
-1 votes
1 answer
74 views

How to deform an object in glsl? (processing)

I am a beginner in glsl and processing. I have a cube, can I know how to deform it using mathematical or progammatical functions? ...
user avatar
-3 votes
1 answer
393 views

Multiple shader passes to the same texture?

o7 I am unable to find an answer to my question, because apparently it's not well enough defined to separate itself from a similar one. So I have to ask here. My problem is quite simple. I have ...
user avatar
  • 113