Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
10 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
44 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 ...
2
votes
1answer
47 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 ...
1
vote
0answers
58 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 ...
2
votes
0answers
50 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 ...
5
votes
1answer
6k views

GLSL. Can someone explain why gl_FragCoord.xy / screenSize is performed and for what reason?

I'm new to shaders and know that you can color pixels with gl_FragColor but sometimes there is this thing: ...
1
vote
1answer
44 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 ...
0
votes
1answer
67 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 ...
5
votes
1answer
627 views

GLSL - Merge two textures

I would like to display arbitrary 3d meshes with black edges (black outline, black ridges, etc.). Thereby I have created two different textures: One color texture and one anti-aliased edge texture. ...
2
votes
1answer
44 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: ...
0
votes
2answers
52 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 ...
4
votes
1answer
123 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?
0
votes
1answer
162 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,...
1
vote
1answer
82 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. ...
8
votes
2answers
580 views

What is a good approach for handling uniforms in modern OpenGL?

I'm creating a renderer using modern OpenGL (3.1 and up) and now I'm trying to create an efficient but flexible way of handling uniforms. I've been reading up on uniform buffer objects and on what a '...
1
vote
1answer
80 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 ...
1
vote
0answers
141 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
1answer
123 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 ...
4
votes
1answer
296 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 ...
3
votes
1answer
320 views

Combine material coefficients and textures in Phong Shading

I'm trying to implement a simple Phong shader that supports non-physically-based materials and textures. Even though the material has a texture for each light component I still want the respective ...
5
votes
2answers
1k views

How can I convert signed distance field to a mesh?

I can easily make models by Modeling with Distance Functions but I need make mesh from It so I decide to use voxelizing and make triangles for my signed distance field torus like this video.but I ...
1
vote
0answers
61 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
335 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 ...
3
votes
0answers
197 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 ...
0
votes
0answers
108 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 ...
4
votes
1answer
511 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 ...
1
vote
1answer
1k 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 ...
3
votes
4answers
169 views

How to access several textures from huge amount of textures in a shader?

I'm developing a light probe based GI solution and currently dealing with light leaks due to interpolation between probes located on opposite sides of the walls. I want to tackle the problem by ...
3
votes
1answer
240 views

How to align Ray Marching on top of traditional 3D rasterization?

I'm trying to apply raymarching on top of 3D rasterization, ordering what 3D object gets displayed based on the depth of a rasterization pass and the raymarch depth. After getting the transform ...
1
vote
1answer
210 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
160 views
2
votes
2answers
184 views

How to generate chaotic halftone pattern?

I'm trying to generate a random halftone like below image: this is a simple halftone that I tried, but I need a random halftone ...
3
votes
1answer
381 views

How to get assembly code from GLSL Shader

I am new to optimizing shader code. Now that I have written an "optimzation", I want to make sure that it really speeds things up and is not just an unreadable version of what I intend to do. For this,...
1
vote
0answers
67 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
46 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
122 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 ...
3
votes
1answer
105 views

How can I implement GIMP's “Colorize” function?

I have an RGB pixel that I'd like to colorize in my program (I'm using GLSL) very similar to how the GIMP "Colors > Colorize" function works. In my program, I can easily convert between RGB and HSV. ...
4
votes
1answer
110 views

NormalMap problems: bumps work, but shade does not

I've been trying to figure this out for a few days now, but I just can't get it right. I've read multiple tutorials and possible explanations, I even watched a java tutorial without finding the ...
4
votes
1answer
210 views

I dont understand how a GPU computes and branches, could you please help me fix this shader preformance

I have been working on how the GPU does parellel processing, and branching. However I am not yet to the point where I know how to make this shader more efficent. Essentially I dont know enough about ...
37
votes
6answers
19k views

How can I debug GLSL shaders?

When writing non-trivial shaders (just as when writing any other piece of non-trivial code), people make mistakes.[citation needed] However, I can't just debug it like any other code - you can't just ...
3
votes
1answer
227 views

GLSL shapes signed distance field implementation explanation?

I'm trying to understand all primitives In this article.After hard work I just learn Sphere and Cube , I wrote description here. I could draw 2D shapes but I have trouble understanding 3D below codes:...
3
votes
1answer
264 views

Bug: Overly Sharp Highlights in PBR

I'm still working on my BRDF equations. Theoretically, all equations are correct, but the hilights are super sharp. I'm not sure if this is a result of me not using Image-Based Lighting (I currently ...
4
votes
1answer
178 views

Is sub-texel shading possible?

I suspect the answer is no, but thought I'd ask anyway. It seems that other than using nearest neighbour and bilinear interpolations, there is nothing you can do to determine how two adjacent pixels ...
4
votes
1answer
829 views

How to dynamically calculate texture coordinates in a vertex shader with OpenGL?

I modified my code, and tried to pass a set of integers specifying the face of a cube (top, bottom left...) to the vertex shader in order to draw multiple instances of a cube face. I did this by ...
1
vote
1answer
131 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
1answer
234 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
1answer
128 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
2answers
347 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 ...
6
votes
1answer
2k views

Double precision in shader

for better accuracy, instead of GLfloat, I bound double data and tried to use the data in shader as follow: (I just tested to draw single triangle.) cpp. ...
-1
votes
1answer
93 views

How to modify a part of VBO data without Compute Shader or OpenCL?

After binding the data to the vertex buffer object as follows, how to modify the buffer data? (Each subdata size is 3$*$ data size (three elements per index) ...