Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
0answers
38 views

Understanding bad shadows with voxel ray tracing

I have a voxel raytracer that is generating some weird shadows and I want to understand what is the source of the problem. The image is voxelized, resulting in: I then generate Hard shadows from the ...
0
votes
1answer
99 views

SSAO random noise vector generation

I am currently trying to implement SSAO on my graphics engine. I am following John Chapman's tutorial here. This is a pretty popular article that is used as reference in many SSAO articles. The part ...
0
votes
0answers
73 views

Why am I getting those artifacts in my branchless/flattened GLSL raytracer?

I sat down this afternoon and tried to make a branchless WebGL ray tracer based on smallpt. For a strange reason that I can't understand at the moment the raytracer accumulates to this: The only ...
1
vote
0answers
48 views

glTexSubImage3D throws GL_INVALID_ENUMERATION on NVIDIA

I'm having problems when using the following statement on different GPUs: glTexSubImage3D(target, 0, 0, 0, 0, width, height, layers, format, type, NULL); on ...
1
vote
0answers
152 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
0answers
50 views

Least painful way of porting OpenGL renderer from Mac to Windows

Can experienced people advise me some tools/approaches for porting my OpenGL engine from Mac to Windows? I've been developing a renderer using C++ as much as possible, but the 'tool' part is written ...
2
votes
0answers
178 views

Circular pattern aliasing in voxel ray tracer

I am doing a voxel based raytracer. In other words, I first voxelize the scene using rasterization and I proceed to raytrace the volume in a 3D image to generate a final frame. Currently I noticed ...
0
votes
0answers
54 views

How to properly modify a ray in a raytracer to achieve camera rotation

I am trying to make a particular kind of raytracer, but there is some strange bug occurring when I attempt to rotate the camera. As you can see, there is some important distortion ocurring when the ...
0
votes
0answers
44 views

Performance drop caused by vertex shader

I'm rendering the Sponza scene and performance drops based on how many objects are located in camera frustum. Worst case scenario takes up to 25ms per frame, but when looking close at a flat wall ...
3
votes
1answer
497 views

Is a branched discard to be avoided

When a simulating a camera, I may run into the situation that a black elliptic border is needed (rather than a rectangular image). In this case I have the option to discard the fragment in the ...
1
vote
1answer
223 views

How to use GLSL texelFetch?

I have read the OpenGl documentation of texelFetch, which is: gvec4 texelFetch(gsampler2D sampler, ivec2 P, int lod). I know the first argument "sampler" is just a texture. But I am very confused ...
3
votes
1answer
91 views

How to align Ray Marching on top of traditional 3D rasterization?

I'm trying to apply raymarching on top of 3D rasterization, ordering what 3D object gets displayed based on the depth of a rasterization pass and the raymarch depth. After getting the transform ...
0
votes
1answer
109 views

Curve rotation in GLSL fragment shader

I'm trying to figure out the correct math to rotate and translate a curve displayed in a fragment shader. What I try to accomplish is to define a curve, for example a sine curve, in a local ...
4
votes
1answer
158 views

Manually fetching 8 neighboring texels from 3D texture greatly decreases performance

I'm implementing manual interpolation between texels in a 3D texture to be able to discard some of them when needed. Compared to hardware interpolation, this process takes a lot of time. If I simply ...
0
votes
0answers
66 views

How can I convert implicit surfaces to 3D distance fields?

I discussed with people from ShaderToy about converting implicit surfaces to 3D distance fields.Of course, I can use domain operators to combine distance fields and build more complex shapes, but I ...
3
votes
4answers
134 views

How to access several textures from huge amount of textures in a shader?

I'm developing a light probe based GI solution and currently dealing with light leaks due to interpolation between probes located on opposite sides of the walls. I want to tackle the problem by ...
1
vote
1answer
165 views

How to get assembly code from GLSL Shader

