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
0 answers
47 views

Having trouble rendering entire sphere

I'm working on a program to draw a sphere. The method I'm using is creating an octahedron And using tessellation shaders to subdivide it into a sphere, however there is a patch of the sphere that is ...
0 votes
1 answer
44 views

want bokeh blur with custom shapes

I have a 2d texture and a shape matte, the matte could be any shape, like a star, heart, and so on, and I want to use this matte to generate different-shaped bokeh blur, how can I do it? and normally, ...
0 votes
0 answers
24 views

Opengl binding different mipmap levels of same texture2darray for use in compute shader. How to handle variable nr of levels?

So I want to make a compute shader that uses a coarse-to-fine approach. As I have learned about open gl mipmap levels it seems they could be very useful. However the only binding method which I have ...
1 vote
1 answer
70 views

How can I test my GLSL code on different hardware?

I've written a game engine in OpenGL and developed it on my computer with an NVidia GTX 1060. I'm now ready to start releasing it into the wild but I'm worried about hardware issues. I compile my ...
  • 57
0 votes
0 answers
64 views

Bottle neck in fragment shader because large number of texture2D call

Are there any way to optimize this flow: The frame captured from camera (NV21 byte array) Convert this frame to I420 format Upload Y data to y_tex; U data to ...
  • 1
0 votes
1 answer
38 views

Splitting Floats To Texture Channels

I know, this is a silly question, but since I need this so often, I just want to double check that I made no mistake. Working with most shader languages, a texture can store $8$ bits per channels, ...
  • 127
1 vote
1 answer
48 views

GLSL trying to bind two different layers from the same texture array as images. Should it work and if so what am I doing wrong?

I am new at this particular site in the SE ecosystem, but not to computer graphics in general. If I'm in the wrong spot feel free to redirect me. My question regards glsl programming and binding two ...
0 votes
2 answers
53 views

Porting from DXR/HLSL to Vulkan Ray Tracing Extension/GLSL

I am working on the port of a demo from DXR to Vulkan Ray Tracing extension using GLSL. In DXR/HLSL space, there are RayTMin() and RayTCurrent() functions to retrieve the starting and the current end ...
1 vote
1 answer
75 views

Best way for rendering Voronoi diagram from Delaunay graph mesh

I have a set of points, which I triangulate to a Delaunay graph to make a mesh. Every mesh vertex has a unique colour, and I can render it without any problem. But I want Voronoi rendering to be ...
0 votes
1 answer
25 views

Why shouldn't I discard faces during Tessellation control stage

In the discussion Here there was said, that discarding faces during Tessellation stage should be avoided. What are the reasons for that? Right now, I am rendering a 3D geometry using Vertex, ...
  • 643
2 votes
2 answers
64 views

Why does GLSL smoothstep return 0 when all parameters are literal floats?

I was working through https://thebookofshaders.com/05/ when I came across some unintuitive behaviour of smoothstep. I wanted to understand it better so I replaced ...
  • 73
0 votes
1 answer
115 views

combinatoric explosion of sampler2D, sampler2DArray, samplerCube

I use uber-shader approach and am having issues fitting within 16 texture units. My material uses 3 textures: albedo, special, and normal map. However, any of these textures can be regular 2D, or 2D ...
  • 41
0 votes
0 answers
63 views

My n-body simulation doesn't form a galaxy

I'm trying to create a galaxy simulation using opengl with the compute shader and when I start my simulation, the galaxy with the spiral arms doesn't form, instead it goes into chaos. I noticed that ...
0 votes
1 answer
55 views

Is there a good rule of thumb for the optimal / maximum number of instances to draw in a single call?

So let's say I want to draw a lot of textured quads to the framebuffer. In each shader invocation, I will bind an array of indicies, an array of positions, and an array of textures to index into. ...
  • 159
0 votes
0 answers
76 views

What are the main concepts behind building the plasma effect with GSLS?

By the plasma effect I mean an animation that looks like this: I have seen some codes, like these https://www.shadertoy.com/view/Xst3zN https://www.shadertoy.com/view/4tdGWX and messed with the code ...
  • 21
1 vote
0 answers
34 views

How to make elevated parts of a steep plane seem darker than the lower surface? [GLSL]

I made a plane in THREEjs using Mesh, PlaneGeometry and ShaderMaterial. It's a very simple/basic form. I applied a simple phormula to make the plain more steep. Now I'm trying to make the lower ...
  • 111
