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
3
votes
1 answer

Which shader file format should I use in HLSL?

I've read this DirectX 11 tutorial on VS2015 (http://www.rastertek.com/dx11s2tut04.html), and found out that the author compiles the vertex and pixel shader separately, using the .vs file and .ps file respectively. And I also found out that in the…
ItsJingran
  • 147
  • 9
3
votes
2 answers

Pack two floats within range into one float

In HLSL, how would I go about packing two floats within the range of 0-1 into one float with an optimal precision. This would be incredibly useful to compress my GBuffer further.
Miguel P
  • 1,262
  • 6
  • 23
  • 48
3
votes
0 answers

Calculating position in view space from depth buffer texture in DirectX 11/HLSL

I want to reconstruct the position in view space from depth buffer texture. I've managed to set the depth buffer shader resource view into shader and I believe there's no problem with it. I used this formula to calculate the pixel position in view…
PolGraphic
  • 3,233
  • 11
  • 51
  • 108
3
votes
1 answer

Mismatch between SetInputLayout, VertexShader, and PixelShader

I have apparent mismatches between each of them, but I can't see why or how they do not match. I've been looking at it so long I can't see anything now, so perhaps a few more sets of eyes.... Here are the members of the vertex struct: XMFLOAT4 …
Dave
  • 1,521
  • 17
  • 31
3
votes
2 answers

How to use a huge array in HLSL (error X4505)

When I try to compile I get the error: X4505: sum of temp register and indexable temp registers exceeds limit of 4096. However my shader does work in FX Composer. The reason it crashes is probably because I use a very large array since I'm using…
Achille Depla
  • 97
  • 1
  • 10
3
votes
1 answer

Shader for counting number of pixels

I'm looking for a shader CG or HLSL, that can count number of red pixels or any other colors that I want.
ragia
  • 143
  • 3
  • 9
3
votes
2 answers

YUV to RGB shader border artifact

I have YUV to RGB conversion shader. struct Pixel_INPUT { float4 pos : SV_POSITION; float2 tex : TEXCOORD0; }; Texture2D textureY : register(t0); Texture2D textureU : register(t1); Texture2D textureV : register(t2); SamplerState…
Alatriste
  • 527
  • 2
  • 6
  • 21
3
votes
1 answer

How can I encode four unsigned bytes (0-255) to a float and back again using HLSL?

I am facing a task where one of my hlsl shaders require multiple texture lookups per pixel. My 2d textures are fixed to 256*256, so two bytes should be sufficient to address any given texel given this constraint. My idea is then to put two…
Statement
  • 3,888
  • 3
  • 36
  • 45
3
votes
0 answers

How to obtain texture coordinate from arbitrary position in HLSL

I'm working on a C++ project using DirectX 11 with HLSL shaders. I have a texture which is mapped onto some geometry. Each vertex of the geometry has a position and a texture coordinate. In the pixel shader, I now can easily obtain the texture…
Martin85
  • 308
  • 4
  • 13
3
votes
1 answer

using Kinect Depth View to show an Object inside the Human Body

I currently working on Depth Data on Kinect SDK v1.8 on XNA and I wanna show an Image Inside the Depth view of Human body. the image below is just an example of what I wanna do…
Nathan Drake
  • 311
  • 3
  • 16
3
votes
3 answers

HLSL tex2d sampler seemingly using inconsistent rounding; why?

I have code that needs to render regions of my object differently depending on their location. I am trying to use a colour map to define these regions. The problem is when I sample from my colour map, I get collisions. Ie, two regions with different…
RJFalconer
  • 10,890
  • 5
  • 51
  • 66
3
votes
1 answer

Blur on Windows Phone 8 too slow

I'm implementing blur effect on windows phone using native C++ with DirectX, but it looks like even the simplest blur with small kernel causes visible FPS drop. float4 main(PixelShaderInput input) : SV_TARGET { float4 source =…
user1760770
  • 365
  • 5
  • 17
3
votes
1 answer

How to define a function-like macro with D3DCompile() from C++?

Is it possible to define a function-like macro with the const D3D_SHADER_MACRO *pDefines parameter of D3DCompile() ? Sadly MSDN is not very specific but implies they can be defined with /D option of fxc.exe. I tried with this : const…
Poppolopoppo
  • 103
  • 1
  • 7
3
votes
2 answers

Impossible to compile hlsl shaders after updating to Sharpdx 2.6.2

I have a C# project that used SharpDX 2.5.0 and everything was working fine. I moved to the newest stable release of SharpDX, 2.6.2. My project compile fine but fails at runtime because it cannot compile the shaders. I'm using this line of code…
Ndech
  • 965
  • 10
  • 21
3
votes
1 answer

DirectX 11 Compiling individual HLSL files (without effects)

First off, I'm completely new to DirectX11. As Microsoft deprecated Effects & D3DX with the release of Windows 8, I want to use an alternative to Effects. However I have no idea how to do it, I just know that every HLSL file has to have 1 entry…
Rakete1111
  • 47,013
  • 16
  • 123
  • 162