I am new to optimizing shader code. Now that I have written an "optimzation", I want to make sure that it really speeds things up and is not just an unreadable version of what I intend to do. For this,...
0
votes
0answers
139 views

glGenerateMipmap does not generate mips for texture with a particular image

I load materials for my models using stbi library and upload pixels to textures through glTexImage2D function. Immediately after ...
1
vote
0answers
38 views

GLSL can't calculate texture and reflection

I'm working on a universal shader, and have a function for calculating reflections and a function for textures. When I run the shader, it seems to give up and discard all fragments. The texture and ...
1
vote
1answer
39 views

Non-point lights

Is there a technique for implementing non-point lights (i.e. light that has actual physical dimensions)? I can't think of anything except than making a light source out of multiple point lights, but ...
1
vote
1answer
86 views

Gravitational calculation of a particle via GLSL / WebGL

I have a running particle system which emits particles in a given radius. Now I want to add some gravity to it. The particles and velocities of each particle is saved in a 2D Texture, now I want ...
0
votes
0answers
28 views

Quaternions and intersection bugs for boxy SDFs

I'm using ray-marching to render simple shapes and test different mapping functions; rotating the shapes along a path lets me easily see all of each surface without clicking/dragging. Rendering boxes ...
5
votes
2answers
398 views

How can I convert signed distance field to a mesh?

I can easily make models by Modeling with Distance Functions but I need make mesh from It so I decide to use voxelizing and make triangles for my signed distance field torus like this video.but I ...
3
votes
1answer
135 views

GLSL shapes signed distance field implementation explanation?

I'm trying to understand all primitives In this article.After hard work I just learn Sphere and Cube , I wrote description here. I could draw 2D shapes but I have trouble understanding 3D below codes:...
4
votes
1answer
119 views

Is sub-texel shading possible?

I suspect the answer is no, but thought I'd ask anyway. It seems that other than using nearest neighbour and bilinear interpolations, there is nothing you can do to determine how two adjacent pixels ...
1
vote
1answer
97 views

What's wrong with my computation of the intersection of a ray with a sphere

