projective texture matrix

okay, i’ve been working on projective texturing trying to get it working, and think i finally figured out whats going on:

instead of rotating around origin of the world as i want, it looks as if its rotating around my camera!

demo showing the funk:

uses first person controls to steer camera, as you can see, as the camera moves, so does the projective texture

the 3 coloured lines show where the depth map is being rendered from, and where it should be being projected from.

heres how i calculate the projection matrix:


static void loadTextureProjection()
	Matrix4 mBias(0.5, 0.0, 0.0, 0.0,
				0.0, 0.5, 0.0, 0.0,
				0.0, 0.0, 1.0, 0.0,
				0.5, 0.5, 0.0, 1.0);


	mBias.Set(); // set this matrix
	gluPerspective(45.0f, 1.0f, 1.0f, 4.0f);

	Matrix4 trans = light.GetTransform();
	trans.SetM(); // multiply with existing matrix (lights model view matrix)


then to render:


	camera.LookAt(); // sets cameras model view matrix

        //render my shapes here

im guessing i need some camera related matrix when producing the projective matrix? but what and in what order?

thanks in advance

light and camera transform are calculated as follows:

	transform[ 0] = right[Vector3::X];
	transform[ 4] = right[Vector3::Y];
	transform[ 8] = right[Vector3::Z];

	transform[ 1] = up[Vector3::X];
	transform[ 5] = up[Vector3::Y];
	transform[ 9] = up[Vector3::Z];

	transform[ 2] = view[Vector3::X];
	transform[ 6] = view[Vector3::Y];
	transform[10] = view[Vector3::Z];

	transform[12] = -( (position[Vector3::X] * right[Vector3::X]) + (position[Vector3::Y] * right[Vector3::Y]) + (position[Vector3::Z] * right[Vector3::Z]) );
	transform[13] = -( (position[Vector3::X] * up[Vector3::X]) + (position[Vector3::Y] * up[Vector3::Y]) + (position[Vector3::Z] * up[Vector3::Z]) );
	transform[14] = -( (position[Vector3::X] * view[Vector3::X]) + (position[Vector3::Y] * view[Vector3::Y]) + (position[Vector3::Z] * view[Vector3::Z]) );


translating by the cameras position, makes the projective texture independent of cameras position, but not the rotation, so i tried multiplying by cameras world matrix, didnt work. then i tried using the cameras model view, and that didnt either :-/

the docs on the nvidia website say i need to multiply by camera view matrix

which makes my lights rotation independent of the camera, but the lights position is still affected by moving the camera :-/

did you set eye plane with glTexGen?