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
1 answer
48 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 ...
user avatar
  • 1,447
1 vote
0 answers
20 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
3 votes
1 answer
31 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 ...
user avatar
  • 519
-1 votes
1 answer
57 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
0 votes
0 answers
69 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
48 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
3 votes
1 answer
35 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, ...
user avatar
  • 519
1 vote
1 answer
162 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 ...
user avatar
  • 519
0 votes
0 answers
56 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
  • 519
1 vote
1 answer
81 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?
user avatar
0 votes
0 answers
60 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
2 answers
93 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-...
user avatar
  • 3
1 vote
1 answer
61 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 ...
user avatar
  • 113
3 votes
1 answer
140 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 ...
user avatar
  • 33
0 votes
0 answers
35 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
2 votes
1 answer
103 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 ...
user avatar
0 votes
1 answer
428 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 ...
user avatar
  • 3
0 votes
1 answer
61 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 ...
user avatar
3 votes
1 answer
190 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 ...
user avatar
0 votes
2 answers
98 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 ...
user avatar
  • 519
0 votes
1 answer
54 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 ...
user avatar
  • 519
0 votes
1 answer
295 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
1 vote
0 answers
69 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
2 votes
0 answers
54 views

OpenGL invalid location when using a literal value in C++, but works when using glGetUniformLocation before

I have a call glUniformMatrix4fv(42, ...other parameters...) with a shader that has layout (location = 42) uniform mat4 someMat; ...
user avatar
  • 125
0 votes
1 answer
66 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 ...
user avatar
0 votes
1 answer
282 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 ...
user avatar
0 votes
1 answer
52 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 ...
user avatar
  • 519
0 votes
1 answer
63 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. ...
user avatar
1 vote
2 answers
235 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 ...
user avatar
1 vote
1 answer
43 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: ...
user avatar
  • 21
1 vote
1 answer
1k 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, ...
user avatar
1 vote
1 answer
191 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 ...
user avatar
  • 169
1 vote
2 answers
292 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 ...
user avatar
3 votes
0 answers
370 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
1 vote
1 answer
795 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 ...
user avatar
0 votes
1 answer
80 views

imageLoad() behavior for non-existent texel

Is there a way to influence the behavior of imageLoad() for accessing an image2D or uimage2D ...
user avatar
0 votes
0 answers
67 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
3 votes
0 answers
229 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
1 vote
0 answers
117 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
0 votes
1 answer
31 views

Equally distribution on triangle surfaces

I would like to implement a random placement for objects like trees stones etc. on a triangles surface. The important part is to have an equally probability to place an object on this surface. That ...
user avatar
  • 519
2 votes
0 answers
70 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
3 votes
0 answers
117 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
0 votes
2 answers
384 views

Using imageLoad/imageStore to perform atomic add

I have a rgba16f texture that I fill with values using nvidia GL_NV_shader_atomic_fp16_vector extension, which allows to perform ...
user avatar
  • 2,037
0 votes
1 answer
47 views

Problem sampling uniformly envmap with GGX

I have made a program that samples uniformly an environment map and computes the lighting using the GGX BRDF. I have made a small example that reproduces the issue I'm having. You can check it out ...
user avatar
2 votes
1 answer
859 views

Is there different between 'if' and 'ternary operator' in GLSL?

I'm practicing GLSL on ShaderToy ...
user avatar
  • 31
1 vote
1 answer
110 views

draw on cubemap with help of geometry shader each triangle covers each cubemap face (why??)

I want to do some complicated stuff but have problems with my geometry shader / FBO bindings. To hold it as easy as possible I reduced the code to a minimum. If this works, I could continue the hard ...
user avatar
  • 519
2 votes
2 answers
304 views

OpenGL - Recreate position in viewspace from depth values

Current state: I belive the reconstructed positions are correct. However, I still have the same problem as all the time. When I rotate around my single pointlight appears to be moving around also. I ...
user avatar
  • 126
1 vote
0 answers
161 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
2 votes
1 answer
1k views

How to work around the pointer limitations of GLSL?

(I am new to Computer Graphics in general) I am learning how to ray trace from a book called ''Peter Shirley - Ray Tracing in One Weekend''. In the book, the code is written in C++. I have ...
user avatar
  • 121
1 vote
0 answers
189 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
2 3 4 5