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

HLSL Point Light shader causing tiles to be shaded separately

I've recently started learning HLSL after deciding that I wanted better lighting than what BasicEffect offered. After going through many tutorials, I found this and decided to learn from…
Merigrim
  • 846
  • 10
  • 18
4
votes
2 answers

Any way to obtain percentage coverage of fragment (pixel) by primitive in hlsl/glsl fragment shader?

When the rasterizer invokes on primitive it split it into the collection of fragments (pixels). Next, the fragment shader called for every obtained pixel. Is there any way for me to have additional float parameter in my fragment shader, that will…
Crabonog
  • 423
  • 3
  • 12
4
votes
1 answer

Unity shader warning when not adding _Stencil properties

I'm writing a custom shader for Unity 2019.3.13f1 that is just a simple UI gradient. This shader does not (need to) do anything with the stencil buffer, so I set the Stencil to always pass statically: Stencil { Ref 0 Comp Equal Pass…
Remy
  • 4,843
  • 5
  • 30
  • 60
4
votes
1 answer

hlsl CG compute shader Race Condition

I'm trying to transform a texture to the frequency domain via a compute shader in unity/CG/hlsl, i.e. I'm trying to read pixel values from a texture and output an array of basis function coefficients. how would i go about that? i am really new to…
AverageGatsby
  • 43
  • 1
  • 3
4
votes
1 answer

HLSL : multi pass shader?

I'm writing a shader that make a blur effect on a texture rendered form the scene. I need to do that in 2 passe, so with the pass P0 i make a horizontal blur, and in pass P1 the vertical one. The problem is: How i can get the output from the PS on…
user714921
  • 43
  • 1
  • 3
4
votes
1 answer

How to work with 8-bit char data in HLSL?

I'm converting some OpenCL code to DirectCompute and need to process 8-bit character strings in a compute shader but don't find an HLSL data type for "byte" or "char". OpenCL supports a "char" type, so I was expecting an equivalent. What is the best…
4
votes
2 answers

HLSL: problematic pixelshader code (alpha at zero when sampling)?

I have this strange problem with the sampler in the pixel shaders. When I sample from a sampler into an empty float4 variable I always get black/transparent color back. So if I use this I get a black screen: float4 PixelShaderFunction(float2…
Marino Šimić
  • 7,318
  • 1
  • 31
  • 61
4
votes
2 answers

Is there a HLSL minifier like there are Javascript minifiers?

Is there a HLSL packer/minifier? (And a wish of potentially enhancing the performance of the shader?)
Neil Knight
  • 47,437
  • 25
  • 129
  • 188
4
votes
1 answer

Which texture slot should be used to start where I need 7th and 8th slot together among 0 to 8 index of 9 resources

I have total 9 texture resources among them I need 2 resources together for a pixel shader. In that case what should be the texture slot start index if I need the 7th and 8th texture resources only. (e.g. Texture2D foo1 : register(t7) and Texture2D…
4
votes
1 answer

DX9 style intristics are disabled when not in dx9 compatibility mode?

I am currently writing an HLSL shader for a basic Gaussian blur. The shader code is straight forward, but I keep getting an error: DX9 style intristics are disabled when not in dx9 compatibility mode. (LN#: 19) This tells me that line 19 in my…
Hazel へいぜる
  • 2,751
  • 1
  • 12
  • 44
4
votes
2 answers

DirectX HLSL Include Directive Doesn't Work

The document: http://msdn.microsoft.com/en-us/library/dd607349(v=vs.85).aspx states that #include "foobar.fx" will look for that file in the same directory as the current effect file. It doesn't work, but using an absolute path does, which is of…
Tony
  • 417
  • 4
  • 11
4
votes
0 answers

Object-To-Clip for Unity Canvas Image Shader

The TL;DR When applying a shader to a UI.Image object in a Unity3D canvas, UNITY_MATRIX_MVP appears to be relative to the Canvas renderer, and not the Image object itself being drawn. Is there a way to compute clip-space coordinates of a point in…
Johannes
  • 6,232
  • 9
  • 43
  • 59
4
votes
1 answer

What exactly is a constant buffer (cbuffer) used for in hlsl?

Currently I have this code in my vertex shader class: cbuffer MatrixBuffer { matrix worldMatrix; matrix viewMatrix; matrix projectionMatrix; }; I don't know why I need to wrap those variables in a cbuffer. If I delete the buffer my code works…
IOSporgrammerIOS
  • 223
  • 4
  • 12
4
votes
1 answer

How do I launch the HLSL debugger in Visual Studio 2017?

I cant find the option to launch the HLSL Debugger in Visual Studio 2017. The Microsoft document instructs to launch it from Graphics Pipeline Stages window or Graphics Pixel History https://msdn.microsoft.com/en-us/library/hh873197.aspx However,…
Mich
  • 3,188
  • 4
  • 37
  • 85
4
votes
1 answer

HLSL #pragma once equivalent?

What's the equivalent to C/C++-like #pragma once in HLSL includes? I want (as a contrived example): // ./dependency.hlsl float x() { return 0; } // ./shader.hlsl #include "./dependency.hlsl" // (./ unnecessary; for question readability) #include…
Warty
  • 7,237
  • 1
  • 31
  • 49