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

How to use Texture2DArray in HLSL DirectX11 C++

I'm just wondering how I can use Texture2DArray in HLSL. I am trying to implement a model loader where models have different amount of textures. At the moment my HLSL uses Texture2D with a size of 2 (texture and normal textures) but as my models…
user2990037
  • 397
  • 5
  • 12
6
votes
2 answers

Comparsion between Pixel Bender(in Flash) and Pixel Shaders(in Silverlight)

Can someone explain the different between Pixel Bender in Flash and Pixel Shader(HLSL) in Silverlight in terms of programming flexibility and run-time performance?
Andy Li
  • 5,894
  • 6
  • 37
  • 47
6
votes
2 answers

Applying pixel shaders to images

I would like to apply a shader effect to an image in c#/xaml. I have found this example: http://msdn.microsoft.com/en-us/library/system.windows.media.effects.shadereffect(v=vs.95).aspx Which makes applying pixel shaders to an image pretty trivial.…
Toadums
  • 2,772
  • 8
  • 44
  • 67
6
votes
2 answers

Matrix multiplication - view/projection, world/projection, etc

In HLSL there's a lot of matrix multiplication and while I understand how and where to use them I'm not sure about how they are derived or what their actual goals are. So I was wondering if there was a resource online that explains this, I'm…
meds
  • 21,699
  • 37
  • 163
  • 314
5
votes
2 answers

Standard naming convention for shaders

Is there a "best" naming convention for shaders? If not, what are the popular options? For example *.vert *.vertex *.vsh *.frag *.pixel *.fsh *.psh I dont have examples for geometry and tesselation
aCuria
  • 6,935
  • 14
  • 53
  • 89
5
votes
2 answers

2D Tile Lighting

I'm adding lighting to my XNA 2D tile based game. I found this article useful, but the way its done it does not support collision. What I'd like is a method to do the following Have always lit point Collision (If the light ray hits a block, then…
Cyral
  • 13,999
  • 6
  • 50
  • 90
5
votes
2 answers

DirectX Clip space texture coordinates

Okay first up I am using: DirectX 10 C++ Okay this is a bit of a bizarre one to me, I wouldn't usually ask the question, but I've been forced by circumstance. I have two triangles (not a quad for reasons I wont go into!) full screen, aligned to…
Jay
  • 833
  • 7
  • 15
5
votes
2 answers

Can you look sample a texture in a vertex shader?

In shader model 3.0, I'm pretty sure this was a no but I want to ask this anyway, In shader model 5.0, can you sample a texture in a vertex shader? If I want to make large amounts of supplementary information available per-vertex, what are my…
bobobobo
  • 64,917
  • 62
  • 258
  • 363
5
votes
2 answers

Writing a HLSL4 pixel shader to perform a lookup from a 2Dtexture

I'm a beginner pixel shader writer and I'm running into some trouble. I want to take a 256x256, 16-bit input (DXGI_FORMAT_R16_UINT) image, and pass it through a 256x256 look-up texture (DXGI_FORMAT_R8_UNORM) to convert it to a 256x256 8-bit…
SJoshi
  • 1,866
  • 24
  • 47
5
votes
2 answers

Pixel shader to project a texture to an arbitary quadrilateral

Just need to figure out a way, using Pixel Shader, to project a texture to an arbitary user-defined quadrilateral. Will be accepting coordinates of the four sides of a quadrilateral: /// 0,0 float2 TopLeft :…
Trainee4Life
  • 2,203
  • 2
  • 22
  • 38
5
votes
2 answers

How to set the saturation level of an entire color channel in Unity

I would like to set the saturation of an entire color channel in my main camera. The closest option that I've found was the Hue vs. Sat(uration) Grading Curve. In the background of the scene is a palm tree that is colored teal. I want the green…
Rickest Rick
  • 1,519
  • 1
  • 15
  • 28
5
votes
1 answer

Multiple Render Targets not saving data

I'm using SlimDX, targeting DirectX 11 with shader model 4. I have a pixel shader "preProc" which processes my vertices and saves three textures of data. One for per-pixel normals, one for per-pixel position data and one for color and depth (color…
Nick Udell
  • 2,420
  • 5
  • 44
  • 83
5
votes
1 answer

HLSL uniform variables vs constant buffers

What is the difference between uniforms and constant buffers? Are they completely separate or can the uniforms be seen as in a constant buffer? In other words, if you want to set a uniform, do you need a constant buffer or is there another way? I…
jnm2
  • 7,960
  • 5
  • 61
  • 99
5
votes
2 answers

Difference Between Calling numthreads and Dispatch in a Unity Compute Shader

Hypothetically, say I wanted to use a compute shader to run Kernel_X using thread dimensions of (8, 1, 1). I could set it up as: In Script: Shader.Dispatch(Kernel_X, 8, 1, 1); In Shader: [numthreads(1,1,1)] void Kernel_X(uint id :…
5
votes
1 answer

HLSL - asuint of a float seems to return the wrong value

I've been attempting to encode 4 uints (8-bit) into one float so that I can easily store them in a texture along with a depth value. My code wasn't working, and ultimately I found that the issue boiled down to this: asuint(asfloat(uint(x))) returns…
283
  • 141
  • 1
  • 9