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

How do constant shaders need to be padded in order to avoid a E_INVALIDARG?

I am investigating a E_INVALIDARG exception that is thrown when I attempt to create a second constant buffer that stores the information for my lights: // create matrix stack early CD3D11_BUFFER_DESC…
Nico
  • 1,181
  • 2
  • 17
  • 35
5
votes
3 answers

How to use shader constant-buffers?

tI'm struggling to understand constant buffers in DirectX. I've seen two syntaxes float4 myVar; declared at top level of the shader file and cbuffer myBuffer { float4 myVar; } as detailed on…
AnonDev
  • 172
  • 3
  • 7
5
votes
1 answer

HLSL float array packing in constant buffer?

people. I have a problem passing a float array to vertex shader (HLSL) through constant buffer. I know that each "float" in the array below gets a 16-byte slot all by itself (space equivalent to float4) due to HLSL packing rule: // C++ struct struct…
Ben Goh
  • 107
  • 1
  • 3
  • 11
5
votes
1 answer

Compute shaders, where do they fit in the pipeline?

I have been at this all day and am starting to give up on it. I can't find a lot of information on compute shaders. Best source was "Practical Rendering and Computation with Direct3D 11" and unfortunately it was not too much help. It helped me…
Prodigga
  • 1,457
  • 1
  • 22
  • 37
5
votes
1 answer

HLSL Pixel Shader - global variables?

I am new to HLSL and shaders. I can't seem to replace the color I retrieve. It's for use in 2D text, i.e. subtitles. The problem is if I set osd_color outside main() it doesn't display anything. I am using Shazzam Shader Editor 1.4 to quickly see…
siz
  • 117
  • 3
  • 9
5
votes
1 answer

Calculating world space coordinates in the pixel shader

I have a pixel shader and I want to calculate the position of each pixel in terms of my world space coordinates. How would I do this? What would I need? I have a ps_input structure which has a float4 position : SV_POSITION. I'm assuming this is…
l3utterfly
  • 2,106
  • 4
  • 32
  • 58
5
votes
2 answers

Debugging HLSL for Windows 8 application

i'm currently in the process of creating a Windows 8 applicaiton using SharpDX (the managed c# directx wrapper). However I have ran into problems with one of my shaders and I want to know if its possible to debug such applications. PIX doesn't seem…
Shervanator
  • 457
  • 1
  • 4
  • 10
5
votes
1 answer

Deferred Shading DirectX demos?

I've been reading a lot about deferred shading and want to try and get into it. Problem is I can't find a sample which demonstrates how deferred shading can support so many lights simultaneously - I found one demo which was very simple with a single…
meds
  • 21,699
  • 37
  • 163
  • 314
5
votes
1 answer

How to make Outer Glow Effect using HLSL?

In WPF OuterGlowBitmapEffect is no longer supported nor rendered by Net4.0. DropShadow has a little in common and not acceptable in my case. My initial goal is to make a white blurry background for black ClearType text upon AeroGlass window to make…
Dmitry Gusarov
  • 1,469
  • 15
  • 22
5
votes
2 answers

how to convert float to int preserving bit value

I have a float4 coming into a compute shader, 3 of these floats are really floats but the fourth is 2 uints shifted together, how would i convert the float to uint by preserving the bit sequence instead of the numeric value? on the c++ side i…
Jake Freelander
  • 1,471
  • 1
  • 19
  • 26
4
votes
2 answers

DirectX11 set shader constants

Having XNA background, I try to create a simple DirectX11 application. Now I try to figure out how to set shader constants such as projection matrix etc. I'm reading about constant-buffers - but is there no simple way to set some constants before…
Mat
  • 4,281
  • 9
  • 44
  • 66
4
votes
1 answer

HLSL tex2D() - where does the gradient come from?

When I sample a texture in a pixel shader the texture unit needs to select a mipmap based on the texture gradient around the pixel being shaded. There's a function tex2Dgrad() which allows me to supply info about the gradient manually and tex2Dlod()…
Jinstarr
  • 43
  • 1
  • 3
4
votes
2 answers

Validate HLSL file at compile time in Visual Studio

I'm looking for an easy way of detecting errors in HLSL file at program compile time from visual studio. I want to add a custom build to my shader files that compiles them and make sure the build fail if I did something stupid like referring an…
Laserallan
  • 11,072
  • 10
  • 46
  • 67
4
votes
1 answer

Compute shader float arithmetic is really inaccurate

I am currently writing a compute shader that requires a simple float multiplication of a float and a uint3, and I am getting really inaccurate results. for example, uint3(1, 2, 3) * 0.25 expected result: uint3(0.25, 0.5, 0.75) actual result:…
niv shalom
  • 93
  • 8
4
votes
1 answer

D3D : hardware mip linear blending is different from shader linear blending

I have a d3d application that renders a mip mapped cubemap in a fullscreen quad pixel shader. I stumbled on a weird behavior, and wrote the following test to illustrate the issue. This shader outputs the absolute difference between hardware mip map…
Hdlx
  • 51
  • 4