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

DirectX11 and packetoffset

Does anyone know how to use "packetoffset" with a bool type in DirectX10/11? I am not sure how this should be aligned cbuffer SomeBuffer : register( b1 ) { float3 SomeFloat3: packoffset(c0); float SomeFloat: packoffset(c0.w); float3…
jack
  • 562
  • 1
  • 11
  • 22
3
votes
1 answer

HSLS float1,..., float4 and its fields

I see that HSLS has float and a number after float (1-4) and a lot of fields (r, rr, rrrr, arar,...) (I see these fields with the help of HLSL Tool Thanks to Tim Jones :D - I can't imagine (for now) how can we programming HSLS without this tool). I…
123iamking
  • 2,387
  • 4
  • 36
  • 56
3
votes
2 answers

Convert DXBC to DXIL (DirectX Bytecode to DirectX Intermediate Language)

Microsoft's open source DirectX Shader Compiler describes the format of a new intermediate language (IL) for HLSL shaders called DXIL. The documentation makes reference to a converter from the previous HLSL IL, called DXBC, to the new DXIL:…
Kerry Seitz
  • 43
  • 1
  • 6
3
votes
1 answer

Is there any way to attach metadata to HLSL global (uniform/constant) variables?

I would like to know if there's any way I can attach application-specific metadata to my global variables in HLSL shaders. I know that HLSL supports annotations on global variables, but I can't find any way of reading those annotations (presumably…
Walt D
  • 4,491
  • 6
  • 33
  • 43
3
votes
0 answers

Gamma function in shaders

Using spherical harmonics for lighting I faced a problem for a big enough bandwidths. The correctness of an approximation by first n^2 terms became worse and worse starting from n=7. I look into associated Legendre polynomials definition and found…
Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
3
votes
1 answer

HLSL error X3086: DX9-style 'compile' syntax is deprecated in strict mode

Hey, I get this error: error X3086: DX9-style 'compile' syntax is deprecated in strict mode When compiling a directx effect with this code: hr=D3DX11CompileFromFile( TEXT("shaders\\basic.fx"), NULL, NULL, NULL,"fx_5_0", D3DCOMPILE_ENABLE_STRICTNESS,…
Mark
  • 2,082
  • 3
  • 17
  • 30
3
votes
1 answer

Array length in HLSL?

I can't find any docs or examples on how to get the length of an array in HLSL. I push an array of lights to an hlsl shader and I want to do a for(int i=0; i
Spectraljump
  • 4,189
  • 10
  • 40
  • 55
3
votes
1 answer

How to make Unity glass shader only refract objects behind it?

I am looking for a glass shader for Unity that only refracts the objects behind it, or ideas for how to modify an existing glass shader to do that. This screenshot shows what happens when I use FX/Glass/Stained BumpDistort on a curved plane mesh. …
Mike
  • 963
  • 4
  • 16
  • 38
3
votes
2 answers

Rendering depth in HLSL

Hi folks this should be an easy task but for some reason I do not get it worked out... I just want to get a visualization of the depth in my scene using a shader: float4x4 matViewProjection; float4x4 matWorld; float4 eyePos; struct VS_OUTPUT { …
SideEffect
  • 401
  • 3
  • 5
  • 10
3
votes
1 answer

Shader linkage error/mismatch

I'm working on dynamic cubemap rendering. In particular, to render the cubemap I'm using a shader from the DirectX SDK sample "CubeMapGS". The shader seems correct, as you can see here: SamplerState ss; Texture2D tex; cbuffer Constants { …
StrG30
  • 670
  • 1
  • 10
  • 20
3
votes
2 answers

Pixel shader always returning white

I have a pixel shader that tries to return a static colour float4 PPBright(PS_POSTPROCESS_INPUT ppIn) : SV_Target { return (1.00f, 0.00f, 0.00f, 1.0f); } no matter the colour values it returns white, I can change the alpha values and it affects…
Salah Alshaal
  • 860
  • 2
  • 17
  • 41
3
votes
1 answer

HLSL Get number of threadGroups and numthreads in code

my question concerns ComputeShader, HLSL code in particular. So, DeviceContext.Dispath(X, Y, Z) spawns X * Y * Z groups, each of which has x * y * z individual threads set in attribute [numthreads(x,y,z)]. The question is, how can I get total number…
Ilia
  • 331
  • 5
  • 12
3
votes
1 answer

HLSL: Using arrays inside a struct

I came across a weird behavior of HLSL. I am trying to use an array that is contained within a struct, like this (Pixel Shader code): struct VSOUT { float4 projected : SV_POSITION; float3 pos: POSITION; float3 normal :…
Karel Petranek
  • 15,005
  • 4
  • 44
  • 68
3
votes
0 answers

How to apply a postprocess effect to a UI element

I have a post-process effect that uses Unity's Graphics.Blit to pixelate or apply a crt-screen effect to a scene. There are some UI elements that display after the fact (basically making it not a true post process, but let's put that aside for a…
Aaron Hull
  • 422
  • 4
  • 16
3
votes
1 answer

How to write a custom shader in Unity 3D that lights up a specific pixel or group of pixel?

I'm making a FPS game in Unity, and I want the environment to light up as the player is shooting on his environment. So say I have a tree. First it would be entirely black or greyish, but if I shoot somewhere, I would see some green. To accomplish…
David
  • 69
  • 6