Questions tagged [hlsl]

HLSL is the High-Level Shading Language, used to author shaders for use with Direct3D, and cross-compilable to SPIR-V. Use this tag for questions which are specifically about shaders written in this language. For generic shader questions use [shader] instead.

Filter by
Sorted by
Tagged with
1 vote
0 answers
112 views

Most efficient way to calculate signed distance field (SDF) for pixel subsamples?

Looking how to utilize as much parallelization processing as possible for the following task: A screen-sized texture is completely black except for blue pixels which are in close proximity to geometry ...
Daniel Cardin's user avatar
0 votes
1 answer
86 views

How do I tell what kind of shader an hlsl shader is by looking at the code?

How do I tell what kind of shader this is: https://github.com/aras-p/UnityGaussianSplatting/blob/main/package/Shaders/GaussianSplatting.hlsl Among these options: vs – vertex shader ps – pixel shader ...
Ethan's user avatar
  • 103
0 votes
0 answers
42 views

How to use unbound descriptor range properly in descriptor tables

I am trying to use 2 "D3D12_DESCRIPTOR_RANGE" in a root descriptor table,defined as follows: ...
VersesDev's user avatar
  • 129
1 vote
0 answers
31 views

Help understanding Texture2D multi-sampling semantics: Why do we need sample index AND location?

Looking at the windows HLSL documentation for Texture2DMS.Load found here: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/texture2dms-load can someone help me better understand different ...
Dan's user avatar
  • 11
1 vote
1 answer
510 views

How to calculate ray-origin and ray-direction in vertex shader working universally for any projection and using interpolators for performance

I have been reading and watching many raymarching tutorials, but almost all of them are only working in the perspective projection. Almost all assume, that to calculate the ray direction, you just ...
Tooster's user avatar
  • 111
0 votes
0 answers
51 views

Hlsl Texture2d array that can be accessed using a variable index

I have tried ...
t3rminal's user avatar
0 votes
2 answers
209 views

Storing array of floats within shader

I am about to implement a framerate histogramm chart for a DirectX Renderer. Ideally I would do this in pure shader code, but for a a histogramm I need to store the timestamps of the last ...
user20154's user avatar
1 vote
0 answers
50 views

BlinnPhong sphere edges look worse than Phong. Am I doing it wrong? (code and pictures included)

First of all, I am completely new to this so please excuse me if this is a dumb question. I am following the book Real-Time 3D Rendering with DirectX and HLSL, for now implementing shaders in Nvidia ...
egil87's user avatar
  • 11
2 votes
1 answer
85 views

Numerically integratable fog volume feathering along a ray

I haven't been able to come up with a good solution for this myself, so I thought I'd ask if anyone else has any good ideas on how to approach this problem. Here's more or less what I'm trying to do ...
smootherstep's user avatar
5 votes
0 answers
59 views

Facetted look when using SampleBias

I am writing a simple material system for a game. Each material can have a specular value (phong) that is translated into "smoothness" via environment map. Similar to PBR, I compute a ...
Raildex's user avatar
  • 173
0 votes
2 answers
118 views

Porting from DXR/HLSL to Vulkan Ray Tracing Extension/GLSL

I am working on the port of a demo from DXR to Vulkan Ray Tracing extension using GLSL. In DXR/HLSL space, there are RayTMin() and RayTCurrent() functions to retrieve the starting and the current end ...
Vectorizer's user avatar
1 vote
0 answers
100 views

Calculating ray intersection with two spheres (with smooth_blending between the two spheres to make them appear as one continuous geometry)

I have the following function to define the distance to the interesection between a ray and the surface of a sphere: ...
Iron Attorney's user avatar
3 votes
1 answer
197 views

Black squares in bloom effect

Good Morning! I'm having trouble rendering an on-screen bloom shader by post processing. Basically the shader works like this: Camera image before rendering the effect: First a filter is passed on ...
Matheus Markies's user avatar
0 votes
1 answer
869 views

Billboarding in Vertex Shader

I'm trying to create a vertex shader that billboards a quad. Most resources online show the code to be some variation of the following ...
H3XXX's user avatar
  • 115
0 votes
0 answers
77 views

16 bit SNORM format not correctly storing Z component?

I generate a normal GBuffer in my engine, and I store it using a R16G16B16A16_SNORM format like this: ...
H3XXX's user avatar
  • 115
