Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rear View Camera Matrix

Started by DJTN Jun 17, 2011 at 10:03 PM 1 replies 1.5k views
Original Post
DJTN
DJTN
What I thought would be rather simple has turned into a complicated task. I’m rendering to a surface for a reflection texture I can use like a rear view mirror in a car. The problem is my view matrix. I build it using a lookAt matrix with the camera’s position, target, and up vector. I thought I could simply invert the camera target (-camera target) when building the matrix and I’d be good to go… but I’m not, I get strange results when the camera goes from a positive X Y or Z position into a negative. As long as the camera’s position is in the positive all is well but as soon as I back out to a negative XY or Z position the reflection starts to roll and eventually ends up looking forward and not back.

Am I overlooking something?
Zakwayda
Zakwayda
It's probably the forward vector you want to negate, rather than the target point.

If you're using a 'look at' function that takes a position and a target point, you should be able to compute the adjusted target point as follows (pseudocode):

vector3 forward = target - position;
vector3 adjusted_target = position - forward;
DJTN
DJTN

It's probably the forward vector you want to negate, rather than the target point.

If you're using a 'look at' function that takes a position and a target point, you should be able to compute the adjusted target point as follows (pseudocode):

vector3 forward = target - position;
vector3 adjusted_target = position - forward;




That did it JYJK. Thanks man!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.