From a23c2e7da774f5134afc5e4a16501cb675c31db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Struh=C3=A1r?= Date: Wed, 12 Feb 2025 14:21:19 +0100 Subject: [PATCH] Tonemapping fix --- level_3_rooms.tscn | 10 +++++++++- portal_environment_adapter.gd | 17 +++++++++++++++++ portal_environment_adapter.gd.uid | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 portal_environment_adapter.gd create mode 100644 portal_environment_adapter.gd.uid diff --git a/level_3_rooms.tscn b/level_3_rooms.tscn index 391e4ab..b2ef611 100644 --- a/level_3_rooms.tscn +++ b/level_3_rooms.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://27pb62xwsqd8"] +[gd_scene load_steps=12 format=3 uid="uid://27pb62xwsqd8"] [ext_resource type="MeshLibrary" uid="uid://bedqgubx1g1uf" path="res://prototypes.tres" id="1_mqqdr"] [ext_resource type="Script" uid="uid://d2bvvjsibau8c" path="res://addons/simple-portal-system/scripts/portal.gd" id="2_b14t7"] @@ -6,6 +6,7 @@ [ext_resource type="PackedScene" uid="uid://cgdlowfuuorvi" path="res://player.tscn" id="3_b0o0q"] [ext_resource type="Script" uid="uid://bkv7t4hw21byg" path="res://addons/simple-portal-system/scripts/simple_portal_teleport.gd" id="4_snwvi"] [ext_resource type="PackedScene" uid="uid://b5x7fmpwck335" path="res://hud.tscn" id="6_phjvl"] +[ext_resource type="Script" uid="uid://cili3lyodjqel" path="res://portal_environment_adapter.gd" id="7_xcmjo"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_b0o0q"] sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1) @@ -17,6 +18,8 @@ sky_material = SubResource("ProceduralSkyMaterial_b0o0q") [sub_resource type="Environment" id="Environment_snwvi"] background_mode = 2 sky = SubResource("Sky_cgnft") +tonemap_mode = 3 +tonemap_exposure = 1.5 glow_enabled = true [sub_resource type="BoxShape3D" id="BoxShape3D_cgnft"] @@ -97,3 +100,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 3, 3) light_color = Color(0.887552, 0.489512, 0.22965, 1) light_energy = 3.0 omni_range = 4.0 + +[node name="PortalEnvironmentAdapter" type="Node" parent="." node_paths=PackedStringArray("base", "portals")] +script = ExtResource("7_xcmjo") +base = NodePath("../WorldEnvironment") +portals = [NodePath("../Portal_red"), NodePath("../Portal_orange")] diff --git a/portal_environment_adapter.gd b/portal_environment_adapter.gd new file mode 100644 index 0000000..3e4c0e8 --- /dev/null +++ b/portal_environment_adapter.gd @@ -0,0 +1,17 @@ +extends Node + +## Fixes the tonemapping being applied twice when looking through a portal. +## +## It copies the original environment (sky and stuff) and just puts in a noop +## tonemapping (linear with exposure 1). + +@export var base: WorldEnvironment +@export var portals: Array[Portal] = [] + +func _ready() -> void: + var adapted_env: Environment = base.environment.duplicate(false) + adapted_env.tonemap_mode = Environment.TONE_MAPPER_LINEAR + adapted_env.tonemap_exposure = 1 + + for p in portals: + p.exit_environment = adapted_env diff --git a/portal_environment_adapter.gd.uid b/portal_environment_adapter.gd.uid new file mode 100644 index 0000000..2497279 --- /dev/null +++ b/portal_environment_adapter.gd.uid @@ -0,0 +1 @@ +uid://cili3lyodjqel