Questions tagged [glsl]

256 questions
Filter by
Sorted by
Tagged with
85 views

So I seem to have some trouble getting a geometry shader working with "glDrawArrays(GL_LINE_STRIP, 0, 4);". When I omit the geometry shader and make some minor variable changes, the vertex ...
1 vote
32 views

Why does my implementation of a sinusoidally time-varying color work so slowly?

I've been following TheCherno's OpenGL tutorials and I got to the point where I could render a square by using an index buffer. Now I wanted to vary the color of the square by using \frac{\sin(t) + ...
• 111
21 views

Doing spectral analysis in GLSL, how can I get FFT-level fidelity in my results?

I'm using GLSL to do spectral analysis of an input signal. I do the math to associate each pixel (in a single row) with a frequency, then use [The Goertzel Algorithm][1] to determine the contribution ...
66 views

What kind of code would it take to visualize just 1 3d gaussian in Godot?

I'm trying to create the simplest possible implementation of the gaussian visualization code from this paper in Godot, https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/ but I just don't even ...
• 103
65 views

How to correctly handle rendering of ~600000, arbitrary colored 2D squares with WebGL?

Information I have to render a map, that is rendered as a 2d collection of squares of different color, separated by white lines horizontally and vertically. There may be ~600000 squares surrounded by ...
50 views

What's the type of iChannel[0-3] in Shadertoy?

I'd like to have a helper function in the Common tab that does something fancy with texture input and returns the result. I'd like the function in question to be able to use any ...
1 vote
31 views

How are multisample samples partitioned in OpenGL, and at which points does interpolation take place?

As I understand it, with glEnable(GL_MULTISAMPLE), glEnable(GL_SAMPLE_SHADING) and ...
• 163
1 vote
30 views

GLSL Uniform Layout Spec says member array stride alignment is rounded up to vec4?

in GLSL spec section 7.6.2.2 about Standard Uniform Block Layout, rule (4) says: If the member is an array of scalars or vectors, the base alignment and array stride are set to match the base ...
• 1,851
32 views

interpolated normal vectors after tessellation. How to hash patch corner / edge vertices?

I have a 3D geometry (an asteroid) that is to be tessellated with respect to the camera position. Each vertex in the original mesh has a unique position and is stored once (VBO with IBO) In the ...
• 1,136
70 views

How are strings for debugPrintfEXT handled in glsl?

Glsl does not support string / char data types, but obviously debugPrintfEXT works and takes some form of string. How are these handled in glsl? Ideally I would ...
• 1,541
1 vote
78 views

Is it possible to read arbitrary data at arbitrary array offset in glsl?

TL;DR In a Vulkan / GLSL ray tracing program, I have several shader files, all accessing the same material buffer of arbitrary data. All materials have an arbitrary layout, e.g. one might be a float, ...
• 1,541
1 vote
41 views

Need help understanding this simplification/optimization for a very basic GLSL shader

i'm currently following a tutorial on youtube to get started with computer graphics (shaders) and it contains the following GLSL code: ...
• 13
202 views

Vulkan backward-only path tracer with caustics

TL;DR -- who has discovered, in the past, a backward-only path tracer that generates caustics not needing extra convergence of any kind? I'm collecting similar algorithms, in order to fully understand ...
185 views

GLSL get min/max index of vec3

I have written a function in GLSL that returns the min index (index 0 is the x component, 1 is the y component, and 2 is the z component) of a vec3 variable. ...
• 1,136
28 views

How to interpolate alpha from CURRENT_ALPHA to TARGET_ALPHA for each pixel in shader language? (Godot/GLSL)

I want to make "trails" of objects on my shader that appear and disappear gradually. I am getting pixels (for fragment shader) where objects are from uniform texture. Basically, I have my ...
• 373
52 views

"Smoothing out" raymarched reflections

I am writing a program to display 3-dimensional lattices (honeycombs) using raymarching and reflections. I made a simple cubic honeycomb to start. The usual method is to use a repetition operator, by ...
• 101
1 vote
126 views

is there an universal way to set a uniform?

so I'm working on a game engine. It's partially python and c++. One part that is currently a pain point is setting the uniforms for shaders. Currently I have to define a behavior for all 50+ methods ...
68 views

How to scale down noise frequency?

I'm making a space game and so far what I have is a system to generate spheres with noise on them, making them planets. I make a sphere, create noise data, write that data to an image file, and then ...
• 11
1 vote
36 views

Curved world effect shader for heterogeneous mesh faces

I have a voxel based game, similar to Minecraft and want to apply the "curved world effect" like described here. As I was using a per 1x1 face quad renderer, applying the effect went well, ...
• 113
1 vote
59 views

Numerically integratable fog volume feathering along a ray

I haven't been able to come up with a good solution for this myself, so I thought I'd ask if anyone else has any good ideas on how to approach this problem. Here's more or less what I'm trying to do ...
1 vote
104 views

GLSL : Extremely slow compilation when using loop

I am making multiple gradients with GLSL. However, when I started using a loop instead of a lengthy else if condition, the compile time jumped from 2-4sec to 40sec !...
1 vote
191 views

Having trouble rendering entire sphere

I'm working on a program where I need to draw spheres. The method I'm using is creating an octahedron And using tessellation shaders to subdivide it into a sphere, however there is a patch of the ...
• 11
143 views

want bokeh blur with custom shapes

I have a 2d texture and a shape matte, the matte could be any shape, like a star, heart, and so on, and I want to use this matte to generate different-shaped bokeh blur, how can I do it? and normally, ...
50 views

Opengl binding different mipmap levels of same texture2darray for use in compute shader. How to handle variable nr of levels?

So I want to make a compute shader that uses a coarse-to-fine approach. As I have learned about open gl mipmap levels it seems they could be very useful. However the only binding method which I have ...
• 125
1 vote
104 views

How can I test my GLSL code on different hardware?

I've written a game engine in OpenGL and developed it on my computer with an NVidia GTX 1060. I'm now ready to start releasing it into the wild but I'm worried about hardware issues. I compile my ...
• 57
71 views

Bottle neck in fragment shader because large number of texture2D call

Are there any way to optimize this flow: The frame captured from camera (NV21 byte array) Convert this frame to I420 format Upload Y data to y_tex; U data to ...
104 views

Splitting Floats To Texture Channels

I know, this is a silly question, but since I need this so often, I just want to double check that I made no mistake. Working with most shader languages, a texture can store $8$ bits per channels, ...
• 127
1 vote
104 views

GLSL trying to bind two different layers from the same texture array as images. Should it work and if so what am I doing wrong?

I am new at this particular site in the SE ecosystem, but not to computer graphics in general. If I'm in the wrong spot feel free to redirect me. My question regards glsl programming and binding two ...
• 125
98 views

Porting from DXR/HLSL to Vulkan Ray Tracing Extension/GLSL

I am working on the port of a demo from DXR to Vulkan Ray Tracing extension using GLSL. In DXR/HLSL space, there are RayTMin() and RayTCurrent() functions to retrieve the starting and the current end ...
• 299
1 vote
134 views

Best way for rendering Voronoi diagram from Delaunay graph mesh

I have a set of points, which I triangulate to a Delaunay graph to make a mesh. Every mesh vertex has a unique colour, and I can render it without any problem. But I want Voronoi rendering to be ...
1 vote
32 views

Why shouldn't I discard faces during Tessellation control stage

In the discussion Here there was said, that discarding faces during Tessellation stage should be avoided. What are the reasons for that? Right now, I am rendering a 3D geometry using Vertex, ...
• 1,136
157 views

Why does GLSL smoothstep return 0 when all parameters are literal floats?

I was working through https://thebookofshaders.com/05/ when I came across some unintuitive behaviour of smoothstep. I wanted to understand it better so I replaced ...
• 83
173 views

combinatoric explosion of sampler2D, sampler2DArray, samplerCube

I use uber-shader approach and am having issues fitting within 16 texture units. My material uses 3 textures: albedo, special, and normal map. However, any of these textures can be regular 2D, or 2D ...
• 41
90 views

My n-body simulation doesn't form a galaxy

I'm trying to create a galaxy simulation using opengl with the compute shader and when I start my simulation, the galaxy with the spiral arms doesn't form, instead it goes into chaos. I noticed that ...
75 views

Is there a good rule of thumb for the optimal / maximum number of instances to draw in a single call?

So let's say I want to draw a lot of textured quads to the framebuffer. In each shader invocation, I will bind an array of indicies, an array of positions, and an array of textures to index into. ...
• 159
1 vote
154 views

What are the main concepts behind building the plasma effect with GSLS?

By the plasma effect I mean an animation that looks like this: I have seen some codes, like these https://www.shadertoy.com/view/Xst3zN https://www.shadertoy.com/view/4tdGWX and messed with the code ...
• 31
1 vote
35 views

How to make elevated parts of a steep plane seem darker than the lower surface? [GLSL]

I made a plane in THREEjs using Mesh, PlaneGeometry and ShaderMaterial. It's a very simple/basic form. I applied a simple phormula to make the plain more steep. Now I'm trying to make the lower ...
• 111
441 views

I am calculating the Summed Area Table(SAT) of a texture with help of a compute shader in OpenGL. The texture which needs to be summed, has a dimension size of more than my GPU supports (...
• 1,136
453 views

GLSL normalized texture coordinate to pixel coordinate

I've a texture (2048 x 2048) Pixels. I am looking for an algorithm to transform the normalized texture coordinate [0 1] to pixel coordinate [0 2047]. This should be a perfect fit... So when the ...
• 1,136
1 vote
80 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
36 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:...
197 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 =...
218 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
894 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
1 vote
329 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: ...
• 159
1 vote
628 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) ...
• 159
46 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,696
1 vote
234 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 ...
• 159
146 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
1 vote