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.

61 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
779 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
  • 151
5 votes
0 answers
343 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
554 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
160 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
197 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
329 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,696
2 votes
0 answers
77 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
82 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
84 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,219
2 votes
0 answers
303 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
64 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
96 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,119
2 votes
0 answers
77 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
287 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
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) + ...
Doobius's user avatar
  • 111
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 ...
Simon's user avatar
  • 163
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, ...
Tare's user avatar
  • 1,541
1 vote
1 answer
57 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
100 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
150 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
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 ...
Jonas's user avatar
  • 111
1 vote
0 answers
79 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
325 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
  • 159
1 vote
0 answers
174 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
303 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
329 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
320 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
531 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
351 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
82 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
132 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
938 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
515 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,696
1 vote
0 answers
144 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
541 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,119
1 vote
0 answers
320 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
19 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
63 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
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 ...
h4ckthepl4net's user avatar
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 ...
Thomas's user avatar
  • 1,136
0 votes
0 answers
200 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
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 ...
idchlife's user avatar
  • 373
0 votes
0 answers
50 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 ...
zenzicubic's user avatar
0 votes
1 answer
139 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
0 votes
0 answers
49 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 ...
mathreadler's user avatar
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 ...
Viète's user avatar
  • 1
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 ...
Sedenion's user avatar
0 votes
0 answers
448 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,136