Ok ok I admit, I'm bored and toying with a portal script like the one on steam.
I've figured out the following:
- relative positioning of the mirrored cameras
- render to texture for the portal (the texture is the view from the opposite camera)
- poly culling (since the camera is behind the other portal, I cull all polys behind the front face of the portal
I can't figure out how to scale the projection so I ignore everything outside of the back of the portal. Here's a picture to explain.
The back of portal 2, which is viewed from camera 2, is being displayed on the front of portal 1. My problem is the scale. I want to ignore everything around the dotted line and scale up the view from cam 2 so it fits the front of portal 1 perfectly. One big problem with that scaling is the perspective changes as you move around. I'm not good at matrix math to figure this out. Anyone have an idea?
I'm looking for some matrix I can set as the projection matrix for cam2 to make this work.
No comments:
Post a Comment