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
11
votes
4 answers

What kind of blurs can be implemented in pixel shaders?

Gaussian, box, radial, directional, motion blur, zoom blur, etc. I read that Gaussian blur can be broken down in passes that could be implemented in pixel shaders, but couldn't find any samples. Is it right to assume that any effect that concerns…
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
11
votes
1 answer

Bézier curves, Loop and Blinn style

A couple of days ago I started looking into efficiently drawing bezier curves, and I came across a this method developed by Charles Loop and Jim Blinn that seemed very interesting. How ever, after a lot of experimenting with their algorithm, I just…
Roliga
  • 113
  • 1
  • 6
10
votes
4 answers

Can I generate a random number inside a pixel shader?

I'm trying to write a very simple shader that adds random sparkle to applicable objects. The way I'd like to do this is by adding a random shade of white (R = G = B) to the pixel value within the pixel shader. It seems that noise() doesn't work the…
chaosTechnician
  • 1,640
  • 4
  • 18
  • 31
10
votes
2 answers

Loading a precompiled HLSL shader into memory for use with CreatePixelShader

I need to load a compiled pixel shader into memory to use with CreatePixelShader but I can't use any D3DX calls. How can I do this? (I'm using Visual Studio 2010 as my compiler and C++ as the language)
Calin Leafshade
  • 1,195
  • 1
  • 12
  • 22
10
votes
2 answers

DirectX 11 Pixel Shader What Is SV_POSITION?

I am learning HLSL for DirectX 11, and I was wondering what exactly is the SV_POSITION that is the output for a Vertex Shader, and the input for a Pixel Shader. 1: Is this x,y,z of every pixel on your screen, or of the object? 2: Why is it 4 32bit…
Mike5050
  • 625
  • 1
  • 7
  • 22
10
votes
1 answer

How to Invert Color of XAML PNG Images using C#?

I'm using Visual Studio, C#, XAML, WPF. In my program I have XAML buttons with white png icons. I want to have it so you can switch to a theme with black icons by choosing the theme from a ComboBox. Instead of creating a new set of black png…
Matt McManis
  • 4,475
  • 5
  • 38
  • 93
10
votes
2 answers

Pixel Shader Effect Examples

I've seen a number of pixel-shader effect examples, stuff like swirl on an image. But I'm wondering if anyone knows of any examples or tutorials for more practical uses of shader effects? I'm not saying that a swirl effect doesn't have it's uses,…
Chris Nicol
  • 10,256
  • 7
  • 39
  • 49
9
votes
3 answers

Pack four bytes in a float

I'm writing a shader (HLSL), and I need to pack a color value into the R32 format. I've found various pieces of code for packing a float into the R8G8B8A8 format, but none of them seem to work in reverse. I'm targeting SM3.0, so (afaik) bit…
YellPika
  • 2,872
  • 2
  • 28
  • 31
9
votes
1 answer

Storing two float values in a single float variable

I'd like to store two float values in a single 32 bit float variable. The encoding will happen in C# while the decoding is to be done in a HLSL shader. The best solution I've found so far is hard-wiring the offset of the decimal in the encoded…
ZoltanE
  • 173
  • 1
  • 7
9
votes
2 answers

HLSL mul() variables clarification

The parameters for HLSL's mul( x, y) indicated here: say that if x is a vector, it is treated as a row vector. if y is a vector, it is treated as a column vector. Does this then follow through meaning that: a. if x is a vector, y is treated as a…
dk123
  • 18,684
  • 20
  • 70
  • 77
9
votes
2 answers

What are all the different HLSL sampler types for?

I'm working with DX9/SM3 at the moment, and the MSDN documentation on HLSL samplers seems to be sorely lacking in explaining how to use the different sampler types. What's worse is they try to cover DX9 and DX10 in a single article, so they jumble…
blah
8
votes
1 answer

DirectX 11 - Compute shader: Writing to an output resource

I've just started using the Compute shader stage in DirectX 11 and encountered some unwanted behaviour when writing to an output resource in the Compute shader. I seem to get only zeroes as output which, to my understanding, means that out-of-bound…
SvinSimpe
  • 850
  • 1
  • 12
  • 28
8
votes
1 answer

HLSL: SV_Position, why/how from float3 to float4?

I'm just at the very very beginning of learning shaders/hlsl etc., so please excuse the probably stupid question. I'm following Microsoft's DirectX Tutorials (Tutorial (link) , Code (link) ). As far as I understand, they're defining POSITION as…
Bogey
  • 4,926
  • 4
  • 32
  • 57
8
votes
3 answers

Efficient pixel shader sum of all pixels

How can I efficiently calculate the sum of all pixels in an image, by using a HSLS pixel shader? I'm interested in Pixel Shader 2.0, that I could invoke as a WPF shader effect.
luvieere
  • 37,065
  • 18
  • 127
  • 179
8
votes
1 answer

error X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Invalid operand type for operand #1 of opcode #86 (counts are 1-based)

I'm absolutely stumped as well as my instructors/lab-assistants. For some reason, the following HLSL code is returning this in the output window: error X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Invalid operand type for operand #1 of…
JMazzola
  • 105
  • 1
  • 5