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
0 votes
1 answer
5 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 ...
user avatar
  • 101
0 votes
0 answers
7 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 ...
user avatar
  • 556
0 votes
0 answers
20 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 ...
user avatar
1 vote
0 answers
20 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 ...
user avatar
2 votes
1 answer
681 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 ...
user avatar
0 votes
1 answer
21 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 ...
user avatar
  • 556
0 votes
0 answers
48 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 ...
user avatar
1 vote
1 answer
60 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 ...
user avatar
0 votes
2 answers
93 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-...
user avatar
  • 3
1 vote
1 answer
94 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 ...
user avatar
3 votes
1 answer
140 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 ...
user avatar
  • 33
0 votes
0 answers
38 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
34 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 ...
user avatar
  • 111
0 votes
1 answer
61 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 ...
user avatar
1 vote
1 answer
86 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 ...
user avatar
  • 45
1 vote
1 answer
105 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 ...
user avatar
  • 519
0 votes
0 answers
117 views

Blending 2 or more Textures based on depth (Unity)

Ive been trying my hand at blending between 2 or more textures, so far I found I can lerp between Colors quite easily, but this lacks the detail im looking for. So Im trying to blend 2 or 4 textures ...
user avatar
0 votes
2 answers
152 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 ...
user avatar
  • 1,447
1 vote
1 answer
32 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, ...
user avatar
0 votes
0 answers
34 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 ...
user avatar
  • 1,447
1 vote
0 answers
32 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 ...
user avatar
  • 125
0 votes
0 answers
94 views

What are Gbuffers?

Good Morning! I am in need of help to understand GBuffers. What exactly are they? and how can I access them through unity? Is it something I need to create? Or does the engine create automatically? In ...
user avatar
0 votes
1 answer
282 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 ...
user avatar
0 votes
1 answer
266 views

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

...
user avatar
1 vote
0 answers
30 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: ...
user avatar
0 votes
2 answers
450 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: ...
user avatar
  • 131
0 votes
1 answer
445 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 ...
user avatar
1 vote
2 answers
292 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 ...
user avatar
3 votes
0 answers
370 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 ...
user avatar
  • 31
0 votes
0 answers
180 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 ...
user avatar
0 votes
1 answer
241 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 ...
user avatar
  • 1,447
0 votes
1 answer
95 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 ...
user avatar
  • 1,447
0 votes
0 answers
18 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 ...
user avatar
2 votes
0 answers
64 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
26 views

Changing shader color

I have the following .fx file for my shader: ...
user avatar
1 vote
0 answers
64 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 ...
user avatar
2 votes
1 answer
238 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 ...
user avatar
2 votes
2 answers
304 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 ...
user avatar
  • 126
2 votes
0 answers
199 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/...
user avatar
  • 61
1 vote
0 answers
63 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 ...
user avatar
  • 1,169
2 votes
1 answer
115 views

Rendering moist/wet materials like human anatomies for surgical simulators

Real human anatomies look wet/ moist when operated. I am looking for some good methods for rendering anatomies in a virtual simulation, and hence I have done a literature survey on 'Rendering wet ...
user avatar
1 vote
1 answer
519 views

DXC error when compiling PSO

I am trying to compile some really simple shaders with DXC but, when creating PSO, I get: ...
user avatar
  • 556
0 votes
1 answer
56 views

Closest sphere on segment

I am trying to get a segment closest point on a surface and display a circle (or sphere in this case) at that position. I actually get the correct position but I can't get a uniform sphere based on ...
user avatar
  • 1,169
2 votes
0 answers
46 views

Per-object screen space uv issue

I am currently trying to sample a texture in screen space. This works well : ...
user avatar
  • 1,169
1 vote
2 answers
124 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 ...
user avatar
1 vote
1 answer
111 views

Help me understand the voronoi shader

I am trying to understand the voronoi shader implemented in the Book of Shaders in the Tiling and iteration section: https://thebookofshaders.com/12/ Specifically how do these lines calculate the ...
user avatar
  • 113
1 vote
1 answer
64 views

Do we have OpenGL shaders write out the intermediate *.o-esque file on first compile so that we can skip compiling them in run-time every single time?

Shaders get compiled during runtime every single time an app starts. I understand the reasoning for this is that there are so many GPU architectures out there that it does not make sense to ship pre-...
user avatar
  • 113
3 votes
2 answers
65 views

Coloring arbitrary closed regions

I'm trying to implement the following paper in modern OpenGL http://web.media.mit.edu/~lieber/Publications/Coloring-Book.pdf The issue is that the algorithm described requires you to consider ...
user avatar
  • 33
2 votes
1 answer
721 views

SDF rendering for large world

There are lots of cool things you can do with SDFs to render implicit surfaces. Most of the examples I've seen have been “all in the shader”, where the entire distance function is encoded in the ...
user avatar
  • 123
1 vote
2 answers
440 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 ...
user avatar

1
2 3 4 5