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

Unity Compute Shader Synchronization

I need your help today ! I begin to work with compute shader in a really simple use case : I have a depth camera and I want to calculate the bounding box of an object near to the camera. But I have too much pixel to process and I want to use GPGPU,…
4
votes
1 answer

CMAKE avoid compilation of HLSL shader files on Visual Studio

I have a DirectX11 project with CMake on Windows. The project contains (at least) three sub-projects - one is for the core 3D engine library - a common asset directory which contains all the binary data used by the test or sample apps that builds…
Caiwan
  • 73
  • 1
  • 9
4
votes
1 answer

Is it better to use one large buffer with all related data or several smaller buffers in HLSL

I interested in both a code design and performance aspect if having a separated buffers when sending data to the GPU in HLSL, or another high-level shader language, is better. This is where a particular shader needs to have a lot of variable data…
A. Yeats
  • 89
  • 2
  • 7
4
votes
1 answer

what is the difference between matrix and float4x4 in HLSL

When I define the cBuffer in hlsl, some examples shows cbuffer cbPerObject { matrix worldMatrix; matrix viewMatrix; matrix projectionMatrix; }; And the other shows cbuffer cbPerObject { float4x4 worldMatrix; float4x4 viewMatrix; …
HUAQ
  • 41
  • 5
4
votes
1 answer

GPU HLSL compute shader warnings int and uint division

I keep having warnings from compute shader compilation in that I'm recommended to use uints instead of ints with dividing. By default from the data type I assume uints are faster; however various tests online seem to point to the contrary; perhaps…
4
votes
1 answer

Dynamically compiling and running shaders from file in XNA

im wondering if its possible to dynamically compile a pixel-shader from file and apply it to a mesh. First I'll just start with some background information. I have a system which creates HLSL pixel-shaders based on a range of data which is not…
Val
  • 930
  • 6
  • 10
4
votes
1 answer

Error with short form opcodes in Reflection.Emit

I'm making a small language that is very similar to hlsl but supports only pixel shaders. This language uses reflection.emit to build .NET assemblies that implement the same functionality. I'm currently testing my implementation of the branch…
Ivo Leitão
  • 337
  • 1
  • 4
  • 16
4
votes
1 answer

D3D11: variable number of lights in HLSL

I'm working on a game engine in C++ and Direct3D11 and I want now to add a variable number lights to the scene. Up to date, I managed to add and render simple lights of a count that was already known and coded in the shader programs. In…
featherless biped
  • 163
  • 1
  • 5
  • 16
4
votes
1 answer

Why pixel shader returns float4 when the back buffer format is DXGI_FORMAT_B8G8R8A8_UNORM?

Alright, so this has been bugging me for a while now, and could not find anything on MSDN that goes into the specifics that I need. This is more of a 3 part question, so here it goes: 1-) When creating the swapchain applications specify backbuffer…
Miguel
  • 872
  • 1
  • 12
  • 26
4
votes
1 answer

understanding the basics of dFdX and dFdY

I've read numerous descriptions of the behavior of dFdX(n) and dFdY(n) and do believe I still have a handle on partial derivatives from school. What I don't follow is where does 'n' come from in the simplest possible example? Reading the glsl…
user487158
  • 460
  • 3
  • 9
4
votes
1 answer

Normal map from height map

I am trying to create a normal map from a height map in HLSL. I followed this https://stackoverflow.com/a/5284527/451136 which is for GLSL. Here is how I translated GLSL to HLSL: GLSL: uniform sampler2D unit_wave noperspective in vec2…
Deniz Cetinalp
  • 901
  • 1
  • 18
  • 34
4
votes
1 answer

glsl vector*matrix different to hlsl

I have two (identical) shaders, one in hlsl and one in glsl. In the pixel shader, I am multiplying a vector by a matrix for normal transformations. The code is essentially: HLSL float3 v = ...; float3x3 m = ...; float3 n = mul(v, m); GLSL vec3 v =…
Programmdude
  • 551
  • 5
  • 22
4
votes
1 answer

How to calculate view-space position from screen-space position without matrix multiplication

I am calculating the view-space position from the screen-space position inside of multiple light- and post-process-shaders. My current code is restoring the position using the inverse of the projection matrix: float depth =…
Jens Nolte
  • 509
  • 3
  • 15
4
votes
1 answer

Sampling a texture within vertex shader?

I'm using DirectX 11 targeting Shader Model 5 (well actually using SharpDX for directx 11.2 build) and i'm at loss with what is wrong with this simple shader i'm writing. The pixel shader is applied on a flat high poly plane (so there are plenty of…
Ronan Thibaudau
  • 3,413
  • 3
  • 29
  • 78
4
votes
1 answer

Unity Compute Shaders Vertex Index error

I have a compute shader and the C# script which goes with it used to modify an array of vertices on the y axis simple enough to be clear. But despite the fact that it runs fine the shader seems to forget the first vertex of my shape (except when…
Géry Arduino
  • 490
  • 5
  • 16