WIP: Camera transforms not working

This commit is contained in:
Vojta committed 2025-03-03 23:03:10 +01:00
1 parent 50314f1ad8
commit eba916fb81
4 files changed
+19 -5

No files matched your search

+13
View File
@@ -17,6 +17,8 @@ var exit_scale: int = 1 # This is not really needed I think
func _ready() -> void:
assert(exit_portal != null)
# Update portals last
process_priority = 1000
_main_camera = get_viewport().get_camera_3d()
# NOTE: In case the exit portal is in a different world, better put the viewport and camera
@@ -29,13 +31,24 @@ func _ready() -> void:
_camera.name = name + "_ExitCamera"
_viewport.add_child(_camera)
# FIXME: Remove this - debug only
var debug = MeshInstance3D.new()
debug.rotate_z(PI / 2)
debug.material_override = StandardMaterial3D.new()
debug.material_override.albedo_color = Color.MAGENTA
debug.mesh = PrismMesh.new()
_camera.add_child(debug)
var mat: ShaderMaterial = MY_PORTAL_MATERIAL
material_override = mat
mat.set_shader_parameter("albedo", _viewport.get_texture())
print(name, ": _ready")
func _process(delta: float) -> void:
_camera.global_transform = real_to_exit_transform(_main_camera.global_transform)
# TODO: Adjust near clip plane to the portal
_camera.near = _main_camera.near
_camera.far = _main_camera.far