Questions tagged [hlsl]

HLSL(High Level Shader Language) is a proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API

HLSL is a C-like language developed by Microsoft and it's used in Direct3D API to define shaders. HLSL is used by Direct3D 9, and is required by the unified shader model in Direct3D 10+.

HLSL can be used to define pixel shaders, vertex shaders, geometry shaders, compute shaders, tessellation shaders, raytracing shaders and mesh shaders. It is analogous to for OpenGL.

Vulkan SDK and DirectX Shader Compiler also supports compiling HLSL shaders into SPIR-V, enabling its use in Vulkan applications.

Resources

1642 questions
0
votes
2 answers

D3D12 Dynamic indexing of textures with different formats

In shader model 5.1 we can use dynamic indexing for textures like so: Texture2D textures[5] : register(t0) PixelShader(Input p) : SV_TARGET { float4 color = textures[0].Sample(someSampler, p.UV); return color; } Here it's assumed that all…
rashmatash
  • 1,699
  • 13
  • 23
0
votes
3 answers

"incorrect number of arguments to numeric-type constructor at line" error in shader, Unity

Found a softbody asset for Unity on github that came with a shader. Due to a limited knowledge of shaders in Unity, I have no idea what the aforementioned error means. Code (Line 22 is where the error is happening. I've marked it.): Shader…
Ducktor
  • 337
  • 1
  • 9
  • 27
0
votes
1 answer

Comparison operations in HLSL

I am reading through a HLSL implementation of CSM shadow mapping and have come across a line of code i don't quite understande float3 pos; float3 CascadeDistances; ... float3 weights = ( pos.z < CascadeDistances ); Can someone please tell me what…
Steve Medley
  • 151
  • 3
  • 7
0
votes
0 answers

When I initialize my ID3D11UnorderedAccessView's buffer to be any larger than 16 bytes, my shader's output is blank. What could be causing this?

I have the following function to create my UAV and initialize a buffer for it: template static inline void CreateInitializedUnorderedAccessView( _In_ ID3D11Device* pDevice, UINT count, …
MNagy
  • 423
  • 7
  • 20
0
votes
0 answers

HLSL multi-pass geometry shader culling issue

I'm working on a shader that runs two passes: A standard vertex / pixel shader that draws the original object with some alpha blending A geometry shader that subdivides the mesh and makes it crumble My issue however is that the geometry of the…
kiamvdd
  • 31
  • 3
0
votes
1 answer

Determinisitic Compute Shader For Simplex Noise In Unity

So I have been trying to use the power of compute shaders to speed up the process of generating simplex noise for my map terrain generation in unity. The problem is that for the game to work it requires everything to be deterministic in order to…
0
votes
1 answer

Compute Shader writing to RWStructuredBuffer randomly from multiple thread groups

I am trying to implement random access reads and writes to RWStructuredBuffer from multiple thread groups. The race condition can occur when there are two threads (on different thread group) running at the same time (on different multiprocessors)…
TheBojanovski
  • 137
  • 1
  • 7
0
votes
1 answer

HLSL - What Does int(x) or int(value) do in High Level Shading Language 2.0?

I've been asked to port some old HLSL code (Shader Model 2.0/3.0) into another language. There is a line in the code that reads - int(value) or int(x). But it doesn't seem to be a "convert to integer" or "return integer of" or similar…
GLSL Dude
  • 1
  • 3
0
votes
1 answer

Load from multisampled texture fails on some Intel GPUs

I’ve implemented mouse picking in my app by using a stencil buffer. Here’s the pixel shader that reads value under the mouse: Texture2DMS depthStencilTexture : register( t0 ); cbuffer ReadDepthInput : register( b2 ) { int2…
Soonts
  • 20,079
  • 9
  • 57
  • 130
0
votes
1 answer

Is there any GLSL's ftransform() translation in HLSL?

When using GLSL vertex shaders, a way to let the shader work as a fixed-function pipeline is to call the: ftransform(); function. Is there a similar function for HLSL's vertex shaders? Thank you
tunnuz
  • 23,338
  • 31
  • 90
  • 128
0
votes
1 answer

How to draw 1 pixel long dotted lines in DirectX?

How can I draw lines similar to the negative axis in Google Sketchup ? I know I can parametrize the line using texture coordinates and draw the line in homogenous coordinates. But if my pixel shader has some logic like tex.u%5<1, surely sometimes…
vlad2048
  • 93
  • 7
0
votes
1 answer

HLSL - how does vertex shader's output POSITION0 affect pixel shader's texture mapping uv?

It seems POSITION/POSITION0's w devide everything in output struct. thus made pixel shader can do correct perspective mapping.and it cant be removed,otherwise pixel shader wont output anything. i didn't see any configuration in program code. Is it…
max zhou
  • 43
  • 3
0
votes
1 answer

Trying to create a wave shader, I can't seem to calculate the normals to apply specular lighting to my wave

Here is my HLSL code for the wave in the vertex shader: // Change the position vector to be 4 units for proper matrix calculations. input.position.w = 1.0f; // Offset position based on sine wave input.position.y = height * sin(input.position.x +…
0
votes
1 answer

Convert float to unorm in HLSL

I am trying to implement my own depth stencil like functionality in a pixel shader. I have a normalised depth value, and I want to convert it to an integer in order to use the SM5 InterlockedMin() operation, like so: uint d_uint = (uint)(dnorm *…
sebf
  • 2,831
  • 5
  • 32
  • 50
0
votes
1 answer

Having trouble adding more Texture2D's as Pixel Shader resources in DirectX 11

I'm having a really annoying problem with my application that is a school project. I'm using deferred rendering and I'm trying to add positions from the light's pov as a new g-buffer texture, and the depth buffer texture as a shader resource in the…