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

Normalizing a vector error in HLSL

I have completely re-written this first post to better show what the problem is. I am using ps v1.4 (highest version I have support for) and keep getting an error. It happens any time I use any type of function such as cos, dot, distance, sqrt,…
Frobot
  • 1,224
  • 3
  • 16
  • 33
2
votes
0 answers

Holodeck effect: Surface shader only partially blocking surfaces behind it?

I am attempting to write a cubemap shader that can be applied to any geometry, with the goal to create a Holodeck-like effect. This shader would be applied to the walls/floor/ceiling of a room, and give the appearance that the room is much bigger…
Zoop
  • 965
  • 1
  • 13
  • 24
2
votes
1 answer

glsl member-wise ?: operator

does glsl support ?: on vectors, like this: // hlsl half3 linear_to_sRGB(half3 x) { return (x <= 0.0031308 ? (x * 12.9232102) : 1.055 * pow(x, 1.0 / 2.4) - 0.055); } I tried like this (via glm), not working as expected (i don't think they are…
21k
  • 391
  • 5
  • 16
2
votes
1 answer

AppendStructuredBuffer count not matching the appends I make (Unity3D, HLSL)

I am using a compute shader to populate a Unity Terrain with trees. However, I am facing issues with the AppendStructuredBuffer. What I want to do, is let a probability check determine if a tree should be spawned or not. If not, then I return,…
Danahi
  • 98
  • 1
  • 11
2
votes
0 answers

Incorrect positions in deferred shading in DirectX

I'm currently working on a Deferred shading project in DirectX. I noticed weird lighting when I create the final image; With this light ray constantly shining from the top left. I looked at my gbuffers and noticed that my position only seems to…
Charlie.Q
  • 43
  • 6
2
votes
1 answer

Mapping a vector to a structuredbuffer gives incorrect values in computeshader

I have a structuredbuffer in a computeshader which is supposed to hold information about several lights, pos, direction, colour, etc. I have managed to get the info into the computeshader, but the values are incorrect. A float4(1.0, 0.0, 0.0, 1.0);…
2
votes
1 answer

How to step through 3D noise for volume textures?

I'm creating volume textures for volumetric ray marching (Creating this with Unity and a fragment shader) Example I have depth value that increases the starting position on the x, y or z axis. Doing this additivley, results in an ulgy side view…
2
votes
1 answer

Sprite outline effect appears one frame later

So, I have the following problem in a Unity 2019.4.36f1 fresh project. I would like to outline group of sprites with the Built-in render pipeline. For this, the developer needs to collect the SpriteRenderers it would like to group together. Then the…
Menyus
  • 6,633
  • 4
  • 16
  • 36
2
votes
1 answer

Build pixel shader project in VS2022

I have an old class library project that was building fine in a previous version of Visual Studio (2017 IIRC). The project contains an HLSL-based pixel shader that generates a radial color picker. I have just ported it to VS2022 and it is no longer…
dotNET
  • 33,414
  • 24
  • 162
  • 251
2
votes
1 answer

What's the GLSL equivalent of [[vk::binding(0, 0)]] RWStructuredBuffer in a compute shader

I have this HLSL and I want to write the equivalent in GLSL. If it's any use, I'm trying to run this example https://github.com/mcleary/VulkanHpp-Compute-Sample [[vk::binding(0, 0)]] RWStructuredBuffer InBuffer; [[vk::binding(1, 0)]]…
Logos King
  • 121
  • 1
  • 6
2
votes
0 answers

Are HLSL loops broken?

I've been messing around with HLSL and Direct3D12 and encountered something strange. Here's a minimal reproducible example: float4 main() : SV_TARGET { uint indices[3]; indices[0] = 0; uint l = 0; [loop] while (true) { if…
BubLblckZ
  • 434
  • 4
  • 14
2
votes
1 answer

An array of Texture3D's in DirectX?

There is Texture2DArray in HLSL, but is there any workaround for an array of Texture3D's in HLSL/DirectX?
2
votes
1 answer

HLSL print function while run the code for unity shader compute

i use HLSL for shaders in unity games and i need to print some values and the HLSL dont have console or something like console ,because it is run from unity compute shaders. so How i can print the Values in HLSL.
kareem alkoul
  • 739
  • 6
  • 13
2
votes
1 answer

CMake: How to make add_custom_command trigger a custom command only when its dependencies are changed?

I have certain files (.hlsl) in one of my targets that are compiled using a custom compiler (glslc). After compilation, I use a different tool to embed the compiled binary in a c-file containing c-array like described here. This workflow is…
Elad Maimoni
  • 3,703
  • 3
  • 20
  • 37
2
votes
1 answer

Reading data from RWTexture2D in compute shader Unity

I'm learning compute shader with Unity, but I've encountered a bug when transferring RenderTexture to the compute shader. Basically, there're 2 texture being transferred, renderTexture and copyTex. The steps are as follow: copyTex copy from…
silverfox
  • 1,568
  • 10
  • 27