0 votes
1 answer
1k views

Calculating UV coordinates for sampling texture atlas

I have an 8192x8192 texture atlas that contains 1024x1024 shadow maps aligned side by side. I'm trying to calculate the uv coordinates so that I can sample each shadow map appropriately based on the '...
H3XXX's user avatar
  • 115
1 vote
0 answers
103 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 ...
H3XXX's user avatar
  • 115
0 votes
1 answer
101 views

Scale Sampled Depth Value

I am currently porting the atmosphere algorithm used by the UE4 engine to my engine. As the original algorithm from Bruneton is in Kilometers i had to adapt it to my engine which uses meters. ...
André Ferreira's user avatar
0 votes
0 answers
77 views

Unity path tracing makes the pc crash

Good Morning. I'm testing Path Tracing techniques with unity, following this tutorial. http://three-eyed-games.com/2019/03/18/gpu-path-tracing-in-unity-part-3/ But I'm in trouble. Whenever I try to ...
Matheus Markies's user avatar
2 votes
4 answers
254 views

Question about function for color

I would like a help to understand the following line of code: return float3(pow(color.r, 2.2), pow(color.g, 2.2), pow(color.b, 2.2)); I've seen some places calling ...
Matheus Markies's user avatar
0 votes
0 answers
371 views

Weird PIX behavior with DXC

Recently I've switched from FXC to DXC to compile shader model 6.0. It compiles well without errors (and runs well) but I can't debug shaders because on my netbook PIX says "failed to load PDB ...
Flone's user avatar
  • 1
3 votes
1 answer
3k views

How to pass a 2D array to a function

How do you allow a function to accept a reference of a double array ? For example: MyFunc(uint x, uint y, float2[][] myArray) {} I get ...
wduk's user avatar
  • 177
0 votes
1 answer
220 views

Pathtracing - many bounces reduce shadows

I'm creating DXR PathTracer highly influence by Matt Pettineo's one - https://github.com/TheRealMJP/DXRPathTracer ; Relevant HLSL code below: ...
DirectX_Programmer's user avatar
1 vote
1 answer
517 views

Importance sampling GGX NDF - fireflies and bright final result

https://schuttejoe.github.io/post/ggximportancesamplingpart1/ - I have problem implementing this method. Somebody asked question about this before ( Can't understand the Importance sampling GGX ) ...
DirectX_Programmer's user avatar
1 vote
1 answer
335 views

Path tracing - cannot converge diffuse sampling + oversaturation

