Skip to main content

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
3 votes
1 answer
97 views

What's the difference of using smoothstep and linear interpolation for antialiasing?

I am currently writing a fragment shader where I want to draw an antialiased line. My first instinct was to calculate the color of each pixel based on the distance to the line. Something like: (using ...
Mos's user avatar
  • 33
0 votes
0 answers
23 views

Conversion of the Cubemap direction access vector to UV coordinates

In GLSL, cubemaps within a shader can be read with gvec4 texture(gsamplerCube sampler, vec3 P, [float bias]); so a direction is used. How can the direction ...
Thomas's user avatar
  • 1,366
1 vote
2 answers
43 views

Confusion about camera ray pdf

When I was studying a code base of path tracing implementation (done in GLSL), I notice the author returned a pdf of generated camera ray: ...
Victor Li's user avatar
0 votes
0 answers
28 views

HealPix: Different results when comparing C++ and Vulkan

I have converted the algorithm for calculating the HealPix value from Lat/Lon values from C++ to GLSL. The result is saved in a BMP image and looks correct. Both algorithms (C++ and GLSL) use the same ...
Thomas's user avatar
  • 1,366
0 votes
0 answers
11 views

Issues with vxgi implementation when rotating the camera

right now I have implemented vxgi algorithm. Voxelization is working fine, same for mipmap generation. But, I have an issue when I rotate the camera. Basically, it is not stable when it is rotated. I ...
Zhukov Artem's user avatar
0 votes
0 answers
54 views

Unit tests and code coverage tool for GLSL compute shaders

I use some compute shaders for some GPGPU usage. Each method of each shader must have unit tests. These unit tests must cover more than 95% of the code. I am looking for tools that I can use to write ...
Thomas's user avatar
  • 1,366
0 votes
0 answers
19 views

Tools to identify the cyclomatic complexity of GLSL code

In principle, cyclomatic complexity is a quantitative measure of the number of linearly independent paths through the source code of a program. I am forced to keep the cyclomatic complexity of our ...
Thomas's user avatar
  • 1,366
1 vote
0 answers
102 views

Projecting a texture onto UVs with GLSL

I am trying to project an image overlayed on top of a mesh in screen space back to it's uvs. The UV triangles do not always cover entire pixels so i get this. The red is showing where the texture is ...
Dusan Bosnjak 'pailhead''s user avatar
0 votes
0 answers
18 views

Reflective shadow maps sampling

I'm following the old RSM paper and I don't understand the sampling section. I understand that it's a disc pattern, that is more scattered away from the center and has some weights. I don't understand ...
Dusan Bosnjak 'pailhead''s user avatar
0 votes
1 answer
279 views

Preferred GPU API to use for Steam Deck, Windows, Linux and MacOS support

Good people of the graphics SO community, I am new to Graphics programming or GPU programming in general but I have been a game dev enthusiast for over 4-5 years. I started learning about Graphics ...
Prav's user avatar
  • 101
0 votes
1 answer
64 views

Slice a volume in GLSL using raymarching

I'm currently visualizing scientific data as volumes using Three and GLSL. I have a raymarching script that is pretty standard and colors based on a colormap I feed into the shader. It looks like this ...
TheJeran's user avatar
  • 121
1 vote
0 answers
43 views

How can you tessellate degenerate triangles evenly?

If you use the tessellation shader for triangle patches, you can only set the following four values to define the tessellation structure of the triangle: ...
Thomas's user avatar
  • 1,366
1 vote
1 answer
60 views

Detecting edges on really small float-value differences

I'm working on a game that has a big proc. generated map (10000km by 20000km). The map generation is based on multi-octave perlin noise. ...
wcobalt's user avatar
  • 111
0 votes
0 answers
62 views

OpenGL hash vertices by position does not work on shared tessellated edges

I have a triangular mesh with common vertices (VBO and EBO/IBO) that contain the normal vectors. If I tessellate this mesh, the subdivision of the triangle edges of neighboring triangles has the same ...
Thomas's user avatar
  • 1,366
0 votes
0 answers
50 views

Shader ported from shadertoy does not behave in the same way

I tried porting the main "Image" shader here this. My results are somewhat similar apart from the fact that "IRES" does not seem to behave in the same way as it does in Shadertoy. ...
dearn44's user avatar
  • 101
0 votes
0 answers
68 views

GLSL reflect function math correct?

In the documentation of GLSL - reflect given a surface normal $N$ and an incident vector $I$ the calculation being performed is reported as $$ \text{reflect}(I,N) = I - 2\text{dot}(I,N)N $$ I wonder ...
user8469759's user avatar
1 vote
2 answers
290 views

Geometry Shader Not Working

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 ...
TFamIdoing's user avatar
1 vote
0 answers
42 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) + ...
Doobius's user avatar
  • 111
0 votes
1 answer
185 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 ...
h4ckthepl4net's user avatar
0 votes
2 answers
457 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 ...
Sniggerfardimungus's user avatar
1 vote
0 answers
88 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 ...
Simon's user avatar
  • 213
1 vote
1 answer
118 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 ...
wip's user avatar
  • 1,871
0 votes
1 answer
228 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 ...
Tare's user avatar
  • 1,603
1 vote
1 answer
266 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, ...
Tare's user avatar
  • 1,603
1 vote
1 answer
95 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: ...
Seth's user avatar
  • 113
0 votes
0 answers
264 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 ...
shawn_halayka's user avatar
1 vote
2 answers
1k 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. ...
Thomas's user avatar
  • 1,366
2 votes
2 answers
675 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 ...
LemonJumps's user avatar
0 votes
1 answer
143 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 ...
Chillzy's user avatar
  • 11
1 vote
1 answer
71 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, ...
Aitch's user avatar
  • 113
2 votes
1 answer
130 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 ...
smootherstep's user avatar
1 vote
0 answers
196 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 !...
Ambroise Rabier's user avatar
1 vote
1 answer
210 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 ...
Chillzy's user avatar
  • 11
0 votes
1 answer
408 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, ...
Caleb Edwards's user avatar
1 vote
1 answer
144 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 ...
JHall's user avatar
  • 57
0 votes
0 answers
75 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 ...
Viète's user avatar
  • 1
0 votes
1 answer
221 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, ...
fweth's user avatar
  • 127
1 vote
1 answer
186 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 ...
mathreadler's user avatar
0 votes
2 answers
158 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 ...
Vectorizer's user avatar
1 vote
1 answer
223 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 ...
Francesco Sollazzi's user avatar
1 vote
1 answer
47 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, ...
Thomas's user avatar
  • 1,366
2 votes
2 answers
286 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 ...
AJP's user avatar
  • 83
0 votes
1 answer
278 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 ...
Tomas's user avatar
  • 41
0 votes
0 answers
100 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 ...
Sedenion's user avatar
1 vote
1 answer
199 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. ...
sak's user avatar
  • 179
1 vote
0 answers
276 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 ...
Jonas's user avatar
  • 31
1 vote
0 answers
37 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 ...
Jonas's user avatar
  • 111
0 votes
1 answer
745 views

OpenGL compute shader workgroup synconization

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 (...
Thomas's user avatar
  • 1,366
0 votes
0 answers
680 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 ...
Thomas's user avatar
  • 1,366
1 vote
0 answers
141 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....
Ameo's user avatar
  • 111

1
2 3 4 5 6