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.

Filter by
Sorted by
Tagged with
1 vote
0 answers
25 views

Is it possible to reduce aliasing in derivatives used to estimate normals from a texture?

I am generating a normal map for a texture for use in a PBR shader. I have a map for the diffuse texture, and I am estimating the normal at each point using the derivative of the texture's brightness....
  • 111
0 votes
0 answers
32 views

Cook-Torrance brdf with direct light sampling got strange result

I'm trying to implement the Cook-Torrance BRDF model in progressive MC ray tracing in glsl shader, I followed the tutorial on this blog, and use the method mentioned to importance sample the normal ...
  • 1
0 votes
0 answers
28 views

How do I make "attribute vec0.5" in GLSL. Sorry if it confuses

Is it possible, in OpenGL (specifically in WebGL), to use a single value from buffer for multiple shader iterations? Like to put the same element from buffer into shader attribute multiple times? Like:...
0 votes
1 answer
59 views

How is mipmap level used mathemetically in image sampling?

I am trying to simulate the behavior of "texelFetch()" and so far I've understood the following: If "gvec4 texelFetch(gsampler3D sampler, ivec3 P, int lod)" is given then : result =...
0 votes
0 answers
27 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 ...
  • 101
4 votes
1 answer
115 views

Artifacts while rendering sponza scene

I'm trying to render the Sponza scene using the Cook-Torrance BRDF Model Plugged with the GGX Normal Distribution, Gemoetry Schlick and fresnel Schlick approximation and a punctual point light. When ...
1 vote
1 answer
68 views

Why must texture samplers be uniform variables in GLSL?

To use a texture in an OpenGL shader, I have to write the Texture Unit to be used into a uniform variable: source.c: ...
  • 13
0 votes
0 answers
59 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: ...
  • 147
1 vote
1 answer
76 views

Is there a cost to querying a texture size inside a GLSL shader?

So I need to have a texture size for my compute shader. I found this function in GLSL to query this inside the shader: ivec2 textureSize = imageSize(outputImage) ...
  • 147
0 votes
0 answers
33 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 ...
  • 1,449
1 vote
1 answer
106 views

Having trouble understanding advection from GPU gems fluid dynamics example

So I am trying to implement a fluid simulation, as described in Chapter 38 of GPU Gems. I am also drawing heavily from the excellent implementation by Pavel. Where I'm getting a bit stuck is with ...
  • 147
0 votes
1 answer
97 views

Bump mapping WITH precomputed tangents?

Most bump mapping (meaning black and white height map) uses Tangents/Bitangents computed from Position using dFdx/y. And they also compute the offsets/derivatives of the height map using dFdx/y. The ...
  • 51
0 votes
0 answers
103 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() ...
1 vote
1 answer
76 views

Defining the proper sdf for this structure

I am making a procedural sdf (just a bunch of cubes) based of an image. The idea is very simple. We have a stencil image: Each texel in the image corresponds to a 3D cube. So to ray trace what I am ...
  • 1,449
2 votes
0 answers
41 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 ...
2 votes
1 answer
38 views

using parts of GL_TEXTURE_2D_ARRAY as GL_TEXTURE_CUBEMAP_ARRAY

I am using layered rendering for all my light sources to avoid rendering multiple times. I have lightSourceCount many point lights and one sun, which is implemented ...
  • 551
-1 votes
1 answer
94 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? ...
0 votes
0 answers
173 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&...
's user avatar
0 votes
0 answers
79 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 ...
2 votes
1 answer
50 views

enable / disable transform feedback within glsl for specific primitives

I am using the tessellation shader stage to increase the density of triangles close to camera. Thereby when the camera is too close to a triangle, so that the maximum tessellation is not high enough, ...
  • 551
1 vote
1 answer
400 views

Opengl GLSL binding locations confusion

The background of this question is that I am trying to write an automatic binding system, where for each uniform variable I want to declare in my GLSL code, I call a method ...
  • 551
0 votes
0 answers
62 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 ...
  • 551
1 vote
1 answer
120 views

Convert image to CIE Lab using GLSL to change hue/chroma

It is possible to convert an image or other output to CIE Lab color model using GLSL? Does it require compute shaders or can be done using only vertex shaders?
0 votes
0 answers
63 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 ...
0 votes
2 answers
115 views

Ambient occlusion depth buffer normalization

Been trying to follow a shader from A Comparative Study of Screen-Space Ambient Occlusion Methods http://frederikaalund.com/wp-content/uploads/2013/05/A-Comparative-Study-of-Screen-Space-Ambient-...
  • 3
0 votes
1 answer
72 views

Tiling in GLSL creates unwanted seams

