io12 / godot-portal-demo

Experimenting with portals in Godot Engine

Home Page:https://io12.github.io/godot-portal-demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Experimenting with portals in Godot Engine

https://io12.github.io/godot-portal-demo/

License:MIT License


Languages

Language:GDScript 98.6%Language:GLSL 1.4%