Basic HLSL questions

ThePentiumGuy

Senior Contributor
Joined
May 21, 2003
Messages
1,113
Location
Boston, Massachusetts
hey

im tryin to learn HLSL(high level shader language)
i just have a bunch of doubts:

1) float4 Pos : POSITION <-- why do u need a ": POSITION" cant you just say POSITION Pos; ?

2)
pass P0
{
CullMode = None;

// shaders
VertexShader = compile vs_1_1 Transform();
PixelShader = NULL;
}

what's the purpose of a pass?.. why cant u just have a technique there

3)
float4x4 WorldViewProj : WORLDVIEWPROJECTION;
float Time = 1.0f;

what's the difference between:
float4, float4x4,.. well i know float ;p

4) last question:

struct VS_OUTPUT
{
float4 pos : POSITION;
float4 diff : COLOR0;
};
VS_OUTPUT Out = (VS_OUTPUT)0;

.. how dose that syntax of the last line work? why would you take "0" and convert it to a VS_OUTPUT type?

---

i used the book Managed DirectX9 Kickstart: Games and Graphics Programming
so if the code looks familiar... yeah :)


if you can help, heh, thanks
pent
 
Well heres as far as i can tell

1) I dont know why you cant say POSITION pos, but if i remember correctly the : POSITION tells it to use the information that your vertexdeclaration defines as POSITION if you add a number say POSITION1 that would be position with a usage of 1 should i remember correctly.
2) a pass is well a pass (say you wanted to render the object normally (pass 0) then go over the whole thing again and render with a glow effect (pass 1) then maybe a fire effect (dont ask why but none the less pass 2) well you get the idea a technique can call multiple passes..
3)float4 is roughly equivalent to a vector4 (its 4 float variables you can access as either .x,.y.z,.w or if im not mistaken .a,.r.g.b) a float4x4 on the other hand is more like a matrix (a 4x4 matrix at that). and im not sure exactly how you access each of the variables here though.
4)im gonna have to say im not sure here at all, because well im not.
Anyways i hopes this helps a bit.
 
thanks :)

a couple of questions about your reply:
"POSITION1 that would be position with a usage of 1 should i remember correctly."
whats a usage of 1?

and uhh - if you program in C#, a : is the same as Inherits or Implements, does it have the same meaning here?

once again, thanks
pent
 
ThePentiumGuy said:
thanks :)

a couple of questions about your reply:
"POSITION1 that would be position with a usage of 1 should i remember correctly."
whats a usage of 1?

and uhh - if you program in C#, a : is the same as Inherits or Implements, does it have the same meaning here?

once again, thanks
pent

As far as i can tell : is not inheritance/implementation (yes i now code in c#), the usage allows you to pass multiple of the same value type, like lets say a vertex has 2 texture coordinants (usage 0 and 1)...
EDIT that would be for say 2 textures (aka compleatly different coordinants just to be clear).
 
ThePentiumGuy said:
VS_OUTPUT Out = (VS_OUTPUT)0;
HLSL?

Is this a C++ Flavor/Library?

I don't do Game programming but by the looks of this, from my experience with C++, I assume it is declaring a variable of type VS_OUTPUT in the immediate scope of said type and initializing it to NULL.

but I could be wrong.
 
HLSL is... well its hard to explain ..
ive heard explanations like "Programmable Function Pipeline" <-- HLSL vs "Fixed Function Pipeline", its a different way of rendering objects and manipulating them and stuff

yeah i think you're right about VS_OUTPUT Out = (VS_OUTPUT)0;
i think it initializes the variables in that struct to their default values or somethin

pent
 
Back
Top