itch.io is community of indie game creators and players

Devlogs

Working on Portals : 2 : Fixing Portal Blindness

2d Portal Demo
A browser demo made in HTML5

The portals have a problem: They blind you when you enter them.

Clipped View :(

Why does this happen? The portals are fine until you're right up in them:

It's because of the way the PortalViewer samples the portals. It does raycasts from it to the portal surface to tell if there's any walls in the way. The positions of these raycasts are , say 1/10 from one edge of the portal to the other, 2/10 of the way, 3/10, 4/10, etc., all the way until the other edge of the portal. (by 'edge', I mean from, say, in a door, the hinge to the doorknob). That explains why it clips the end of the room off. When it is right close to the door, all the raycasts are off to one side or the other, with none going forwards.

The proper way to position the raycasts is for the PortalViewer to get the angles from one side to the other, and iterate over 1/nth of that angle each time.

Leave a comment