0 votes
1 answer
137 views

OpenGL compute shader workgroup synconization

I am calculating the Summed Area Table(SAT) of a texture with help of a compute shader in OpenGL. The texture which needs to be summed, has a dimension size of more than my GPU supports (...
  • 643
0 votes
0 answers
51 views

Screen space to texture space transformation

I've built a deferred renderer that is able to do deferred decals, now I want to be able to bake that into textures. I have a texture (so screen space) that holds a deferred screen space decal that ...
0 votes
0 answers
176 views

GLSL normalized texture coordinate to pixel coordinate

I've a texture (2048 x 2048) Pixels. I am looking for an algorithm to transform the normalized texture coordinate [0 1] to pixel coordinate [0 2047]. This should be a perfect fit... So when the ...
  • 643
1 vote
0 answers
46 views

Is it possible to reduce aliasing in derivatives used to estimate normals from a texture?

I am generating a normal map for a texture for use in a PBR shader. I have a map for the diffuse texture, and I am estimating the normal at each point using the derivative of the texture's brightness....
  • 111
0 votes
0 answers
77 views

Cook-Torrance brdf with direct light sampling got strange result

I'm trying to implement the Cook-Torrance BRDF model in progressive MC ray tracing in glsl shader, I followed the tutorial on this blog, and use the method mentioned to importance sample the normal ...
  • 11
0 votes
0 answers
32 views

How do I make "attribute vec0.5" in GLSL. Sorry if it confuses

Is it possible, in OpenGL (specifically in WebGL), to use a single value from buffer for multiple shader iterations? Like to put the same element from buffer into shader attribute multiple times? Like:...
0 votes
1 answer
125 views

How is mipmap level used mathemetically in image sampling?

I am trying to simulate the behavior of "texelFetch()" and so far I've understood the following: If "gvec4 texelFetch(gsampler3D sampler, ivec3 P, int lod)" is given then : result =...
0 votes
0 answers
41 views

void main{vec4 rgba;} wont work on OpenGL

I´m very newbie in OpenGL and I'm trying to tweak a triangle example on Android. I got this ...
  • 101
4 votes
1 answer
166 views

Artifacts while rendering sponza scene

I'm trying to render the Sponza scene using the Cook-Torrance BRDF Model Plugged with the GGX Normal Distribution, Gemoetry Schlick and fresnel Schlick approximation and a punctual point light. When ...
1 vote
1 answer
363 views

Why must texture samplers be uniform variables in GLSL?

To use a texture in an OpenGL shader, I have to write the Texture Unit to be used into a uniform variable: source.c: ...
  • 13
1 vote
0 answers
182 views

Problem when passing a readonly image2D to a function

I would like to declare a function which reads from an image2D and modifies the output. My shader is written like so: ...
  • 159
1 vote
1 answer
299 views

Is there a cost to querying a texture size inside a GLSL shader?

So I need to have a texture size for my compute shader. I found this function in GLSL to query this inside the shader: ivec2 textureSize = imageSize(outputImage) ...
  • 159
0 votes
0 answers
39 views

Getting something close to the convex full of SDFs using CSG operations

Inigo Quilez has an explanation of smooth operations to join sdfs. I am trying to get something close to the convex hull of multiple sdfs. For starters let;s consider a simple case of 3 cubes int eh ...
  • 1,594
1 vote
1 answer
146 views

Having trouble understanding advection from GPU gems fluid dynamics example

So I am trying to implement a fluid simulation, as described in Chapter 38 of GPU Gems. I am also drawing heavily from the excellent implementation by Pavel. Where I'm getting a bit stuck is with ...
  • 159
0 votes
1 answer
117 views

Bump mapping WITH precomputed tangents?

Most bump mapping (meaning black and white height map) uses Tangents/Bitangents computed from Position using dFdx/y. And they also compute the offsets/derivatives of the height map using dFdx/y. The ...
  • 51
0 votes
0 answers
244 views

GLSL texture() vs textureLOD causing odd texture filtering

I've got a fragment shader sampling an environment texture for world reflections, and in testing, there seems to be a major difference in the result for texture() ...
1 vote
1 answer
91 views

Defining the proper sdf for this structure

I am making a procedural sdf (just a bunch of cubes) based of an image. The idea is very simple. We have a stencil image: Each texel in the image corresponds to a 3D cube. So to ray trace what I am ...
  • 1,594
2 votes
0 answers
52 views

GLSL, Fragment Shader: How to separate functions (like noise, transform...) to reuse in different projects

I'm a total newbie to coding and recently got interested into generative art. This is my problem: I have to copy all of the functions I need (and there are a lot) in every single fragment file I'm ...
2 votes
1 answer
59 views

using parts of GL_TEXTURE_2D_ARRAY as GL_TEXTURE_CUBEMAP_ARRAY

I am using layered rendering for all my light sources to avoid rendering multiple times. I have lightSourceCount many point lights and one sun, which is implemented ...
  • 643
-1 votes
1 answer
185 views

How to deform an object in glsl? (processing)

I am a beginner in glsl and processing. I have a cube, can I know how to deform it using mathematical or progammatical functions? ...
2 votes
1 answer
92 views

enable / disable transform feedback within glsl for specific primitives

I am using the tessellation shader stage to increase the density of triangles close to camera. Thereby when the camera is too close to a triangle, so that the maximum tessellation is not high enough, ...
  • 643
1 vote
1 answer
997 views

Opengl GLSL binding locations confusion

The background of this question is that I am trying to write an automatic binding system, where for each uniform variable I want to declare in my GLSL code, I call a method ...
  • 643
0 votes
0 answers
73 views

Precision problems when rendering whole planets

I'm trying to implement a camera, which is able to go very close to a planet/moon surface, without flickering surface. The problem: Right now the position of a planet / moon is saved at the center of ...
  • 643
1 vote
1 answer
167 views

Convert image to CIE Lab using GLSL to change hue/chroma

It is possible to convert an image or other output to CIE Lab color model using GLSL? Does it require compute shaders or can be done using only vertex shaders?
0 votes
0 answers
130 views

Achieving bokeh blur with custom shapes

I have a 2D texture, without any depth maps, which I'd like to blur to achieve a bokeh effect. The catch, however, is that I want the effect to be custom bitmaps/shapes (e.g. a heart). Here's a part ...
0 votes
2 answers
170 views

Ambient occlusion depth buffer normalization

Been trying to follow a shader from A Comparative Study of Screen-Space Ambient Occlusion Methods http://frederikaalund.com/wp-content/uploads/2013/05/A-Comparative-Study-of-Screen-Space-Ambient-...
  • 3
0 votes
2 answers
108 views

Tiling in GLSL creates unwanted seams

I'm writing a shader that creates a grid with coloured tiles. The color is derived from a pixel at that location on a texture. But around the tiles I get these unwanted seams. I can't seem to figure ...
  • 103
2 votes
1 answer
239 views

Having trouble implementing distance transform with jump flood

I'm attempting to use the jump flood algorithm to compute distance transforms of an arbitrary texture derived from a canvas2d context, roughly following the explanations detailed here/here. In the ...
  • 23
0 votes
0 answers
46 views

Obtaining sample position z value when using positions from depth buffer for SSAO

I was looking to implement SSAO; demonstrated on learnopeng (https://learnopengl.com/Advanced-Lighting/SSAO). While I have implemented the way they have done it i.e using a position texture for ...
2 votes
1 answer
161 views

Is there a better, more elegant way of translating/rotating my camera in my 3d raymarched world or am I stuck with trigonometry?

What I am trying to achieve So I'm a fractal enthusiast and decided to build a 2D/3D fractal generator in WebGL using raymarching, with Typescript as scripting language. I've been a C#/Typescript dev ...
0 votes
1 answer
1k views

How to render fog in OpenGL

I have a simple question just because I can’t find any good example in the internet. How to create fog without using particles? How to make for with different density on different locations and in ...
  • 103
0 votes
1 answer
255 views

Dynamic Loop Based on Uniform

My question is fairly simple but I guess it contains two questions, one is how to arrive at an answer (imagine a similar one and you want to deduce it using existing tools like a GLSL compiler or the ...
3 votes
1 answer
484 views

Compute Shader shared average value

Short Question: How can i integrate a buffer variable in a compute shader over each pixel i.e. how can i ensure memory coherence in such a case? Long Question: I've written a deferred renderer with ...
0 votes
2 answers
332 views

glsl passing data array from vertex to tessellation control shader

I am trying to pass a vec3 array from vertex shader to tessellation shader. passing just one value works fine, but how to pass an array? Vertex shader ...
  • 643

1
2 3 4 5