I'm assuming all the math is done with projection matrices from linear algebra, but I don't yet understand how they work, and haven't found much information on them.

What I'm mainly curious about is how after you convert the 3D stuff to 2D, how do you attribute the vision through a portal (like in game Portal)? How is that math done?

  • \$\begingroup\$ "rendering pipeline" is the term you are looking for \$\endgroup\$ – wondra Dec 13 '15 at 12:15

The transformation of coordinates is done in 3 steps.

1. World Transformation: Vertex coordinates are in relation to the origin of the mesh. To place it inside your world you have a so called world matrix, doing translation, rotation and scaling. Now your vertex coordinates are in world space.

2. View Transformation: In the next step the world space coordinates are transformed to camera space. You must note, that you are not moving the camera around, in fact you move the whole world aroung. This is done by the view matrix and the vertex coordinates are now in camera/view space.

3. Projection Transformation: Finally you project the coordinates from view space to screen Space. This matrix actually converts your 3D coordinates to screen coordinates, where they can be displayed.

As for you question on the portals: I'd guess they just render the screen a second time to a texture from the position of the "target portal". Then they use this texture for drawing the ellipse on the wall.

Click here for more information

  • \$\begingroup\$ Link does not work, quotation mark at the end of it which does not belong there :p Besides that +1 \$\endgroup\$ – RdeGier Dec 13 '15 at 12:54
  • \$\begingroup\$ Portal rendering isn't render to texture it actually just recursivly renders scene and uses stencil buffer for round portal opening. \$\endgroup\$ – Steven Dec 13 '15 at 16:31
  • \$\begingroup\$ @Steven Rendering to texture and recursive rendering is pretty much the same I think. \$\endgroup\$ – LukeG Dec 13 '15 at 21:15
  • \$\begingroup\$ @lukeg not true. The recursive rendering I am referring to is recursion into the scene data. While we don't know exactly what Valve did this discription of a unity clone tells all : algoholic.eu/unity3d-indie-free-portal-effect-project-sources \$\endgroup\$ – Steven Dec 13 '15 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.