PDA

View Full Version : vector to pixel


kruseborn
02-26-2009, 01:39 AM
Im am drawing a cube around a position. what i want is to get a vector from the camera(eye position) to the pixel I am drawing.

I have tried to just take the (vertex position - eye pos) in the pixel shader but that does not give the right answer, its just gives me the vector to the vertex position. In some way it is possible to get the view vector to the pixel its drawing but i cant get it to work.

Does anyone now how?

vrnunes
02-26-2009, 02:13 AM
Guess you wish the eye direction:

In the Vertex-Shader:


output.EyePosition = mul(-View._m30_m31_m32, transpose(View));
output.EyeDirection = normalize(worldPosition - output.EyePosition);


These two output fields may be declared as, lets say, TEXCOORD1 and TEXCOORD2.

kruseborn
02-26-2009, 02:57 AM
works perfectly