I'm in process of creating progressive path tracer using DX12 + DXR. I managed to create working raytracing code + pathtracing code with multiple bounces but I'm experiencing problems stated below (...
DirectX_Programmer's user avatar
1 vote
1 answer
92 views

Worsening sampling quality of raytracing with increasing distance from world origin

I am using RT shader (DXR) to generate g-buffers with code below. There was no problems with smaller scene (pink room from cwyman tutorial - http://cwyman.org/code/dxrTutors/tutors/Tutor5/tutorial05....
DirectX_Programmer's user avatar
3 votes
2 answers
2k views

Using array of textures in DX12

I managed to create code, working correctly as Texture2DArray in hlsl by using single ID3D12Resource and binding it as D3D12_SRV_DIMENSION_TEXTURE2DARRAY with constant array size. ...
DirectX_Programmer's user avatar
1 vote
2 answers
1k views

What is a tbuffer and what is their use case?

In HLSL, we have cbuffers and tbuffers. MSDN's description for tbuffers is the following: A texture buffer is a specialized buffer resource that is accessed like a texture. Texture access (as ...
user avatar
1 vote
1 answer
66 views

Texture value clamped to 1

I am working on ray/path-tracer using DXR and I'm starting with simple AO. In first pass, I am storing normal value and RayTCurrent(): ...
DirectX_Programmer's user avatar
2 votes
0 answers
373 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/...
b1skit's user avatar
  • 161
1 vote
1 answer
151 views

Reading from buffer versus calculating on the fly performance

I am creating a fast fourier transform algorithm for the compute shader - i am no expert on how GPUs really run optimally so thought i would ask here. I have the option to calculate on the fly or ...
wduk's user avatar
  • 177
0 votes
1 answer
78 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 ...
MaT's user avatar
  • 1,229
2 votes
0 answers
85 views

Per-object screen space uv issue

I am currently trying to sample a texture in screen space. This works well : ...
MaT's user avatar
  • 1,229
2 votes
0 answers
47 views

Multipass Rendering Vertex Buffer Organisation

I am working on a Renderer that should do a Depth Prepass before rendering the desired geometry. For this I have a Vertex and Pixel Shader that outputs to the Depth Texture. After that it should ...
user avatar
2 votes
0 answers
597 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: ...
Badnet's user avatar
  • 21
1 vote
0 answers
115 views

Cannot use variable as texture sample value - HLSL DirectX11

I ran into strange problem. My HLSL VS won't compile for given lines: ...
DirectX_Programmer's user avatar
2 votes
0 answers
29 views

Should I use common resource bindings across all my shaders in HLSL/D3D12?

Will unaccessed bindings consume cache or bandwidth? I want to improve cache usage by splitting the per-path information in my renderer across different resources, but I also want to keep my binding ...
Paul Ferris's user avatar
1 vote
1 answer
3k 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 ...
hezided's user avatar
  • 11
2 votes
1 answer
330 views

R16_FLOAT, SampleCmp and CheckFormatSupport

I want to use PCF shadow map on my d3d11 app. My shadow map is an R16_FLOAT texture. When I use SampleCmpLevelZero it didn't give a correct result. After enabling debug layer, it shows: The Shader ...
ACskyline's user avatar
  • 115
4 votes
0 answers
306 views

Direct3D Global Atomic Issue

Recently I ran into an odd issue with some of my DirectX11 DirectCompute code when trying it on an AMD GPU for the first time where as on a NVIDIA one it had worked fine all through development. The ...
Lemon Drop's user avatar
5 votes
1 answer
538 views

Precision problem on AMD

I have a problem with precision on AMD in shaders (hlsl). In vertex shader I calculate UVs for particle using modulus operator ...
Derag's user avatar
  • 596
1 vote
1 answer
774 views

How to scale and offset a cubemap using sphere mapping

I am trying to scale and repeat a Cubemap with Latitude-Longitude mapping layout just as you would do with classical UV mapping but without any interesting result. This should be used as a skybox. ...
MaT's user avatar
  • 1,229
1 vote
1 answer
520 views

Changing sin frequency smoothly in shader

In my vertex shader I am using a sin function to offset vertices. But as I change the frequency of my sin function I notice some ...
MaT's user avatar
  • 1,229
3 votes
1 answer
1k views

Unexpected results from Mitchell-Netravali

I recently implemented Mitchell-Netravali filtering in my path-tracer with 16x (4x4) temporal anti-aliasing. PBR's demonstration image shows it should give significantly better results than the box ...
Paul Ferris's user avatar
5 votes
1 answer
5k views

Threads per compute shader group

The maximum allowed number of threads per compute shader group is 1024 for Shader Model 5.0. Is it advisable with regard to performance to stay close to this maximum number? In order to resolve SSAA ...
Matthias's user avatar
  • 1,074
2 votes
1 answer
387 views

Artifacts in omni light shadow mapping

Spotlight My spotlight's intensity is cut off at a distance of 3 and at an angle of $\pi/4$ radians (umbra angle). The corresponding light camera has a near plane at a distance of 0.1, a far plane at ...
Matthias's user avatar
  • 1,074
4 votes
1 answer
462 views

Special Texture Stretching without deformation

I am trying to achieve a special texture stretching effect in my shader. Here is how I define my uv before sampling my texture, nothing really special. ...
MaT's user avatar
  • 1,229
2 votes
0 answers
80 views

Implementation of the paper "unified texture management of arbitrary meshes"

I briefly read the paper and I think I got the basic idea of it. The paper doesn't really go into implementation details though so my question is mostly on that. In the paper, needed tiles are ...
Temp4890's user avatar
3 votes
1 answer
3k views

What are Jittering and Dithering

I've heard a lot about jittering and dithering but I would like to know more about those techniques, especially when used to avoid visible sampling in a fragment shader. What are the differences ...
MaT's user avatar
  • 1,229
2 votes
0 answers
156 views

If statements in shaders - implications and consequences [duplicate]

I've heard a lot that in shader development, you absolutely need to avoid branching and so if statements. But why? Does this have a real impact on performances on old and modern hardware or is it ...
MaT's user avatar
  • 1,229