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

Strange behaviour of HLSL pow() function using DirectX 11

I'm programming a DX11 SM5.0 terrain hull shader along the lines of many examples such as Frank Luna's. While investigating the reason for crazy flickering of the (wireframe) terrain, I've homed in on what seems to be a problem with the pow()…
Barbarian
  • 237
  • 4
  • 9
0
votes
0 answers

Punching a hole with shader

Shader "Custom/Mask" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _ColorStrength("Color Strength", Range(1,4)) = 1 [Space(10)] …
Arcana Affinity
  • 307
  • 7
  • 18
0
votes
1 answer

SPIR-V error with InterlockedMax after upgrading to LunarG SDK 1.0.68.0

My compute shader (written in HLSL) compiled and worked with the earlier SDK 1.0.65.0. I updated to 1.0.68.0 and recompiled it, now I get this error when calling vkCreateShaderModule: Vulkan error: [SC], code: 5: SPIR-V module not valid:…
SurvivalMachine
  • 7,946
  • 15
  • 57
  • 87
0
votes
1 answer

DX10 Skybox Shader

I'm trying to write a skybox shader in DX10 using the following HLSL code: ////////////////////////////////////////////////////////////////////////// // world matrix for each rendered object float4x4 g_mWorld; // single cubemap texture Texture2D…
Simononon
  • 1
  • 1
  • 1
0
votes
1 answer

directx 11 omnidirectional shadow mapping shadow wrong projected

I code ommidirectional shadow mapping by c++ directx 11. I took algorithm from book: "HLSL Development Cookbook" by Doron Feinstein. But if my screen resolution and all dependences are different with resolution of shadow map, the shadows are in…
0
votes
1 answer

Unity / HLSL - Storing vertex position into render texture in first pass for normal calculation in second pass

I'm trying to animate large meshes representing tiles of water using the GPU. So far I managed to update "on the fly" the vertices of a mesh. I mean on the fly because the mesh isn't actually updated, it remains flat, it's just its vertices that…
Virus721
  • 8,061
  • 12
  • 67
  • 123
0
votes
1 answer

DirectX 9 HLSL Texture Sampling Issues

I'm making an application using managed directX 2.0 (which I believe is the same as DirectX9) and I'm new to HLSL, so I'm sorry if what I'm doing is idiotic. I'm writing a simple pixel shader that simply outputs a stored texture (assigned as a…
Nick Udell
  • 2,420
  • 5
  • 44
  • 83
0
votes
1 answer

Error about function Interlockedadd under RWTEXTURE2D.(HLSL)

I got a problem about intelockeded in HLSL compute shader. Here is my Code RWTexture2D TileNum:register(u0); //Texture size is same with all group size(Context->Dispantch(x,y,z)) [numthreads(32, 32, 1)]//max 1024 void main(uint3 TileIndex :…
F.Eazism
  • 43
  • 10
0
votes
1 answer

Why won't my falloff work for this dot product based spotlight?

I made a spotlight that Projects 3d models onto a render target from each light POV to simulate shadows Cuts a circle out of the square of light that has been projected onto the render target as a result of the light frustum, then only lights up…
Dude
  • 29
  • 6
0
votes
1 answer

HLSL shader doesn't work

I've made two shaders that share almost all the code except for a line that shouldn't change the result. That's the shared part of code: struct VOut { float4 position : SV_POSITION; float4 color : COLOR; float4 ld1 : LD; }; cbuffer…
0
votes
1 answer

D3DXCompileShader cannot compile shader with NORMAL in it

I noticed that the D3DXCompileShader function from the Ogre library fails in case of DirectX9 because of the following reason: error X4502: invalid vs_2_0 output semantic 'NORMAL' Seems pretty strange to me because MSDN states that it should be…
FrozenHeart
  • 19,844
  • 33
  • 126
  • 242
0
votes
1 answer

Keeping Texture2D object(s) for interpolation HLSL

Recently someone added a module to OBS Studio which lets anyone incorporate their own shaders into OBS. I've never touched on writing shaders, but after reading some material, I get the gist, it's a function that returns a bit of memory representing…
TheUnknownGeek
  • 110
  • 1
  • 10
0
votes
1 answer

How can I define an array with a large dimension in HLSL?

Is there a way to define a large array in HLSL or any alternative to this as I'm trying to move some of my calculations to the GPU. I currently have struct Buffer { float3 image[640 * 480]; }; but I am getting the error error X3059: array…
kbz
  • 984
  • 2
  • 12
  • 30
0
votes
2 answers

X3501 'main entrypoint not found'

I am having a really hard time trying to compile some shaders for a Direct X 11 tutorial I am working my way through. For some reason, even when I explicitly change the "Entrypoint name" I am still getting this message. X3501 'main entrypoint not…
user121615
  • 199
  • 1
  • 7
0
votes
1 answer

Artefact in shader for iOS

kernel vec4 custom(__sample s1, __sample s2) { if(s1.a == 0.0) return s2; if(s2.a == 0.0) return s1; vec4 res; float temp = 1.0 - s2.a; res.rgb = s2.rgb *…
Vahe Karamyan
  • 33
  • 1
  • 10