Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 1.44 KB

README.md

File metadata and controls

48 lines (34 loc) · 1.44 KB

Godot Portal Demo

Experimenting with portals in Godot Engine

Web build

screenshot

Controls

WASD or arrow keys to move, E to pick up cube

Issues

This implementation has several issues that need to be fixed before the portals can be fully seamless. To fix all of them, Godot needs support for custom projection matrices and stencil buffering, which it doesn't have yet.

  • Rendering
    • Oblique near-plane frustum for portal cameras
    • Fix performance with stencil buffering
    • Lighting through portals
    • Portal camera FOV sync with player FOV
    • Portal dynamic updating in editor (optional, but nice)
  • Physics
    • Seamless first-person player teleportation
    • Fix holding RigidBody through portal
    • Collision masking for objects behind portal

How it works

The full details are in the code, but basically, the portals behave as described below.

Rendering

Each portal has a camera attached to it, mapped to a ViewportTexture on the linked portal. These cameras move based on the player position such that angles look realistic.

Physics

When a RigidBody overlaps the portal, it creates a clone at the other portal. The clone and real object swap once the real object's center goes behind its portal. This allows somewhat-seamless object teleportation.