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.

68 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
907 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
  • 161
5 votes
0 answers
351 views

Indexing gl_TessLevelOuter[] with gl_InvocationID on a tessellation control shader

I'm using hardware tessellation to render a terrain mesh with variable LOD. I have this snippet on my tessellation control shader: ...
MadEqua's user avatar
  • 238
5 votes
1 answer
2k 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 ...
Pavlo Muratov's user avatar
3 votes
0 answers
642 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
3 votes
0 answers
171 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
3 votes
0 answers
216 views

Projective Texture / Shadow Mapping -- Why is the perspective division performed in the fragment shader?

I've just worked my way through this OpenGL shadow mapping tutorial. While I understand the basic algorithm, one thing puzzles me: During the 2nd render pass all vertices are transformed into the clip ...
rapunzel's user avatar
3 votes
0 answers
350 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 ...
Makogan's user avatar
  • 1,726
2 votes
0 answers
93 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
0 answers
83 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
2 votes
0 answers
86 views

Per-object screen space uv issue

I am currently trying to sample a texture in screen space. This works well : ...
MaT's user avatar
  • 1,229
2 votes
0 answers
359 views

Calculate the distance between two 3d points in screen coordinates

Given the Point A with the coordinates gl_FragCoord.xy, I have to find the distance to the Center of the cube face to which it belongs in screen coordinates. ...
keepyourweb's user avatar
2 votes
0 answers
65 views

Communication between vertex shader executions

Look at this vertex shader: ...
Vladimir Nazarenko's user avatar
2 votes
0 answers
117 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{...
Daus's user avatar
  • 21
2 votes
0 answers
100 views

Artifacts (numerical errors?) in rasterisation renderer

This might be not laser precision question but this issue appeared a long time ago when first trying to render some scene with 3D models in rasterisation renderer and apply some lighting, ...
mdkdy's user avatar
  • 2,169
2 votes
0 answers
80 views

Implementation of the paper "unified texture management of arbitrary meshes"

I briefly read the paper and I think I got the basic idea of it. The paper doesn't really go into implementation details though so my question is mostly on that. In the paper, needed tiles are ...
Temp4890's user avatar
2 votes
0 answers
299 views

How to output a 32 floating value in a render buffer with fragment shader

I would like to downsample my depth buffer and my normals. For that, I take in input of my shader, the corresponding textures (depth, normal), and I write my new values in a multi render target. I ...
user3596305's user avatar
1 vote
0 answers
29 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
1 vote
0 answers
34 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,285
1 vote
0 answers
35 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
1 vote
0 answers
43 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
  • 183
1 vote
1 answer
145 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,566
1 vote
0 answers
159 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
0 answers
214 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
36 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
1 vote
0 answers
102 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 vote
0 answers
432 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: ...
sak's user avatar
  • 169
1 vote
0 answers
199 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
1 vote
0 answers
367 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
1 vote
0 answers
378 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
1 vote
0 answers
376 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
583 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 ...
チーズパン's user avatar
1 vote
0 answers
371 views

How to hide a part of a geometry dynamically using a shader in three.js

I have a very big geometry in three.js and I want to hide a section of that geometry along an axis (for example every vertex with a Z>N must be hidden). My idea is to create a custom shader in GLSL ...
Nicolò Monica's user avatar
1 vote
0 answers
87 views

Convey screenspace bounding box of rendering result

Imagine I render to an FBO some arbitrary geometry. Geometry can be rendered via single or multiple draw calls. For the sake of the question, assume I know nothing about geometry or transformation ...
lhog's user avatar
  • 19
1 vote
0 answers
135 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 ...
Kyy13's user avatar
  • 121
1 vote
0 answers
1k 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 ...
Abrar Borno's user avatar
1 vote
0 answers
541 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 ...
Makogan's user avatar
  • 1,726
1 vote
0 answers
145 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 ...
u1F98E's user avatar
  • 11
1 vote
0 answers
591 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 ...
mdkdy's user avatar
  • 2,169
1 vote
0 answers
327 views

Subdivision vertex normal interpolation

I'm using GLSL 4.0 to write a subdivision routine that divides the triangles on an object through a geometry shader. I'm not using barycentric co-ordinates but vector arithmetic to output the triangle ...
Nubcake's user avatar
  • 111
0 votes
0 answers
10 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
26 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,285
0 votes
0 answers
12 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,285
0 votes
0 answers
11 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
0 answers
52 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,285
0 votes
0 answers
44 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
42 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
0 votes
0 answers
39 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 ...
Sniggerfardimungus's user avatar
0 votes
0 answers
136 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 ...
Ethan's user avatar
  • 103
0 votes
1 answer
114 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
0 answers
41 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 ...
Thomas's user avatar
  • 1,285