Questions tagged [hlsl]

A proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API.

The High Level Shading Language (HLSL) is a proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API. It is analogous to the GLSL shading language used with the OpenGL standard. It is the same as the Nvidia Cg shading language, and it was developed alongside it.

655 questions
22
votes
1 answer

What does ddx (hlsl) actually do?

I'm a bit confused. The official documentation (http://msdn.microsoft.com/en-us/library/windows/desktop/bb509588(v=vs.85).aspx) says that ddx(input) is the partial derivative of the input with respect to the "screen-space x-coordinate." My calculus…
Richard Rast
  • 385
  • 1
  • 2
  • 10
2
votes
2 answers

Transform coordinates in vertex shader or in geometry shader?

Currently I have a vertex shader which just passes the coordinates to the geometry shader and a geometry shader which does some sort of tessellation. Now I also want to transform my model with a 4x4 matrix before applying the tessellation. I could…
Roman Reiner
  • 318
  • 1
  • 2
  • 10
1
vote
0 answers

Using custom functions in HLSL shaders generates extra insructions?

We use forward rendering so our main shader is pretty big (342 instructions). Recently I tried substituting every single custom function I call in the shader with the actual code from that function and the number of instructions generated dropped…
cubrman
  • 1,551
  • 1
  • 18
  • 31
1
vote
1 answer

What does [dynamic] do in HLSL

Here's an example (this if() is inside of a for loop, which itself has the [unroll] attribute): [dynamic] if (n.x > 1.0f || n.x < -1.0f || n.y > 1.0f || n.y < -1.0f || n.z < 0.0f || n.z > 1.0f) { break; } I've never seen this before, but I…
1
vote
1 answer

Weird member of float4 structure in the HLSL

I have encountered a weird x.wwww component of the float4 x vector in a HLSL code. I haven't seen such a member or member function of float4 structures in HLSL, so please tell me what is the meaning of that. It is in the code of this pixel…
Pekov
  • 157
  • 6
0
votes
1 answer

Difficulties in converting RGBA to float and back

I can't get my colors back. What I'm using to encode/decode: static const float Scale = 255.0f;//or 256 not working either static const float Scale2 = Scale*Scale; static const float Scale3 = Scale2*Scale; static const float Scale4 =…
philB
  • 129
  • 8
0
votes
1 answer

Initializing a global variable array once for a shader without using CPU code to populate the array

I know I can initialize arrays via code written in C++, etc. to set arrays in a shader. What I want to know is if I can initialize the array in HLSL code instead. For example: float3 myArray[64] = InitializeFunction(); Is this possible? I've tried…
jjxtra
  • 127
  • 8
0
votes
1 answer

HLSL Shader help

I'm trying to go over some Shader code at my university, I have forgotten it, and well, Its really confusing, The documentation we have been given is really difficult to read. Also is there any good beginner tutorials In HLSL that can walk me…
RNewell122
  • 324
  • 2
  • 18
0
votes
1 answer

HLSL identity matrix multiplication not producing identical output

I'm debugging my very simple shader and it's led me to a point where, as a quick test, I'm performing a multiplication of my position vector with an identity matrix. If I don't perform this multiplication, my position is preserved and I get a…
Nathan Ridley
  • 389
  • 5
  • 14