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
1answer
39 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
168 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 ...
0
votes
0answers
37 views

GLSL asymmetric performance for point cloud

I'm currently using OpenTK (OpenGL binding for C#) to draw a lot of points (~17 million) - that very rarely change - in a cube (256 x 256 x 256) with different float "transparency weights". ...
2
votes
0answers
97 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
52 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
58 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
82 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
38 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
34 views

Per-object screen space uv issue

I am currently trying to sample a texture in screen space. This works well : ...
1
vote
2answers
57 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
67 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
35 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-...
0
votes
0answers
51 views

Why is my ray caster is running much faster as a fragment shader compared to a compute shader

I'm trying to write a simple ray caster in OpenGL with C++. Previously, I have been using the fragment shader of a quad that covers the entire screen to do all the ray calculations. Now, I want to do ...
3
votes
2answers
63 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
103 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 ...
0
votes
0answers
78 views

(Desperately) Need help sending an array of floats from Unity C# to HLSL shaders

I am currently working on implementing parametric curve based dynamic tessellation using GLSL. I have scanned the entire internet and I cannot find even a single good example of a GLSL shader which ...
1
vote
2answers
118 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 ...
0
votes
1answer
67 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
113 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
38 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
75 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
80 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
34 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 ...
0
votes
0answers
79 views

Compute normal based on Voronoi pattern

I am applying a 3D Voronoi pattern on a mesh. Using those loops, I am able to compute the cell position, an id and the distance. But I would like to compute a normal based on the generated pattern. ...
0
votes
0answers
26 views

Unlit shader emulation in usdz

How do you "emulate" an unlit shader in the .usdz file format?
1
vote
1answer
125 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
88 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 ...
0
votes
1answer
66 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
57 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 ...
2
votes
0answers
128 views

Implementing GGX VNDF importance sampling with DXR

I am currently implementing the GGX specular BRDF in a DXR raytracer using the importance sampling method describe by Heitz I am sampling the VNDF with: ...
2
votes
0answers
64 views

Calculate the distance between two 3d points in screen coordinates

Given the Point A with the coordinates gl_FragCoord.xy, I have to find the distance to the Center of the cube face to which it belongs in screen coordinates. ...
1
vote
0answers
22 views

Confusion about glVertexAttribPointer and non-active attributes

When binding an attribute index using glVertexAttribPointer, what happens when a later bound program does not contain an attribute at said index? Is the behaviour undefined, or is the attribute ...
4
votes
1answer
575 views

Why is OpenGL recompiling my depth map vertex shader based on the GL state?

I've written a shader that writes depth to each face of a cube map, as part of rendering cube map shadows for a realtime 3D engine I'm writing with OpenGL and C++. The shader transforms each vertex ...
2
votes
1answer
175 views

Use glTranslatef and shaders?

In newer OpenGL it's encouraged to use shaders and pass the model-view-projection as parameters. But what if I drew a complex object, and wanted to translate/rotate it and draw many copies? For ...
2
votes
0answers
86 views

Screen space reflections become warped when looking up or down

I have been experiencing issues over the past few days with implementing SSR on water into my engine. Looking straight forward, it appears to be alright. However, when I look up or down, the ...
2
votes
1answer
76 views

Represent shape as particles

Input: Triangles which make up an arbitrary shape. Each triangle is represented by 3 3D points. Output: A set of particles which fills up the inside of the object (see image). I have read the ...
2
votes
1answer
96 views

Strange dark spot when lighting in deferred rendering PBR shaders

It's probably something obvious but there seems to be a strange issue with lighting in my pipeline. I'm trying to keep everything in world space at the moment for simplicity but cannot figure out what'...
-1
votes
2answers
239 views

Why does Cubemap have 6 individual textures?

I am learning about Cubemap and I learned that A cubemap is basically a texture that contains 6 individual 2D textures but my question is Why does it contain 6 individual texture ? and also I've read ...
0
votes
1answer
405 views

shaderc compile through api with #include

I'm using shaderc to compile glsl code in to spirv module and pass to pipelie in REAL-TIME. I want to use #include to reuse some of the shader code but shaderc is having problems recognizing it. Any ...
0
votes
1answer
350 views

Sphere Texture Mapping Algorithm

I am trying to generate UV coordinates automatically to map a texture on a sphere. The problem is with seams when going from 0.8 to 0.2 there is a discontinuity and interpolation in fragment shader ...
2
votes
1answer
253 views

2D Line of Sight + Visibility Calculations

I am currently working on an algorithm to calculate visibility in a 2D top-down level. The level contains actors, with position and "sight" information walls, ...
-1
votes
1answer
133 views

Where should I learn shaders as a vulkan user?

I have no prior experience with any other graphics low level libraries and I have barely any clue how shaders work, any book related to shadings is bloated with opengl code and is demoralizing.
2
votes
0answers
69 views

Show the edges between the clipping plane and clipped objects [closed]

I want to utilize shaders to not only discard fragments if they are on one side of a predefined plane but also render a contour along the intersection. My fragment shader currently does something ...
0
votes
1answer
114 views

Ray tracing the next week: understanding Instances

My question is not about the code, but it's about the approach used by the author Peter Shirley (and apparently common practice in ray tracers) of handling Instances. To understand the question it's ...
2
votes
1answer
130 views

Is it possible to bind dynamic texture samplers to a shader in DX12?

So usually texture samplers are set directly in the D3D12_ROOT_SIGNATURE_DESC structure in DX12, at least that's how I've been setting them. I was wondering if it's ...
1
vote
1answer
205 views

OpenGL Unable to retrieve the values of data sent to shader using textures

I've been following these tutorials and i can't figure out how to send data to shaders using textures. https://en.wikibooks.org/wiki/OpenGL_Programming/Scientific_OpenGL_Tutorial_02 In this tutorial ...
2
votes
1answer
78 views

Is there an analogue of OpenGL's ImageLoadStore in DirectX 12?

I'm trying to port part of an OpenGL program into an existing DirectX 12 software, at some point in their shaders they use OpenGL ImageLoadStore in order to store information in 3D Textures without ...
1
vote
1answer
819 views

Convert RGB image to YUV420 using a hlsl shader

I am new to shaders and I need to convert efficiently an RGB image to YUV420. I can convert the RGB image to YUV420 with a simple c++ program that uses the ...
2
votes
1answer
575 views

How does a GLSL Sampler2D read a Vec2 UV coordinate to determine UV range

I am working with an atlas shader that steps through various sprite tiles within a single png atlas page to playback an animation with sampler2D. Looking at the shader code, I would expect to have to ...
0
votes
1answer
292 views

Convert shader from GLsl 1.50 to 1.30

I'm a newbie with OpenGl and I'm stuck in following the tutorial. I found this tutorial with these shaders ...

1
2 3 4 5