Jump to content


vector to pixel


2 replies to this topic

#1 kruseborn

    Member

  • Members
  • PipPip
  • 33 posts

Posted 26 February 2009 - 09: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?

#2 imerso

    Senior Member

  • Members
  • PipPipPipPip
  • 428 posts
  • LocationBrasil

Posted 26 February 2009 - 10: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.

#3 kruseborn

    Member

  • Members
  • PipPip
  • 33 posts

Posted 26 February 2009 - 10:57 AM

works perfectly





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users