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
0 votes
2 answers
85 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 ...
0 votes
1 answer
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 ...
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 ...
1 vote
1 answer
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 vote
0 answers
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) + ...
0 votes
0 answers
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 ...
0 votes
0 answers
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 ...
0 votes
2 answers
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
0 answers
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 ...
1 vote
1 answer
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 vote
1 answer
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 ...
0 votes
1 answer
744 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
1 answer
533 views

Mimic shadertoy in WebGL

I was following this guide for drawing circles using shadertoy. Now I am trying to mimic the examples behaviour in WebGL. Here is a working shadertoy example I try to mimic. The code is not mine, see ...
0 votes
0 answers
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 ...
0 votes
1 answer
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 ...
0 votes
0 answers
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 ...
1 vote
1 answer
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: ...
0 votes
1 answer
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. ...
0 votes
0 answers
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 ...
0 votes
1 answer
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, ...
0 votes
0 answers
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 ...
1 vote
1 answer
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 ...
0 votes
1 answer
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 ...
1 vote
1 answer
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, ...
1 vote
0 answers
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
1 answer
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 ...
1 vote
0 answers
940 views

How Skia uses OpenGL backend?

Skia 2D's one notable backend in OpenGL, but how does it work under the hood to render? Say, we need to draw an anti-aliased circle. Does Skia: make a quad (using 2 triangles) and paint the circle ...
0 votes
0 answers
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 ...
1 vote
1 answer
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 ...
0 votes
2 answers
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 ...
0 votes
0 answers
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 ...
0 votes
1 answer
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, ...
1 vote
1 answer
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 ...
0 votes
2 answers
140 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 ...
2 votes
2 answers
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 ...
1 vote
1 answer
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
1 answer
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, ...
0 votes
1 answer
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 ...
0 votes
0 answers
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 ...
0 votes
1 answer
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. ...
1 vote
0 answers
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 ...
1 vote
0 answers
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 ...
0 votes
1 answer
441 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 (...
0 votes
0 answers
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 vote
0 answers
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....
0 votes
0 answers
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:...
0 votes
1 answer
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 =...
2 votes
2 answers
3k views

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

I'm practicing GLSL on ShaderToy ...
4 votes
1 answer
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
1 answer
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: ...

1
2 3 4 5 6