I'm having problems creating an in-game video monitor that renders the view from an in-game camera. The screen of the in-game monitor is rendered with a "mask" shader which cuts a hole in the geometry, allowing the camera feed to be rendered behind the level geometry. I then tamper with the camera's projection matrix to scale, translate and distort it - just like photoshop's "free transform" command - so that it fits correctly behind the in-game monitor when viewed from any angle.
After much testing, I've learned that it IS possible, but the math has me beat. I can perform all the necessary transformations by individually tweaking the values of the camera matrix in the editor so that it fits the in-game monitor, but can't figure out how to write a script that will correctly adjust the projection matrix in real time. At the moment I can only translate and scale the camera output correctly in real time. I am not adjusting the view rect, only the projection matrix.
Obviously, I don't own Unity PRO, and can't use a render texture.
So... How do I use the viewport points of the in-game monitor to correctly distort the in-game video camera's projection matrix so that it conforms to the in-game monitor?
asked Dec 13 '10 at 01:58 AM