Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Godot 4+ specific ignores
.godot/

# Godot-specific ignores
.import/
export.cfg
export_presets.cfg

# Imported translations (automatically generated from CSV files)
*.translation

# Mono-specific ignores
.mono/
data_*/
mono_crash.*.json
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2019 Benjamin Levy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2019 Benjamin Levy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
96 changes: 48 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
# Godot Portal Demo

Experimenting with portals in Godot Engine

[Web build](https://io12.github.io/godot-portal-demo/)

![screenshot](screenshot.png)

## 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](https://github.com/godotengine/godot-proposals/issues/2713)
and [stencil buffering](https://github.com/godotengine/godot/issues/23721), 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.
# Godot Portal Demo
Experimenting with portals in Godot Engine
[Web build](https://io12.github.io/godot-portal-demo/)
![screenshot](screenshot.png)
## 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](https://github.com/godotengine/godot-proposals/issues/2713)
and [stencil buffering](https://github.com/godotengine/godot/issues/23721), 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.
14 changes: 7 additions & 7 deletions addons/editor_camera_provider/plugin.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[plugin]

name="Editor Camera Provider"
description="Allow tool-mode scripts access to the editor's camera"
author=""
version=""
script="plugin.gd"
[plugin]
name="Editor Camera Provider"
description="Allow tool-mode scripts access to the editor's camera"
author=""
version=""
script="plugin.gd"
10 changes: 5 additions & 5 deletions addons/editor_camera_provider/plugin.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tool
@tool
extends EditorPlugin

var _camera: Camera
var _camera: Camera3D


func _enter_tree() -> void:
Expand All @@ -12,14 +12,14 @@ func _enter_tree() -> void:

# warning-ignore:unused_argument
func handles(obj: Object) -> bool:
return true
return true


# warning-ignore:unused_argument
func forward_spatial_gui_input(camera: Camera, event: InputEvent) -> bool:
func _forward_3d_gui_input(camera: Camera3D, event: InputEvent) -> int:
_camera = camera
return false


func get_camera() -> Camera:
func get_camera_3d() -> Camera3D:
return _camera
32 changes: 16 additions & 16 deletions assets/icon.png.import
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/icon.png-b6a7fb2db36edd3d95dc42f1dc8c1c5d.stex"
type="CompressedTexture2D"
uid="uid://ep3bjewwbuc8"
path="res://.godot/imported/icon.png-b6a7fb2db36edd3d95dc42f1dc8c1c5d.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/icon.png"
dest_files=[ "res://.import/icon.png-b6a7fb2db36edd3d95dc42f1dc8c1c5d.stex" ]
dest_files=["res://.godot/imported/icon.png-b6a7fb2db36edd3d95dc42f1dc8c1c5d.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/hdr_compression=1
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading