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
4 votes
1 answer
2k 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 ...
Krupip's user avatar
  • 280
1 vote
1 answer
785 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 ...
remi000's user avatar
  • 240
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
4 answers
495 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 ...
Pavlo Muratov's user avatar
3 votes
1 answer
3k 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,...
Tare's user avatar
  • 1,541
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
1 answer
108 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 ...
Hedede's user avatar
  • 113
1 vote
1 answer
481 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 ...
HappyR's user avatar
  • 13
9 votes
2 answers
8k 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 ...
Seyed Morteza Kamali's user avatar
4 votes
1 answer
1k 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:...
Seyed Morteza Kamali's user avatar
2 votes
1 answer
412 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 ...
barneypitt's user avatar
0 votes
1 answer
296 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 ...
spraff's user avatar
  • 279
1 vote
1 answer
751 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. ...
MaT's user avatar
  • 1,219
1 vote
1 answer
460 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 ...
MaT's user avatar
  • 1,219
1 vote
2 answers
2k 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 ...
Startec's user avatar
  • 781
6 votes
1 answer
6k 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. ...
shashack's user avatar
  • 523
-1 votes
1 answer
322 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) ...
shashack's user avatar
  • 523
2 votes
1 answer
606 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 ...
Daniel Marques's user avatar
3 votes
2 answers
504 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 ...
Seyed Morteza Kamali's user avatar
3 votes
2 answers
3k views

Getting rid of branching to check if a variable is within a range in GLSL

I have this GLSL function that I am trying to optimize because it is going to be ran on many pixels of an older devices GPU. There is no room for branching inefficiency. Essentially this function ...
J.Doe's user avatar
  • 1,445
7 votes
1 answer
2k views

Ray tracing - partial derivatives for texture lookup

I'm doing some ray tracing on GPU using a fragment shader... How can I calculate texture coordinates partial derivatives with respect to screen coordinates so I could perform filtered texture lookup ...
zduny's user avatar
  • 377
3 votes
1 answer
1k views

Shader storage buffer indexing by 4 bytes instead of 3?

I am trying to send rendering information for an instancing rendering using shader buffer objects. My current problem is that I have 2 shader buffer objects, one which works just fine, and another ...
Makogan's user avatar
  • 1,696
1 vote
1 answer
185 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: ...
Startec's user avatar
  • 781
4 votes
1 answer
437 views

How to prevent moire artifacts in this light casting algorithm?

I am writing a 2D light casting algorithm with OpenGL compute shaders. The algorithm is simple: For each light source shoot out light rays from it, the ray begins at the light coordinates, it ends at ...
sydd's user avatar
  • 253
3 votes
1 answer
2k 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 ...
Makogan's user avatar
  • 1,696
27 votes
2 answers
41k 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: ...
idchlife's user avatar
  • 373
2 votes
1 answer
282 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. ...
carlr's user avatar
  • 21
1 vote
1 answer
439 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 ...
scx's user avatar
  • 169
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
4 votes
1 answer
356 views

Tesselation sine distortion?

I am experimenting on a simple wave tessellation shader. I ported it from a working vertex shader. When my frequency is higher than 1, I get strange "saw-tooth" artifacting at peaks of the wave. Here ...
scx's user avatar
  • 169
0 votes
1 answer
1k 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 : ...
scx's user avatar
  • 169
5 votes
1 answer
2k views

What happens to float values written to UNSIGNED_BYTE texture?

This is more a theoretical question. I'm wondering what happens when I write float values into an empty RGBA texture of type gl.UNSIGNED_BYTE in WebGL 1.0. ...
Muad's user avatar
  • 165
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
3 votes
2 answers
2k views

Why do we multiply vertex from left side in vertex shader with matrices?

I have been learning OpenGL 3.3 and I saw this expression: gl_Position = projection * view * model * vertex I am confused because I read in some book that if the ...
Ankit singh kushwah's user avatar
12 votes
3 answers
16k views

Dynamic Array in GLSL

Is it possible to have a dynamic array in a GLSL shader? For instance, what if I have something like this in my GLSL Shader: ...
Archmede's user avatar
  • 471
2 votes
1 answer
209 views

How can deal with batch rendering when the elements in the batch changed every frame?

Since I am using batch rendering, so I should pack every render units can be batched into one big VBO. But, what if I am in a case where render units are dynamically changed, some new units are added ...
Francis's user avatar
  • 165
3 votes
1 answer
476 views

Screen Space Ambient Occlusion Issues

I'm having problems with Ambient Occlusion. I've tried to follow both John Chapman's improvements over the Crytek AO and LearnOpenGL's tutorial of it when I failed to properly obtain the correct ...
Karim Abdel Hamid's user avatar
3 votes
1 answer
763 views

GLSL function parameters

In GLSL: Common Mistakes it states: Functions parameters must be declared with the in, out, or ...
Archmede's user avatar
  • 471
14 votes
1 answer
1k views

Confused with PBR implementations

I'm discovering the wonderful world of math and I'm hitting a huge wall with PBR and naming so I have a few questions: As far as I understand BRDF describe how a material react to light (incoming ...
newin's user avatar
  • 363
-3 votes
1 answer
436 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 ...
z0rberg's's user avatar
  • 113
3 votes
1 answer
1k views

Phong shading in OpenGL: line of light from the center of the world

I implemented a Phong shader in GLSL, but there is a bug. What you are (supposed) to see down below: A point light source rotating around the center of the world, with a radiance of (0, 100, 0) A ...
Tudvari's user avatar
  • 313
3 votes
2 answers
14k 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. ...
Archmede's user avatar
  • 471
4 votes
2 answers
256 views

Strange behaviour in vertex shader with divisions

This is the vertex shader code: ...
Adrian's user avatar
  • 657
4 votes
1 answer
445 views

Special Texture Stretching without deformation

I am trying to achieve a special texture stretching effect in my shader. Here is how I define my uv before sampling my texture, nothing really special. ...
MaT's user avatar
  • 1,219
3 votes
1 answer
130 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 ...
Charlie's user avatar
  • 203
2 votes
1 answer
375 views

Easing curves on the GPU?

I was thinking that I could pass a timestamp in (from requestAnimationFrame) to the vert shader, and just have my easing curves in the GPU instead of using (for example) Tween.js from the outside. Is ...
trusktr's user avatar
  • 255
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
1 vote
1 answer
236 views

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

This is what I'm doing: vertex shader: ...
Charlie's user avatar
  • 203
1 vote
1 answer
498 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 ...
Charlie's user avatar
  • 203