Questions tagged [shader]

For all questions related to shaders, i.e. the programmable part of the GPU pipeline. For language-specific shader questions, see also the [glsl] and [hlsl] tags.

Filter by
Sorted by
Tagged with
1 vote
1 answer
63 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 ...
1 vote
0 answers
12 views

How can I see the whole shader's text content, with all the prepended code by Three.js, when using ShaderMaterial or RawShaderMaterial (r148)?

I know that Three.js prepends the shader text you provide with some code that includes definitions etc. I am not a big fan of "magic" and I would like to be able to see the final text ...
0 votes
1 answer
54 views

Output to more than one canvas texture in processing with shader OpenGL

as the question suggests im looking to output to more than one canvas element in processing to speed up the calculations and limit shader draw calls. It has to be as simple as possible to be ...
0 votes
1 answer
53 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
54 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
33 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
1 vote
0 answers
71 views

What is the best way to display complex number "images"?

I may be getting some details wrong (e.g. colour space vs. colour model), so please bear with me: I want to represent "images" consisting of complex numbers i.e. for each "pixel" ...
1 vote
2 answers
106 views

Has general purpose GPU computing been used before compute shaders were available?

Today we have tools such as Nvidia's CUDA and OpenCL to perform general purpose computing on the GPU (GPGPU). Seeing that traditional shaders are specifically used for generating graphics by filling a ...
0 votes
0 answers
27 views

Understanding Virtual Texturing and Virtual Texturing Coordinates

So for a few weeks now i've been trying to get my head around implementing a virtual texturing system. Since i've got a mesh and a 32k texture that already has UV's i've been scratching my head how do ...
  • 1
0 votes
1 answer
46 views

How does swizzling works in ARB shaders?

I am trying to understand some shader code written in ARB. I am mostly using this to understand it. However the doc doesn't explain (or I missed it) how vector operands are transformed into scalars, ...
  • 141
0 votes
0 answers
62 views

Alternate projections in shader

I have a projection calculation which maps points from 3D space to pixel (image) space, and I want to use it as instead of the standard MVP projections in a vertex shader. In the image below the lower ...
  • 3
1 vote
1 answer
96 views

Rendering multiple camera transforms of the same geometry at once

Currently I have a basic (OpenGL 3.3) rendering scheme using a simple depth vertex shader to generate shadow maps for a scene. I don't care about having a large number of lights in the scene so it is ...
  • 111
0 votes
2 answers
150 views

Model matrix for batch renderer as uniform or vertex attribute?

Where should the model matrix be uploaded to the GPU in a batch renderer? All the tutorials I've ever seen use a uniform for this, but that's not with batch rendering. Since the uniform is only ...
  • 101
0 votes
0 answers
30 views

Cg - fixed data type

I noticed that Cg has data type fixed, which is: a 12bit fixed point number Does any hardware even support that? AFAIK most GPUs don't even support 16bit floats ...
  • 596
0 votes
0 answers
57 views

Calculating texture UVs on world origin shift

I am using procedural tiling terrains for very large worlds, and to avoid floating point errors I'm periodically shifting all parent objects back closer to zero. The Unity terrains textures are ...
2 votes
0 answers
49 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 ...
1 vote
1 answer
780 views

On modern GPUs, what hardware do vertex/pixel shaders have access to that compute shaders don't?

Suppose that someone implemented rendering for a video game using entirely GPGPU apis, like compute shaders or CUDA. Would it be possible to achieve the same performance as standard graphics pipelines ...
0 votes
1 answer
178 views

Unity - custom shadow from sun

due to some features in materials I need to create my own directional shadow map. Everything seems to work ok, until the moment where I compare depths. First I add camera component to directional ...
  • 596
0 votes
0 answers
116 views

OpenGL Compute Shader Vector Subtraction Not Working As Expected

all. I am currently working on a compute shader in GLSL intended to simulate visualizations of general relativity by ray tracing in the Schwarzchild spacetime geometry. I'm about halfway through ...
1 vote
1 answer
139 views

SSAO with reconstructed depths yields strip artifacts

I wrote an ssao algorithm with compute shaders and view-position-reconstruction from the depth buffer. It works great for objects near by but results in strip or banding artifacts for large planes ...
0 votes
2 answers
152 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
2 votes
1 answer
169 views

Painter's algorithm test 2 and test 3?

TEST #2: Surface S is completely behind the overlapping surface relative to the viewing position. S1 is completely behind/inside the overlapping surface S2 How to check these conditions? i) Set the ...
  • 191
2 votes
1 answer
219 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
70 views

How to interpolate between two MVP setups?

I am currently writing an AR experience. I have a Camera View Matrix, A Camera Perspective matrix and the Model Matrix of the content I display. The AR content should can be switched to "2D",...
user avatar
1 vote
0 answers
35 views

How khronos flame swing effect is done?

This demo: https://www.khronos.org/registry/webgl/sdk/demos/google/particles/ Contains multiple effects that can be done with WebGL. I've been able to recreate some of them, but for example I don't ...
  • 111
0 votes
1 answer
215 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 ...
1 vote
1 answer
91 views

Stripping unnecessary data from C++ data structures before sending to GPU

I've recently been working on a particle system in my renderer and I've encountered a situation where my particle class on the C++ side has data I need to maintain my particle on that end, but that I ...
  • 45
1 vote
1 answer
169 views

Mesh-Shader and layered rendering

