Noise-driven fire light rig with bounce, core, embers and glow

This commit is contained in:
enne2
2026-10-11 02:26:08 +02:00
parent e15deef84f
commit 70c82df450
11 changed files with 440 additions and 22 deletions
+11 -18
View File
@@ -1,9 +1,8 @@
extends Node3D
## Sparse office props and bounded fire animation; Web/Compatibility safe.
const FIRE_MIN := 1.9
const FIRE_MAX := 2.8
## Sparse office props; the fire itself is a reusable rig in scripts/fire_light.gd.
const FireLight = preload("res://scripts/fire_light.gd")
var fire_light: OmniLight3D
var _time := 0.0
var fire_rig: Node3D
func _ready() -> void:
name = "OfficeAtmosphere"
@@ -150,17 +149,11 @@ func _barrel(pos: Vector3) -> void:
fire.mesh = quad
fire.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
barrel.add_child(fire)
fire_light = OmniLight3D.new()
fire_light.name = "BarrelFireLight"
fire_light.position = Vector3(0, 1.5, 0)
fire_light.light_color = Color(1, 0.36, 0.07)
fire_light.light_energy = (FIRE_MIN + FIRE_MAX) * 0.5
fire_light.omni_range = 10
fire_light.shadow_enabled = true
barrel.add_child(fire_light)
func _process(dt: float) -> void:
_time += dt
# Smooth, deterministic, bounded flicker: no per-frame random flashes.
var wave := 0.5 + 0.3 * sin(_time * 7.1) + 0.2 * sin(_time * 11.7 + 1.2)
fire_light.light_energy = lerpf(FIRE_MIN, FIRE_MAX, wave)
# Rig: noise-driven main light (the only shadow caster), fake-GI bounce light,
# hot core light and floating embers. The flame follows the same signal.
fire_rig = Node3D.new()
fire_rig.set_script(FireLight)
fire_rig.position = Vector3(0, 1.5, 0)
barrel.add_child(fire_rig)
fire_rig.attach_flame(fire)
fire_light = fire_rig.main_light