1,671 questions
0
votes
0
answers
46
views
Taking advantage of memory contiguousness in HLSL
This is a bit of a slog so bare with me.
I'm currently writing a 3D S(moothed) P(article) H(ydrodynamics) simulation in Unity with a parallel HLSL backend. It's a Lagrangian method of fluid simulation,...
-1
votes
0
answers
53
views
HLSL URP 17.0 PBR functions do not render light
Unity provides their PBR lighting function with UniversalFragmentPBR, and UniversalFragmentBlinnPhong, but for me, it doesn't seem to render the light.
I have been following a couple of books on ...
0
votes
0
answers
68
views
Drawing a color wheel with fxc shader in a WPF app
I want to achieve something like this with fxc shader in a WPF application.
So far, with the below hlsl (High-Level Shading Language) code, I managed to produced this picture:
The problem is that I ...
0
votes
0
answers
100
views
Is StructuredBuffer<T>[ ] more analogous to std::vector<T>[ ] or std::vector<std::vector<T>>?
So let's just say I have:
// HLSL
layout (set = 0, binding = 4) StructuredBuffer<T> my_buffer;
And compare it with:
// HLSL
layout (set = 0, binding = 4) StructuredBuffer<T> my_buffers[];
...
0
votes
0
answers
31
views
HLSL Texture2DArray.Load can only load pixel of first texture
Call Texture2DArray.Load(int4), and pass non-zero value to the third component of vector. It always returns float(0, 0, 0, 1)
Part of shader:
float4 sample_source(int sourceIndex, float2 texcoord)
{
...
1
vote
0
answers
74
views
How can I get syntax highlighting for HLSL in CLion?
The title says it all. There seem to be no plugins and no native support for proper HLSL highlighting.
Native support results in just keywords getting highlighted, my current workaround is that I put *...
0
votes
0
answers
136
views
How would I resolve this redefinition error in HLSL, despite not redefining anything?
I am currently learning how to write shaders in Unity, as the Unity environemt is most comfortable for me to use.
I want to create a procedural terrain, and currently trying to light it using ...
1
vote
0
answers
45
views
Is HLSL pessimsing by not offering all of the cuda shuffle intrinsics?
Cuda has
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#warp-shuffle-functions
Warp Shuffle Functions
__shfl_sync, __shfl_up_sync, __shfl_down_sync, and __shfl_xor_sync exchange a ...
1
vote
1
answer
137
views
D3D12 Cooperative Vectors: thread to vector correspondence
The cooperative vectors feature seems a bit magical to me. Before each thread owned it's local variables. Now vector<float, 8> MulRes seems to be shared across the threads (i.e. the first 8 ...
1
vote
0
answers
66
views
Circular artifacts when performing deferred shading
I finally managed to add realistic realtime rendering to my software. Now I am facing some "banding" artifacts when performing the actual shading. The test scene is straightforward. It ...
0
votes
0
answers
62
views
Noise pattern has subtle difference between glsl and hlsl
I'm using a noise algorithm from here, the code is
highp vec3 mod289(highp vec3 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
highp vec4 mod289(highp vec4 x) {
...
0
votes
2
answers
181
views
Fastest way to accumulate (reduce) a StructuredBuffer<float> in a compute shader
I've got a RWStructeredBuffer<float> tau I'm writing to in a ray generation shader rayGen. The DispatchRays dimension are (tauWidth, tauHeight, 1) and tau has exactly tauWidth * tauHeight ...
1
vote
1
answer
134
views
Volumetric Fog HLSL DirectX 11 [closed]
Good evening! I want to implement volumetric fog in HLSL on DirectX 11. But I can't find a mathematical summary anywhere. Can someone provide the code in hlsl in what order and what variables I need ...
0
votes
1
answer
63
views
Projecting Depth of Adjacent Pixel based on Normal
I'm working on a screen-space outline effect for a low-res, cartoony game idea. I'm very new to HLSL programming and fullscreen Shader Graphs, but by looking at tutorials, I've mostly gotten the depth-...
1
vote
1
answer
148
views
Parallel reduction with single wave
Following these slides https://www.nvidia.com/content/GTC-2010/pdfs/2260_GTC2010.pdf when doing a parallel reduction you should avoid GroupMemoryBarrierWithGroupSync when reducing the last 2*...
2
votes
0
answers
68
views
Passing depth buffer values as a texture to pixel shader
I'm very new to shader programming, so forgive me for any knowledge gaps or mistakes I've made.
I am currently following a technique discussed in Nvidia's GPU Gems: https://developer.nvidia.com/...
0
votes
1
answer
92
views
half data in structured buffer directx11
I am trying to use 16 bit floating point data in my directx 11 buffer but the data always comes back wrong are there special options i need to set on the data to pack it and read it correctly?
this is ...
2
votes
0
answers
108
views
When converting HLSL to GLSL with shaderc and SPIRV-Cross, how can I keep in/out variable names consistent?
Here's my C++ code that converts HLSL to GLSL:
const shaderc::Compiler scompiler;
shaderc::CompileOptions soptions;
soptions.SetSourceLanguage(shaderc_source_language_hlsl);
soptions....
0
votes
0
answers
40
views
Suggestions on how to fix holes appearing in 2D image rotation shader?
I have a HLSL shader I am using in unity and the idea is to take a 2D image and a depth map of that image, and rotate them based on an euler input. Right now it's rotating exactly how I want it to, ...
-3
votes
1
answer
133
views
HLSL/GLDL float2x2 mul() operation
What is the result of this hlsl/glsl code (and are they different)?
float2x2 m2x2 = { a, b, c, d };
float2 xy = { x, y };
float2 result = mul( m2x2, xy );
Is it result = float2( a*x + b*y, c*x + ...
0
votes
1
answer
111
views
Why is the grid visible through my custom shader in Unity?
In Unity's Editor Scene view, the grid is not visible through an object with the default Lit URP shader, but an object with my custom simple shader appears transparent to this grid. I don’t understand ...
1
vote
1
answer
213
views
How do I pass a value from the vertex shader as a flat variable in Slang and HLSL?
In my GLSL code in my vertex shader I have:
layout(location = 2) out flat uint out_uniform_index;
layout(location = 3) out vec2 out_pos_in_chamfer_box;
layout(location = 4) out flat vec2 ...
0
votes
1
answer
211
views
VS22 debug output fail on above HLSL shader model 6.6 ERROR: Shader Model 6.7 is not supported! (RTX 3090)
I cant seem to get any HLSL shader model above 6.6 working in VS22 even though Nvidia tells me that the GPU (RTX 3090) supports shader model 6.8. With SM 6.8 MS recommended windows be placed into dev ...
0
votes
1
answer
122
views
Dynamic index in vk::binding(index, 0)?
I've recently been introduced to a new rendering system which uses the bindings from Vulkan and I've created a system where I bind a lot of textures from a vector.
This causes an issue that everytime ...
1
vote
0
answers
170
views
How to terraform terrain generated with marching cubes in a right way?
I implemented an algorithm to fill the RWTexture3D with density values according to y coordinate of the value using compute shader. Basically, density[id] = id.y * 0.01 - 0.5. So my densities are in a ...
1
vote
1
answer
140
views
DirectX11 discard/clip pixel MSAA
I am creating my Colour and Depth textures using a sample description of count 8. When rendering geometry the MSAA appears to be working nicely.
However, in my sprite based shaders, where I render ...
-1
votes
1
answer
132
views
'redefinition of script' and 'type is ambiguous' errors
I'm writing a compute shader in unity and am writing various HLSL scripts which will be referenced in the compute shader using #include.
I have a struct called Move, in a script called MoveC.hlsl. I ...
0
votes
0
answers
84
views
Stencil buffer to outline sprites
In HLSL, I want to make a shader that blends my sprites so that the outline only appears in the borders of the blended shape and not in the interior, like in the image above. I've been trying to use ...
0
votes
0
answers
32
views
Write Data contiguously across threads
I have a compute shader that culls object triangles against frustums.
For culling, I use a huge vertex and index buffer and a pair of (offset, count) to identify the range of vertices for a single ...
0
votes
0
answers
86
views
Array access out of bound in dx11 hlsl
what will happen if the shader access an array with error index in hlsl?
where can find dx spec about this?
I wanna know the right behavior that the driver should execute in this situation,
such as
...
2
votes
1
answer
186
views
How to compile HLSL 6.0 at runtime?
I am currently learning D3D12 and decided to change from using HLSL 5.0 to 6.0 to be able to use dynamic indexing. The problem is that D3DCompile and D3DCompile2 seen to only support up until HLSL 5.0,...
0
votes
1
answer
484
views
hlsl - how do i avoid using switch statement?
i recently started working with shaders, and i’d like to avoid using a switch statement.
it keeps getting longer and i’m wondering if there are alternative approaches or patterns i can use.
below is ...
2
votes
1
answer
211
views
Shader signature reflection
I am trying to get the shader signature for my vertex shader in HLSL using DirectX 12 and I cannot figure out how to get the data types out of the parameters.
vs.hlsl
#include "rootsig.hlsl"
...
1
vote
0
answers
44
views
How to calculate Gertner waves normals?
I'm unable to properly calculate the normals for gertner waves following the Nvidia article
vec3 get_wave(vec4 wave, vec2 direction,vec3 vtx)
{
// x = SPEED, y = WAVELENGTH, z = AMPLITUDE, w = ...
1
vote
0
answers
95
views
the register assignment collision across shader stages in dx12
My vertex shader use cbuffer 'A' it get assign to register b0. At the same time, my pixel shader use cbuffer 'B' and after compilation it get assign to the same register b0.
As i can see, in order to ...
2
votes
0
answers
98
views
Dynamic Texture3D Indexing in HLSL shader
Is it possible to store Texture3D resources (preferably of different resolutions) in a BVH or cluster grid, and dynamically index them in a shader at runtime?
I'm building a custom volumetric ...
1
vote
1
answer
58
views
How to skip edges shared between two triangles when conservative rasterization
When enabling conservative rasterization, there are lots of fragments generated from edges.
How to skip fragments generated from edges shared between two triangles?
-1
votes
1
answer
94
views
Add rotation to main texture - unity shader
i don’t have any knowledge about Shaders script. I want to have a float in my shader and rotate my texture with that value on UV. how can i add this option to my Shader?
I don't want to use Shader ...
1
vote
0
answers
441
views
How to get shadow from additional light in Unity custom shader?
I’m working on a project in Unity where I’m using a compute shader to render grass. The rendering path is Forward+, and I’m trying to make the additional lights affect the grass. I want to achieve ...
0
votes
0
answers
118
views
Do WebGL/WebGPU shaders use log2(x) when implementing log(x)?
I came across this quote on the Outerra blog:
using log2 instead of log: in shaders, log function is implemented using the log2 instruction, so
it's better to use log2 directly, avoiding an extra ...
1
vote
1
answer
135
views
Unpack/Pack SNorm16 in HLSL compute shader
I'm trying to unpack SNorm16 values in HLSL compute shader. Since SNorm16x4 = 8 bytes total, and Load/Store functions can only read/write 4 bytes I'm trying to get two 4 bytes values as packed to 1 ...
0
votes
1
answer
427
views
Recreating Quaternion.FromToRotation in hlsl with a compute shader
I'm working on a grass instancer using compute shaders. Each grass blade shall be rotated to the ground normal.
The problem: I can't use Unity functions like Quaternion.FromToRotation and they musst ...
0
votes
1
answer
98
views
How can I use a shader to make my brick wall look more realistic and have some color variation?
I have this brick wall in a project that I am working on. I modelled the wall itself in Blender: its a whole bunch of bricks which stick out a little from a cube that is meant to be the "mortar&...
-1
votes
1
answer
39
views
How to avoid documentation duplication in CG/HLSL?
Let's say we have few function overrides in CG/HLSL, and this functions need some big and almost the same documentation, so how to get it for each override without repeating the same text?
/**
* Long ...
0
votes
0
answers
74
views
Converting Unity Built In RenderPipeline shader to URP shader
I am working on the Unity Learn 3D Game Kit. But in URP project, shaders are not working as expected. So i have to convert them to URP.Below code is from 3D Game Kit shader. I am not good at shader ...
2
votes
0
answers
95
views
SV_PrimitiveID in Geometry Shader and Pixel Shader in Dx12
When I learn the system value SV_PrimitiveID,I have a question.
In my realize,SV_PrimitiveID will give each primitive an id.But if I add GS to pipeline and the GS adds new primitive.I want to know if ...
1
vote
1
answer
91
views
Need help modifying HLSL shader
I am trying to modify this shader code which adds a phosphor effect in the form of "phosphor trails" much like an old CRT monitor. This code is part of MAME emulation software package.
Can ...
1
vote
1
answer
77
views
Why is my 2d quad not rendering using glm::perspective?
I try to render a simple 2d quad using DirectX12, but somehow my perspective camera is not displaying the quad, orthographic camera works though. The reason of the perspective camera is to prepare for ...
0
votes
1
answer
94
views
Triangle not showing despite imgui and compute draw working fine
I am following vkguide but not exactly. I am struggling getting a triangle to appear. When looking at render doc, it seems the vertices are drawn correctly according the the mesh viewer, but nothing ...
1
vote
0
answers
49
views
Unity: Set a mesh directly on the GPU
In unity I'm constructing a mesh on the GPU. Currently, I have to write the vertices / indices back to the CPU before setting them again in the mesh. This is very inefficient and takes about 90% of ...