I'm trying to add portals to a game (as in the entities from the Portal video game), and I've gotten them to a render the other portal's pos/dir to a texture which I can then display on a surface. However, I'm not really sure which direction to render the portal view from so that it'll actually look like a portal. Simply rotating the camera dir by the difference between the portal dirs isn't correct.

  • \$\begingroup\$ You need to move the second camera as if it was inside the wall of the second portal. And then you need to somehow get a near clipping plane that is aligned with said wall. This is how it was done in the portal games. This is a very simplified explanation though \$\endgroup\$ – Daniel Holst Jul 4 '15 at 7:16
  • \$\begingroup\$ ^^ the camera needs to have the same relative position to its portal, as the relative position from the player and the first portal. If that makes sense \$\endgroup\$ – Daniel Holst Jul 4 '15 at 7:18
  • \$\begingroup\$ That doesn't make much sense, but where do I point the camera in that scenario, still? If I just let it turn directly with me, won't I just see the floor floating above the void when I'm at any distance? \$\endgroup\$ – Asunaya Jul 4 '15 at 10:11
  • \$\begingroup\$ Use the portal as temporary origin and get the camera position and orientation. That done, use the second portal and apply the same transformation to place the camera. As Daniel suggested the camera should be placed "inside" the wall so actually normal of the first portal in case of second is pointing into the wall. \$\endgroup\$ – rostok Jul 4 '15 at 11:39
  • \$\begingroup\$ The only way the "inside the wall" thing makes sense to me is if the way you're doing it is to render from the portal view you described, and then render the world from the normal cam, overwriting everything from the first render except the rectangular outline where the portal would be peering into. That's not the way I'm doing it ATM, but would that be easier? \$\endgroup\$ – Asunaya Jul 4 '15 at 12:51

Your Answer

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

Browse other questions tagged or ask your own question.