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
2
votes
1answer
575 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 ...
2
votes
0answers
34 views

Per-object screen space uv issue

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

Show the edges between the clipping plane and clipped objects [closed]

I want to utilize shaders to not only discard fragments if they are on one side of a predefined plane but also render a contour along the intersection. My fragment shader currently does something ...
2
votes
0answers
253 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
77 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 ...
2
votes
0answers
147 views

If statements in shaders - implications and consequences [duplicate]

I've heard a lot that in shader development, you absolutely need to avoid branching and so if statements. But why? Does this have a real impact on performances on old and modern hardware or is it ...
1
vote
1answer
371 views

Why does substracting -1 in shader fail for a float data type?

I am loading a texture in a WebGL fragment shader (GLSL version 1.00). This is my working code: ...
1
vote
2answers
57 views

What's more optimal - sampling one channel at a time or all channels at once?

I'm going through and optimizing some of my glsl code for a project, and have come across a scenario several times that I am not sure how best to optimize. In summary - Is it faster to sample a ...
1
vote
1answer
132 views

How to compute normal in quartic Walton-Meek's Gregory patch in tessellation shader?

I am programing a tessellation shader in OpenGL which computes the quartic Walton-Meek's Gregory patch. I am searching for a local G1 method with good shading/visual results. So I am trying this patch....
1
vote
1answer
467 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 ...
1
vote
1answer
193 views

My (ADS) shader doesn't render the light direction correctly

This is what I'm doing: vertex shader: ...
1
vote
1answer
230 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
1answer
366 views

Am I passing the correct matrices for my shader? openGL/C++

On page 89 of David Wolff - OpenGL 4.0 Shading Language Cookbook book, it suggests a way to set up up a Phong shader in the fragment stage. It lists some different matrices to pass via uniform, and I ...
1
vote
1answer
31 views

draw on cubemap with help of geometry shader each triangle covers each cubemap face (why??)

I want to do some complicated stuff but have problems with my geometry shader / FBO bindings. To hold it as easy as possible I reduced the code to a minimum. If this works, I could continue the hard ...
1
vote
1answer
57 views

Does atomic functions on same memory location cause an performance issue?

is it worse to do for each invocation an atomicAdd on the same memory location than doing for each invocation an atomicAdd to a unique memory location? (I know, atomicAdd does not make sense when each ...
1
vote
1answer
66 views

OpenGL task/mesh shader extension NV_mesh_shader not behaving as I expected

I am trying to get up to speed with the NV_mesh_shader extension from NVidia (on my RTX2080). Samples are rare, so I tried to come up with my own small sample. I am rendering a sphere (20 triangles) ...
1
vote
1answer
221 views

Is it possible to access adjacent vertex data in tessellation evaluation shader?

I'm trying to render thick cubic Bezier curves using the whole OpenGL 4.5 pipeline: I render a patch with 4 control points. Vertex shader is simply pass-through to tessellation control shader. ...
1
vote
1answer
66 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
204 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
2answers
7k views

Send Texture to Shader

I've been following the LearnOpenGL tutorials and I've come across a piece of code I don't understand. ...
1
vote
1answer
555 views

What framework shoud I use to implement the RAISR upscaling algorithm on the GPU?

I recently ran across the paper RAISR: Rapid and Accurate Image Super Resolution and thought it seemed like an interesting technique for scaling up images. However, I haven't seen any implementation ...
1
vote
1answer
48 views

Passing mat4 array to GLSL succeeding but producing GL_INVALID_OPERATION

I'm currently passing an array of bone positions to GLSL for a skeletal animation shader; the positions are passing successfully but producing a GL_INVALID_OPERATION error. I'm passing the matrices ...
1
vote
1answer
38 views

Implicit conversion in glsl shaders

When specifying member values for a structure consisting of float values like vec3 or mat3, is it guaranteed that if an integer ...
1
vote
2answers
119 views

OpenGL Compute Shader Shared Maximum

I'm working on an OpenGL compute shader in which each work item results in a single number output I'll call x, as well as a struct output with more information, I'll call y. What I would like is a ...
1
vote
1answer
154 views

Retrieve real distance from depth buffer for shadow ray (vulkan hybrid rendering)

I'm trying to implement an hybrid renderer based on Vulkan extension VK_NV_ray_tracing. Basically, the rasterizer compute the albedo and depth map of the scene. Then I try to compute the distance from ...
1
vote
2answers
43 views

Help with wireframe artifacts on mesh procedural UV texturing

My goal in my project is to render a procedural texture for a given mesh based on a predefined camera projection. The way I choose to accomplish it is by creating tex coords based on only the visible ...
1
vote
1answer
331 views

Shader code for putting an atmosphere over a planet

I'm working on a game set in space with procedurally generated planets, and I'm trying to write a shader that puts an atmosphere over a planet given the color of the atmosphere and the strength of the ...
1
vote
1answer
61 views

Wrapping normals around a sphere

I'm using a vertex shader to effectively wrap vertices on a sphere. Starting with world_position already after multiplying the vertex by the model transform matrix ...
1
vote
1answer
75 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: ...
1
vote
1answer
246 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
1answer
678 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 : ...
1
vote
0answers
37 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
45 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
259 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
90 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
74 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
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
535 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
1answer
233 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 ...
1
vote
1answer
431 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
2answers
881 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 ...
1
vote
0answers
416 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
235 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
1answer
292 views

Convert shader from GLsl 1.50 to 1.30

I'm a newbie with OpenGl and I'm stuck in following the tutorial. I found this tutorial with these shaders ...
0
votes
1answer
38 views

Closest sphere on segment

I am trying to get a segment closest point on a surface and display a circle (or sphere in this case) at that position. I actually get the correct position but I can't get a uniform sphere based on ...