problem with billboarding, what am I doing wrong?

problem with billboarding, what am I doing wrong?

Post by Rich » Mon, 08 Oct 2007 13:43:29



Hi,

I am trying to make a quad face the camera at all times. Each of the
four vertices store the centre of the quad in TEXCOORD1 and the actual
position of the vertex is in POSITION as it normally would be. In my
vertex shader I am doing this:

float3 p = Input.Centre.xyz;
float3 q = cameraPos.xyz;
float3 l = normalize(q-p); // look
float3 r = cross(float3(0.0f,1.0f,0.0f), l); // right
float3 u = cross(l, r); // up

float4x4 m;

m[0] = float4(r, 0.0f);
m[1] = float4(u, 0.0f);
m[2] = float4(l, 0.0f);
m[3] = float4(Input.Centre.xyz, 1.0f);

float4 newPos = mul(Input.Position, m);

newPos = mul(newPos, matViewProjection);

Output.Position = newPos;

I'm not seeing anything when I do this, does anybody know what I am
doing wrong with this?

Cheers,

Richy