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
2 votes
0 answers
77 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 ...
Noah Greenrock's user avatar
2 votes
1 answer
104 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 ...
Thomas's user avatar
  • 1,136
-1 votes
1 answer
312 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? ...
Tragend's user avatar
2 votes
1 answer
131 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, ...
Thomas's user avatar
  • 1,136
1 vote
2 answers
2k 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 ...
Thomas's user avatar
  • 1,136
0 votes
0 answers
78 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 ...
Thomas's user avatar
  • 1,136
1 vote
1 answer
221 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?
vaunnaut's user avatar
0 votes
0 answers
168 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 ...
Parker Queen's user avatar
0 votes
2 answers
244 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-...
Boinking's user avatar
0 votes
2 answers
138 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 ...
polyclick's user avatar
  • 103
2 votes
1 answer
357 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 ...
Nico's user avatar
  • 23
0 votes
0 answers
52 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 ...
user17440's user avatar
2 votes
1 answer
196 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 ...
Arthur Visser's user avatar
0 votes
1 answer
2k 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 ...
Mike F's user avatar
  • 103
0 votes
1 answer
460 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 ...
Felipe Gutierrez's user avatar
3 votes
1 answer
780 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 ...
Sprinklerkopf's user avatar
0 votes
2 answers
468 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 ...
Thomas's user avatar
  • 1,136
0 votes
1 answer
191 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 ...
Thomas's user avatar
  • 1,136
0 votes
1 answer
738 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 ...
Michael Sohnen's user avatar
1 vote
0 answers
174 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 ...
mcb's user avatar
  • 111
0 votes
1 answer
98 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 ...
Vectorizer's user avatar
0 votes
1 answer
873 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 ...
Vectorizer's user avatar
0 votes
1 answer
76 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 ...
Thomas's user avatar
  • 1,136
0 votes
1 answer
94 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. ...
André Ferreira's user avatar
1 vote
2 answers
591 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 ...
user369070's user avatar
1 vote
1 answer
67 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: ...
xyz's user avatar
  • 33
1 vote
1 answer
3k 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, ...
Andrew Woo's user avatar
1 vote
1 answer
485 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 ...
Sync it's user avatar
  • 169
1 vote
2 answers
724 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 ...
JanuszGrafiki's user avatar
5 votes
0 answers
779 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 ...
racz16's user avatar
  • 151
1 vote
1 answer
1k 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 ...
Vectorizer's user avatar
0 votes
1 answer
270 views

imageLoad() behavior for non-existent texel

Is there a way to influence the behavior of imageLoad() for accessing an image2D or uimage2D ...
Vectorizer's user avatar
0 votes
0 answers
116 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 ...
Vectornaut's user avatar
3 votes
0 answers
554 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 ...
user1754322's user avatar
1 vote
0 answers
303 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: ...
user14063792468's user avatar
0 votes
1 answer
46 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 ...
Thomas's user avatar
  • 1,136
2 votes
0 answers
82 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 ...
user10037795's user avatar
3 votes
0 answers
160 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 ...
user1754322's user avatar
0 votes
2 answers
759 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 ...
mdkdy's user avatar
  • 2,119
0 votes
1 answer
90 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 ...
user1754322's user avatar
2 votes
2 answers
3k views

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

I'm practicing GLSL on ShaderToy ...
Oh Seo's user avatar
  • 31
1 vote
1 answer
295 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 ...
Thomas's user avatar
  • 1,136
2 votes
2 answers
636 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 ...
the1bird's user avatar
  • 126
1 vote
0 answers
329 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 ...
weichsem's user avatar
  • 111
2 votes
1 answer
2k 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 ...
sigsegv's user avatar
  • 121
1 vote
0 answers
320 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/...
FShrike's user avatar
  • 205
1 vote
1 answer
338 views

Does atomic functions on same memory location cause an performance issue?

is it worse to do for each invocation an atomicAdd on the same memory location than doing for each invocation an atomicAdd to a unique memory location? (I know, atomicAdd does not make sense when each ...
Thomas's user avatar
  • 1,136
2 votes
1 answer
164 views

Rendering moist/wet materials like human anatomies for surgical simulators

Real human anatomies look wet/ moist when operated. I am looking for some good methods for rendering anatomies in a virtual simulation, and hence I have done a literature survey on 'Rendering wet ...
Argha Chakraborty's user avatar
0 votes
1 answer
76 views

Closest sphere on segment

I am trying to get a segment closest point on a surface and display a circle (or sphere in this case) at that position. I actually get the correct position but I can't get a uniform sphere based on ...
MaT's user avatar
  • 1,219
3 votes
1 answer
214 views

OpenGL task/mesh shader extension NV_mesh_shader not behaving as I expected

I am trying to get up to speed with the NV_mesh_shader extension from NVidia (on my RTX2080). Samples are rare, so I tried to come up with my own small sample. I am rendering a sphere (20 triangles) ...
pettersson's user avatar