I'm writing a shader that creates a grid with coloured tiles. The color is derived from a pixel at that location on a texture. But around the tiles I get these unwanted seams. I can't seem to figure ...
  • 103
2 votes
1 answer
173 views

Having trouble implementing distance transform with jump flood

I'm attempting to use the jump flood algorithm to compute distance transforms of an arbitrary texture derived from a canvas2d context, roughly following the explanations detailed here/here. In the ...
  • 23
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 ...
2 votes
1 answer
117 views

Is there a better, more elegant way of translating/rotating my camera in my 3d raymarched world or am I stuck with trigonometry?

What I am trying to achieve So I'm a fractal enthusiast and decided to build a 2D/3D fractal generator in WebGL using raymarching, with Typescript as scripting language. I've been a C#/Typescript dev ...
0 votes
1 answer
650 views

How to render fog in OpenGL

I have a simple question just because I can’t find any good example in the internet. How to create fog without using particles? How to make for with different density on different locations and in ...
  • 3
0 votes
1 answer
120 views

Dynamic Loop Based on Uniform

My question is fairly simple but I guess it contains two questions, one is how to arrive at an answer (imagine a similar one and you want to deduce it using existing tools like a GLSL compiler or the ...
3 votes
1 answer
290 views

Compute Shader shared average value

Short Question: How can i integrate a buffer variable in a compute shader over each pixel i.e. how can i ensure memory coherence in such a case? Long Question: I've written a deferred renderer with ...
0 votes
2 answers
196 views

glsl passing data array from vertex to tessellation control shader

I am trying to pass a vec3 array from vertex shader to tessellation shader. passing just one value works fine, but how to pass an array? Vertex shader ...
  • 551
0 votes
1 answer
80 views

optional geometry shader

I am looking for an easy solution for passing information between shader stages when adding additional shader stages. Right now I am using the "out" keyword to pass data from for example ...
  • 551
0 votes
1 answer
403 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 ...
1 vote
0 answers
100 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 ...
  • 11
0 votes
1 answer
73 views

Level of detail passed from vertex shader to fragment shader

I am looking at a sample code from a respected source and the mipmap level-of-detail parameter (float) is passed to the vertex shader as a uniform which then passes to the fragment shader without ...
0 votes
1 answer
435 views

gl_ClipDistance vs gl_CullDistance

Why are there very similar yet distinct arrays: gl_ClipDistance[] vs gl_CullDistance[]? What would be some use cases where the ...
0 votes
1 answer
55 views

SSBO get block of data instead of iterating

I have a mesh, each face (triangle) of the mesh needs to read some information out of a SSBO object. Is there a way to read out a block (lets say 100 floats) at once? Or do I need to iterate over the ...
  • 551
0 votes
1 answer
67 views

Scale Sampled Depth Value

I am currently porting the atmosphere algorithm used by the UE4 engine to my engine. As the original algorithm from Bruneton is in Kilometers i had to adapt it to my engine which uses meters. ...
1 vote
2 answers
314 views

Is there an efficient way to achieve color blending in compute shaders?

What I want is a function like imageStore, but instead of replacing a value - applying a blend operation to it, e.g. addition. It is not possible to do something ...
1 vote
1 answer
48 views

Mat4 that is written to a storage buffer in a compute shader has an altered value when read back

I am attempting to use a compute shader to calculate joint transforms for animations. I use a loop to calculate the global joint transforms from the local transforms. Relevant code below: ...
  • 21
1 vote
1 answer
2k views

Understanding fragment shader coordinate system

I'm trying to create an infinitely panable grid using fragment shaders (C++/OpenGL/GLSL), and I'm having a bit of difficulty understanding the coordinate system. This is my fragment shader code, ...
1 vote
1 answer
236 views

Opengl : GLSL utility files

We can create header files in C/C++ which we can include in our project using #include directive but when I use this keyword in my shader it gives the error reserved keyword. If let's say I create an ...
  • 169
1 vote
2 answers
413 views

Is there a way to compile part of a shader into a spirv?

I want to have separate files for common things for shaders precompiled into a spirv. For example PBR, I've got these functions and implementations for them ...
3 votes
0 answers
447 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 ...
  • 31
1 vote
1 answer
921 views

GLSL Compute Shader Setting "shared" memory buffer size

Is it possible to set the size of the shared memory of a compute shader workgroup from the host code? There is a way to do this in CUDA and I am suspecting that, since there is an GLSL extension to ...
0 votes
1 answer
123 views

imageLoad() behavior for non-existent texel

Is there a way to influence the behavior of imageLoad() for accessing an image2D or uimage2D ...
0 votes
0 answers
76 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 ...
3 votes
0 answers
309 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 ...

1
2 3 4 5