I am learning GLSL and trying to raytrace a sphere. Here is a fragment shader. It correctly discards fragments which are not on the sphere, but when I try to calculate the point of intersection (and ...
1
vote
1answer
151 views

How to scale and offset a cubemap using sphere mapping

I am trying to scale and repeat a Cubemap with Latitude-Longitude mapping layout just as you would do with classical UV mapping but without any interesting result. This should be used as a skybox. ...
1
vote
1answer
80 views

Changing sin frequency smoothly in shader

In my vertex shader I am using a sin function to offset vertices. But as I change the frequency of my sin function I notice some ...
1
vote
2answers
177 views

Why would I specify image format in a shader layout qualifier?

The OpenGL wiki entry for layout qualifiers says: Image uniform variables have qualifiers that define the format that all reading operations will convert the data into... When is it a good idea to ...
5
votes
1answer
1k views

Double precision in shader

for better accuracy, instead of GLfloat, I bound double data and tried to use the data in shader as follow: (I just tested to draw single triangle.) cpp. ...
-1
votes
1answer
67 views

How to modify a part of VBO data without Compute Shader or OpenCL?

After binding the data to the vertex buffer object as follows, how to modify the buffer data? (Each subdata size is 3$*$ data size (three elements per index) ...
3
votes
1answer
219 views

Combine material coefficients and textures in Phong Shading

I'm trying to implement a simple Phong shader that supports non-physically-based materials and textures. Even though the material has a texture for each light component I still want the respective ...
2
votes
2answers
145 views

How to generate chaotic halftone pattern?

I'm trying to generate a random halftone like below image: this is a simple halftone that I tried, but I need a random halftone ...
1
vote
0answers
185 views

Depth aware blur - Kawase

I am using this Kawase Blur, to apply blur onto my buffer. But I would like to apply this blur in an uniform way, no matter the distance of the objects from the camera. I guess that I need to use the ...
3
votes
1answer
291 views

Getting rid of branching to check if a variable is within a range in GLSL

I have this GLSL function that I am trying to optimize because it is going to be ran on many pixels of an older devices GPU. There is no room for branching inefficiency. Essentially this function ...
6
votes
1answer
196 views

Ray tracing - partial derivatives for texture lookup

I'm doing some ray tracing on GPU using a fragment shader... How can I calculate texture coordinates partial derivatives with respect to screen coordinates so I could perform filtered texture lookup ...
1
vote
1answer
230 views

Shader storage buffer indexing by 4 bytes instead of 3?

I am trying to send rendering information for an instancing rendering using shader buffer objects. My current problem is that I have 2 shader buffer objects, one which works just fine, and another ...
1
vote
1answer
45 views

Issue with declaring inputs to geometry shader?

I am trying to pass vertex attributes from my vertex shader -> geometry shader and then to the fragment shader. Pretty simple program, here is my vertex shader: ...
5
votes
1answer
129 views

How to prevent moire artifacts in this light casting algorithm?

I am writing a 2D light casting algorithm with OpenGL compute shaders. The algorithm is simple: For each light source shoot out light rays from it, the ray begins at the light coordinates, it ends at ...
4
votes
1answer
463 views

How to dynamically calculate texture coordinates in a vertex shader with OpenGL?

I modified my code, and tried to pass a set of integers specifying the face of a cube (top, bottom left...) to the vertex shader in order to draw multiple instances of a cube face. I did this by ...
2
votes
1answer
3k views

GLSL. Can someone explain why gl_FragCoord.xy / screenSize is performed and for what reason?

I'm new to shaders and now that you can color pixel with gl_FragColor but sometimes there is this thing ...
3
votes
1answer
97 views

How can I implement GIMP's “Colorize” function?

I have an RGB pixel that I'd like to colorize in my program (I'm using GLSL) very similar to how the GIMP "Colors > Colorize" function works. In my program, I can easily convert between RGB and HSV. ...
1
vote
1answer
123 views

How do you scale an image across planes while retaining perfect tiling?

Scaling up or down a texture is quite simple, modify the UVs. In my particular scenario though, I have multiple "quads" (it is a patch tessellation shader) each with a tiling texture. Does anyone ...
1
vote
0answers
117 views

Nearest depth upsampling

Nvidia in this article presented a way to upsample low res buffer to full res buffer called Nearest Depth Upsampling. This works by comparing four depth values from downsampled low res depth buffer ...
5
votes
1answer
120 views

Tesselation sine distortion?

I am experimenting on a simple wave tessellation shader. I ported it from a working vertex shader. When my frequency is higher than 1, I get strange "saw-tooth" artifacting at peaks of the wave. Here ...
1
vote
1answer
263 views

How do you interpolate UV mapping coords in a quad tessellation evaluation shader?

Does anyone know who to interpolate UVs in a quad tessellation evaluation shader? I can interpolate the position easily like so : ...
6
votes
1answer
209 views

What happens to float values written to UNSIGNED_BYTE texture?

This is more a theoretical question. I'm wondering what happens when I write float values into an empty RGBA texture of type gl.UNSIGNED_BYTE in WebGL 1.0. ...
2
votes
0answers
91 views

GLSL broken access operator

I've been following a guide to learn OpenGL, and I'm now learning how to do post-processing. In particular, I'm trying to apply a blur to my rendering through the following kernel: $\frac{\begin{...
4
votes
2answers
280 views

Why do we multiply vertex from left side in vertex shader with matrices?

I have been learning OpenGL 3.3 and I saw this expression: gl_Position = projection * view * model * vertex I am confused because I read in some book that if the ...
1
vote
1answer
1k views

Dynamic Array in GLSL

Is it possible to have a dynamic array in a GLSL shader? For instance, what if I have something like this in my GLSL Shader: ...