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 parts of this water shader are resposible for the transparancy?

I have a water shader here and I want to know what code is responsible for transparency. Currently the water is transparent, that is the other thing i would like to change. I hoped the RenderType is "RenderType"="transparent" but it is…
Mr_Desmond
  • 59
  • 6
3
votes
1 answer

How to pass float3x3 to HLSL Shader in DirectX?

I'm having trouble with passing 3x3 matrix through a constant buffer to my shader in DirectX. This is how I define my constant buffer: In .cpp: struct PostProcessConvolutionCB { float screenWidth; float screenHeight; float sum; …
Maciej Dziuban
  • 474
  • 3
  • 21
3
votes
2 answers

HLSL: Returning an array of float4?

I have the following function in HLSL: float4[] GetAllTiles(float type) { float4 tiles[128]; int i=0; [unroll(32768)] for(int x=0;x
Mathias Lykkegaard Lorenzen
  • 15,031
  • 23
  • 100
  • 187
3
votes
2 answers

Direct3D11: "gradient instruction used in a loop with varying iteration, forcing loop to unroll", warning: X3570

I'm working on a graphics engine using Direct3D 11 and Visual Studio 2015. In the HLSL shaders for the main draw calls, I sample shadow maps for directional and point lights with percentage-closer-filtering, i.e. I sample a small square area around…
Novare
  • 71
  • 1
  • 7
3
votes
0 answers

Lighting abnormal when calculating in tangent space. Probably something wrong with coordinate transformation matrix

I'm trying to calculate lighting in tangent space. But I just keep getting abnormal results. I was modifying the book's demo code and I wander if there maybe something wrong with the transformation matrix I created. I'm having trouble solving a…
tigerccx
  • 47
  • 6
3
votes
1 answer

uniform keyword in HLSL

it seems that in HLSL i can but dont have to provide the uniform keyword for variables which come from the application. right? why is that so?
clamp
  • 33,000
  • 75
  • 203
  • 299
3
votes
1 answer

ThreeJS shaders in Unity

I'm working on a project in Unity that uses AR to place products in the real world. These products (geometry & material) are downloaded from a http server and converted into a gameobject in Unity. These products are originally created in ThreeJS…
Tostifrosti
  • 143
  • 9
3
votes
1 answer

HLSL 5.0 float1x3 vs float3x1 constant buffer packing rule

I'm currently trying to get my head around constant buffer packing rules in HLSL 5.0 and D3D11. So I played a little with fxc.exe: // Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.18773 // // // Buffer Definitions: // // cbuffer…
user1655806
  • 396
  • 1
  • 3
  • 15
3
votes
1 answer

Direct3D Compute Shader running 15x slower than Unity Compute Shader

I'm developing a VR application in Unity that uses a native plugin for video decoding and I wanted to do some processing on the decoded video frame. My first step was to use a Unity compute shader that was dispatched from a C# script within the…
Will-of-fortune
  • 167
  • 1
  • 3
  • 16
3
votes
1 answer

Convert colors from RGB to NV12

I’m working on an app that encodes video with media foundation h264 encoder. Sink writer crashes on Windows 7 with RGB input in VRAM, saying "0x8876086C D3DERR_INVALIDCALL" so I’ve implemented my own RGB->NV12 conversion on GPU, saving more than 60%…
Soonts
  • 20,079
  • 9
  • 57
  • 130
3
votes
0 answers

Is it possible to pass an array into a PixelShader register using WPF

I'm trying to write a Gaussian blur pixel shader for use with WPF Effects, but I'm having difficulties finding a way to pass the kernel into the shader. The way my shader works is pretty standard. It calculates the kernel on the cpu and then it…
3
votes
2 answers

What happens when I have a uint32 (R32) texture and I sample/fetch from it in a shader?

Note: I distinguish sample from fetch in the title, since in my tests this behavior seems to differ between the two. Possible answers: The [0..2^32] range is scaled down to [0..1] (I think OpenGL works this way) The uint32s are casted to float32s…
Stefan Monov
  • 11,332
  • 10
  • 63
  • 120
3
votes
1 answer

How to compile hlsl shaders multiple times in visual studio?

I have HLSL shaders added to my Visual Studio project and they're getting compiled automatically to cso files as part of the build process. The problem which I'm facing is, that I need to compile them multiple times using different Shader models…
Constantin
  • 8,721
  • 13
  • 75
  • 126
3
votes
1 answer

Vertex shader compilation error from DX9 to DX11 (Unity 5.6 to 2017.4)

I have a Unity image post effect using a custom shader that throws an error when migrating from Unity 5.6 to Unity 2017.4 Assertion failed: Failed to create DX11 vertex declaration; something wrong with vertex shader input data? (hr=80070057) It…
David Coombes
  • 317
  • 1
  • 13
3
votes
2 answers

Trying to find HLSL Compiler

Googling for "HLSL compiler" and a few things, I'm frustratingly unable to find where to look for a standalone HLSL compiler for D3D9 so I can tell which lines are causing problems. I can't see anything in my SDK but perhaps it has a name I am not…
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589