Tonemapping fix

This commit is contained in:
Vojtěch Struhár 2025-02-12 14:21:19 +01:00
parent 6d50a76cff
commit a23c2e7da7
3 changed files with 27 additions and 1 deletions

View File

@ -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")]

View File

@ -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

View File

@ -0,0 +1 @@
uid://cili3lyodjqel