In the usual pipeline (vertex, tessellation, geometry and fragment shaders) the geometry can be deformed and in the geometry shader it is possible to copy the generated and deformed geometry in order ...
  • 667
0 votes
2 answers
212 views

How to avoid curvature artifact in raytracer?

I have a pretty simple raytracer that is rendering some SDFs, but when my camera is close to the object I see curves: I am not entirely sure where they are coming from, as I am using nothing but ...
  • 1,564
1 vote
1 answer
45 views

Is fragment shader run on fragments that are outside of rasterized geometry?

In deferred rendering, I first write world position to G-Buffer, and then in shading part, I want to use that information to reproject in the previous frame and then write the final color. However, ...
0 votes
0 answers
43 views

Offsetting value in shader causes unexpected/wrong logic

Let me explain what I am doing. I am trying to reduce the memory footprint of a voxel based algorithm by storing the voxel data as a hash map in an SSBO, as opposed to a 3D image. I am visualizing the ...
  • 1,564
1 vote
0 answers
55 views

Passing variable through cbuffer vs. shader input in HLSL

Let's say I want to pass some kind of value to a pixel shader in HLSL. I can either make a cbuffer and pass the value directly to the pixel shader, or I can make a cbuffer in the vertex shader and ...
  • 115
0 votes
1 answer
570 views

gl_ClipDistance vs gl_CullDistance

Why are there very similar yet distinct arrays: gl_ClipDistance[] vs gl_CullDistance[]? What would be some use cases where the ...
0 votes
1 answer
385 views

Can I write histogram equalization, blurring, sharpening grayscale image etc.. as shader programs with openGL?

...
1 vote
0 answers
31 views

Questions about caculate the highlight direction from spherical harmonics functions

Recently I‘m working on a Precomputed GI Project I'm trying to use a technique called AHD, Amibent Highlight Direction, rendering my project; I use Unity and my target platform is Android. First: ...
0 votes
2 answers
715 views

Does Vulkan have the equivalent of OpenGL's separable shader program and pipeline?

If you have a shader pipeline in OpenGL that goes something like the following: ...
  • 131
0 votes
1 answer
900 views

What is the most efficient line algorithm using a shader program

I'm new to shaders and I have been experimenting with them in shadertoy. I'm trying to get a deeper understanding of the graphics pipeline and I want to implement some features using shaders. I want ...
1 vote
2 answers
532 views

Is there a way to compile part of a shader into a spirv?

I want to have separate files for common things for shaders precompiled into a spirv. For example PBR, I've got these functions and implementations for them ...
4 votes
0 answers
572 views

How to implement PCSS correctly?

I'm trying to implement PCSS in OpenGL/GLSL, but I have problems understanding the details especially the conversions between the coordinate spaces. The existing implementations are so different from ...
  • 41
0 votes
0 answers
360 views

Using multiple textures in a shader

Background: I am extracting the textures for a model with Assimp and sampling those textures in the fragment shader. I have multiple uniform sampler2D textureN ...
0 votes
1 answer
333 views

Screen Space anti aliasing?

I have the following challenge. I am given a black and white image with rasterized lines. Given this input, I want to extend the edges to cover more than one pixel and antialias the edges. My first ...
  • 1,564
0 votes
1 answer
103 views

Stylized math like rendering?

How can I render plots and graphics that mimic how mathematicians draw diagrams? For example Look at this shirt: The diagrams represent 2D and 3D shapes, however they have characteristics of human ...
  • 1,564
0 votes
0 answers
22 views

Rendering different array types in the same vertex/fragment shader?

I have a pretty basic widget rendering, largely based upon the learnopengl.com "hello triangle." I'm actually using a tristrip to create two triangles, forming a semi-opaque square over the ...
2 votes
0 answers
118 views

What is the best way to calculate the projected size of a point

In a particle simulation, I am rendering particles as "spheres" using GL_POINTS instead of a mesh for efficiency. With glEnable(GL_PROGRAM_POINT_SIZE) I ...
user avatar
0 votes
0 answers
33 views

Changing shader color

I have the following .fx file for my shader: ...
1 vote
0 answers
89 views

Blur calculation in shader with fixed CoC

I have just started learning how to use and create shaders in ThreeJS and, while going through some shaders in the example folder, I have come across a bokeh shader. Inside the shader, blur is ...
3 votes
1 answer
359 views

How do I efficiently calculate the distance to the edge of a shape?

I'm trying to implement something like an "inner glow". That is, I have an image which defines the shape of an object, and then I want to create overlay that is a gradient that goes from the ...
2 votes
2 answers
428 views

OpenGL - Recreate position in viewspace from depth values

Current state: I belive the reconstructed positions are correct. However, I still have the same problem as all the time. When I rotate around my single pointlight appears to be moving around also. I ...
  • 126
2 votes
0 answers
273 views

Corrupt values when writing and reading from the same RWTexture2D in HLSL/DirectX?

I'm playing around with DirectX 12 ray tracing, and I'm trying to read and write data to a 32-bit RGBA floating point RWTexture2DArray within a DirectX 12 HLSL shader. I'm getting weird corruption/...
  • 161
1 vote
0 answers
82 views

Conditionals and branching in shaders

This is a quite wide subject which implies a lot of topics such as the platform or the compiler, but I think that it could be useful for everyone to know more about this. A common mistake is to think ...
  • 1,219

1
2 3 4 5