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
0answers
25 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",...
1
vote
0answers
29 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 ...
0
votes
1answer
25 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
1answer
77 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 ...
1
vote
1answer
48 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 ...
0
votes
0answers
41 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 ...
0
votes
2answers
127 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
vote
1answer
26 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
0answers
25 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
vote
0answers
23 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 ...
0
votes
0answers
49 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 ...
0
votes
1answer
120 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
0answers
17 views

How to distribute compute shader invocations for drawing of many multi segment curves?

I'm trying to figure out how I should distribute the invocations of a glsl compute shader for drawing multiple curves composed of multiple interpolated segments. In this figure I show how I've ...
1
vote
0answers
28 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
2answers
234 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: ...
0
votes
1answer
181 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
2answers
150 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 ...
3
votes
0answers
262 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 ...
0
votes
0answers
145 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
1answer
173 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 ...
0
votes
1answer
89 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 ...
0
votes
0answers
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 ...
2
votes
0answers
41 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 ...
0
votes
0answers
23 views

Changing shader color

I have the following .fx file for my shader: ...
1
vote
0answers
51 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 ...
2
votes
1answer
143 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
2answers
239 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 ...
2
votes
0answers
167 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/...
1
vote
0answers
60 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 ...
2
votes
1answer
96 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 ...
1
vote
1answer
345 views

DXC error when compiling PSO

I am trying to compile some really simple shaders with DXC but, when creating PSO, I get: ...
0
votes
1answer
42 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 ...
2
votes
0answers
39 views

Per-object screen space uv issue

I am currently trying to sample a texture in screen space. This works well : ...
1
vote
2answers
102 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 ...
1
vote
1answer
96 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 ...
1
vote
1answer
43 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-...
3
votes
2answers
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 ...
2
votes
1answer
345 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 ...
1
vote
2answers
288 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 ...
1
vote
1answer
93 views

constant pixel width for any scale

I have a standard 3d camera/projection/model setup that renders rectangles with a WebGL shader. Users can zoom out and fly anywhere. I want to make sure that regardless of the scale, width of the ...
0
votes
1answer
226 views

Sending programs from CPU to GPU

How does a CPU know which piece of code should be executed on GPU (i.e how to recognize whether a code is shader or not) and how is it been sent to GPU VRAM?Is it via DMA?
0
votes
0answers
94 views

Problem with Quad-based Tessellation in GLSL generating incorrect vertex ordered tessellation

I am trying to perform quad-based tessellation using GLSL on Unity to be able to render polynomial-based parametric surfaces on a Unity quad. The quad-based tessellation using GLSL seems to be ...
0
votes
0answers
98 views

How to pack 3 floats into one?

I am doing some animation jobs. I need to pack some pivots into UV and then my shader can read them. I need to pack 4 float3 into a float4. Therefore, I need to pack each float3 into a float. ...
4
votes
1answer
150 views

Shader or formula that distorts inward

I am looking for a shader (or at least the right terminology) for crushing an image. It should be something very similar to barrel distortion, but instead of the center crushing outward to the edges, ...
1
vote
0answers
38 views

Optimizing texture fetches with higher mip levels

Let's say I have some shader program in DirectX or OpenGL rendering a full screen quad. And in a pixel/fragment shader I sample some huge textures at random texture coordinates. That is one same ...
1
vote
1answer
384 views

What is a 0 "null" normal map? Or Unlit shader

Does anyone understand normal maps and what would color a uniformly 0 normal map be? I'd like to convert a standard shader into an unlit shader, so (I think?) the idea is that the normal map should ...
1
vote
1answer
100 views

GLSL - increasing line spacing with y

I'm trying to force perspective into the horizon of a Shadertoy scene by drawing horizontal lines at decreasing distances as y grows to create an outrun-esque scene, but can't figure out which ...
1
vote
1answer
190 views

What are the type constants that the documentation for glGetProgramResourceiv() refers to?

Quoting the Khronos OpenGL documentation pages for the glGetProgramResourceiv() function: For the property GL_TYPE, a single integer identifying the type of an ...
1
vote
0answers
90 views

How to render multiple shaders per mesh

I've tried looking everywhere, but I just don't get it. How is multiple shaders assigned to a mesh if you can only bind a single shader in OpenGL? Assume I have a mesh with a texture shader and now I ...

1
2 3 4 5