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.

35 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
815 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 ...
4
votes
0answers
251 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: ...
3
votes
0answers
77 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 ...
3
votes
0answers
250 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 ...
3
votes
0answers
237 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 ...
2
votes
0answers
33 views

Per-object screen space uv issue

I am currently trying to sample a texture in screen space. This works well : ...
2
votes
0answers
63 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. ...
2
votes
0answers
48 views

Communication between vertex shader executions

Look at this vertex shader: ...
2
votes
0answers
252 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 ...
2
votes
0answers
102 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{...
2
votes
0answers
76 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, ...
2
votes
0answers
62 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 ...
1
vote
0answers
36 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 ...
1
vote
0answers
43 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/...
1
vote
1answer
256 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 ...
1
vote
0answers
87 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 ...
1
vote
0answers
73 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 ...
1
vote
1answer
540 views

How does a GLSL Sampler2D read a Vec2 UV coordinate to determine UV range

I am working with an atlas shader that steps through various sprite tiles within a single png atlas page to playback an animation with sampler2D. Looking at the shader code, I would expect to have to ...
1
vote
0answers
95 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
529 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 ...
1
vote
0answers
130 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
0answers
409 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 ...
1
vote
0answers
234 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 ...
0
votes
0answers
18 views

Open GL mapping/hash function on hexagon grid, translating from a cell ID to pixel location on 1d texture

I've spent the last three days trying to figure this out, my intuition about this space has been thrown out of the window. The problem is this: I have a hexagon grid making function that returns an id ...
0
votes
0answers
48 views

Why is my ray caster is running much faster as a fragment shader compared to a compute shader

I'm trying to write a simple ray caster in OpenGL with C++. Previously, I have been using the fragment shader of a quad that covers the entire screen to do all the ray calculations. Now, I want to do ...
0
votes
1answer
111 views

What is wrong with my metalic PBR shader?

I feel like my light conservation math isn't correct, but I am not sure which part is wrong. Is reflected light supposed to influence the diffuse light? Does metalness only affect the reflected ...
0
votes
0answers
41 views

Specifying Fragment Shader Colors per Fragment (Instead of per Vertex)

I am learning about fragment shaders and have seen how by setting the colours of each vertex a triangle can be coloured via interpolation. However what if we want to use our own function to manually ...
0
votes
0answers
75 views

(Desperately) Need help sending an array of floats from Unity C# to HLSL shaders

I am currently working on implementing parametric curve based dynamic tessellation using GLSL. I have scanned the entire internet and I cannot find even a single good example of a GLSL shader which ...
0
votes
1answer
56 views

constant pixel width for any scale

I have a standard 3d camera/projection/model setup that renders rectangles with a WebGL shader. Users can zoom out and fly anywhere. I want to make sure that regardless of the scale, width of the ...
0
votes
0answers
96 views

Shader sampler2D uniforms instead of attributes

In the godot game engine (using opengl) it is not possible to define custom shader attributes. A workaround is creating a sampler2D texture uniform instead and use vertexId (or in fact UV since ...
0
votes
0answers
36 views

Problem with Quad-based Tessellation in GLSL generating incorrect vertex ordered tessellation

I am trying to perform quad-based tessellation using GLSL on Unity to be able to render polynomial-based parametric surfaces on a Unity quad. The quad-based tessellation using GLSL seems to be ...
0
votes
0answers
33 views

What quad will fill the screen, which can be inverse-projection-view transformed to map to the near frustum plane?

I've been experimenting with raytracing using GLSL. I had success rendering a cube which encloses the object. Now I want to do a full-screen raytrace, and I want to construct a quad which covers the ...
0
votes
0answers
271 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
0answers
269 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 ...
-3
votes
1answer
359 views

Multiple shader passes to the same texture?

o7 I am unable to find an answer to my question, because apparently it's not well enough defined to separate itself from a similar one. So I have to ask here. My problem is quite simple. I have ...