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
0 votes
1 answer
96 views

Force int array to compact memory

I have following structure which i use as an uniform buffer object. ...
MrRabbit's user avatar
2 votes
0 answers
85 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
4 votes
1 answer
251 views

Operator associativity and 4x4 matrices - performance question

During vertex processing with 4x4 matrices, we might stack multiple transformations like projection, model-world, world-camera, etc. by doing something like this: $$v_{final} = T_N \cdot ... \cdot ...
wychmaster's user avatar
  • 1,233
1 vote
2 answers
198 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 ...
Lucas Morgan's user avatar
3 votes
1 answer
847 views

Shader that transforms a mercator projection to equirectangular?

I am new in the OpenGL - GLSL and trying to make a shader that taking a mercator projection texture as a source and converting it to an equirectangular projection texture. Sample input: (1024x1024) ...
Hamid Reza Mohammadi's user avatar
2 votes
1 answer
133 views

Creating glsl library

I have different functions for example normalmapping which I use all the time... Now I thought about making a small glsl library. My problem: I don't want to have all functions within the same "...
Thomas's user avatar
  • 1,136
1 vote
1 answer
511 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 ...
user avatar
1 vote
1 answer
630 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 ...
Lenny White's user avatar
0 votes
1 answer
464 views

What is wrong with my metallic 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 ...
zoran404's user avatar
  • 153
0 votes
0 answers
187 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 ...
JShorthouse's user avatar
1 vote
2 answers
898 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 ...
user3228706's user avatar
0 votes
1 answer
89 views

Wrong reflection

Here is a youtube video showing my problem: youtube.com/watch?v=y8J7VhS2pkM I think I'm either doing the texture lookup on the reflection texture wrong, or the reflection or view matrix is somehow ...
Martin Gerhardy's user avatar
1 vote
1 answer
188 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 ...
Anvaka's user avatar
  • 213
0 votes
1 answer
768 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 ...
SleepProgger's user avatar
0 votes
0 answers
158 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 ...
Bhavyansh Mishra's user avatar
2 votes
1 answer
119 views

Point light illuminating only half of a scene

A point light is illuminating only a half of a scene in my small 3D renderer. It happens on every scene I've tried (conference room, cornell box, etc). How do I go about debugging this? What could ...
Ohkomonkiainen's user avatar
0 votes
1 answer
471 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 ...
antaalt's user avatar
  • 11
3 votes
0 answers
198 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
1 vote
1 answer
668 views

Stumped on GLSL error C5041 (cannot located suitable resources to bind variable... possibly large array

I have an OpenGL based graphics engine coming along quite nicely, but I'm currently stumped on a problem that arose after adding a new vertex shader output array. The vertex shader is outputing the ...
MarvinWS's user avatar
2 votes
1 answer
233 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....
YardenJ2R's user avatar
1 vote
2 answers
71 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 ...
Yaniv Knoll's user avatar
2 votes
1 answer
1k 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 ...
Earlh21's user avatar
  • 21
2 votes
0 answers
304 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
0 votes
0 answers
258 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 ...
spraff's user avatar
  • 279
2 votes
1 answer
542 views

GLSL Compute Shader doesn't run for large inputs

The shader takes an SSBO of Photons that have a position, direction, wavelength and intensity and each thread is responsible for tracing exactly one photon through the grid, where at each grid cell ...
Jhonny007's user avatar
  • 179
1 vote
1 answer
110 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 ...
PixelArtDragon's user avatar
2 votes
0 answers
64 views

Communication between vertex shader executions

Look at this vertex shader: ...
Vladimir Nazarenko's user avatar
3 votes
1 answer
328 views

Strange dark spot when lighting in deferred rendering PBR shaders

It's probably something obvious but there seems to be a strange issue with lighting in my pipeline. I'm trying to keep everything in world space at the moment for simplicity but cannot figure out what'...
user1117065's user avatar
3 votes
1 answer
4k views

What do the OpenGL version strings from glxinfo actually mean?

Note: I wasn't 100% certain if this question belonged here or in Ask Ubuntu. I figured since it was about OpenGL programming I'd put it here, but if I should move it to Ask Ubuntu, please let me know. ...
RoboticForest's user avatar
2 votes
1 answer
269 views

Difference between isnan and comparison to self

In GLSL, what is the difference between isnan(x) and !(x == x)?
Tomas's user avatar
  • 41
1 vote
1 answer
533 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
2 votes
1 answer
1k views

Clarifying vulkan glsl std140

So I have a uniform block that looks something lile this { mat4; mat4[128]; uint[16] } The block should total up to 8320 bytes. After aligning by 256 bytes for nvidia, that brings the total ...
Temp4890's user avatar
1 vote
0 answers
355 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
2 votes
0 answers
81 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 ...
graphics_guy's user avatar
2 votes
1 answer
2k 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 ...
Daniel E's user avatar
0 votes
1 answer
527 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 ...
marcoresk's user avatar
  • 101
2 votes
1 answer
280 views

Alpha component in color buffer affects RGB components?

I'm looking for a way to make my surface semitransparent, and for now i ended up using this configuration: ...
The Dreams Wind's user avatar
0 votes
2 answers
133 views

Why is precalculating a distortion different from calculating it in the shader?

I have an application where I simulate a camera distortion. There are two ways to go about it: calculate the distortion per pixel in the shader or precalculate the distortion and store the distortion ...
Tare's user avatar
  • 1,541
4 votes
1 answer
2k views

How does GLSL code get “loaded” and “compiled”?

I just wanted to find out for sure how GLSL code gets loaded and compiled. Does the g++ compiler do it?
user9778's user avatar
  • 191
1 vote
1 answer
437 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. ...
SurpriseQuestion's user avatar
0 votes
1 answer
320 views

Using depth texture to mask local pixels

I have a scene with camera facing billboards drawn with depth write off so they appear on top of other objects. I would like to draw each sprite so that any obscured pixels are drawn with a very low ...
Snicklefritz's user avatar
0 votes
1 answer
732 views

GLSL Debugging Volumetric light

I'm implementing basic volumetric lighting using deferred shading (gbuffer + render to screen quad) and basic shadow mapping. So, I am sending the position texture and shadow map to a separate shader,...
Camilo's user avatar
  • 101
0 votes
1 answer
326 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 ...
kevinyu's user avatar
  • 493
1 vote
0 answers
133 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
940 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
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
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
4 votes
1 answer
632 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 ...
Tare's user avatar
  • 1,541
9 votes
1 answer
16k 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 ...
yuchen's user avatar
  • 455