Skip to content

Commit 2869084

Browse files
committed
Added colour flashes to sphere
1 parent 4bbecb0 commit 2869084

4 files changed

Lines changed: 39 additions & 6 deletions

File tree

misc/hdr_output/main.tscn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,12 @@ size = Vector2i(350, 350)
473473

474474
[node name="Node3D" parent="DemoScenes/DemoScene_output_max_linear_value/SubViewport" unique_id=1416688204 instance=ExtResource("8_ycdy4")]
475475

476+
[node name="Sprite2D2" type="Sprite2D" parent="DemoScenes/DemoScene_output_max_linear_value" unique_id=1284238580]
477+
visible = false
478+
position = Vector2(210, 250)
479+
scale = Vector2(1.36, 3.48)
480+
texture = SubResource("GradientTexture2D_cegan")
481+
476482
[node name="ViewportSprite" type="Sprite2D" parent="DemoScenes/DemoScene_output_max_linear_value" unique_id=234860266]
477483
position = Vector2(207, 248)
478484
texture = SubResource("ViewportTexture_efxa6")

misc/hdr_output/output_max_linear_value/3d_scene.tscn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ albedo_color = Color(0.37021315, 0.17127198, 0.10240973, 1)
1818

1919
[node name="Node3D" type="Node3D" unique_id=1416688204 node_paths=PackedStringArray("meshes")]
2020
script = ExtResource("1_7feuc")
21+
base_colors = Array[Color]([Color(0.4383469, 0.18152684, 0.094284914, 1), Color(0.11448214, 0.2458665, 0.41194695, 1), Color(0.17459896, 0.35552335, 0.31885692, 1), Color(0.32928962, 0.36724612, 0.15746233, 1), Color(0.39016208, 0.14532027, 0.1877656, 1), Color(0.38054246, 0.18174157, 0.3412228, 1), Color(0.30982816, 0.31805637, 0.3737292, 1)])
2122
meshes = [NodePath("geodesic-sphere2/GD_mesh_002"), NodePath("geodesic-sphere2/GD_mesh_003"), NodePath("geodesic-sphere2/GD_mesh_004"), NodePath("geodesic-sphere2/GD_mesh_005"), NodePath("geodesic-sphere2/GD_mesh_006"), NodePath("geodesic-sphere2/GD_mesh_007"), NodePath("geodesic-sphere2/GD_mesh_008"), NodePath("geodesic-sphere2/GD_mesh_009"), NodePath("geodesic-sphere2/GD_mesh_010"), NodePath("geodesic-sphere2/GD_mesh_011"), NodePath("geodesic-sphere2/GD_mesh_012"), NodePath("geodesic-sphere2/GD_mesh_013"), NodePath("geodesic-sphere2/GD_mesh_014"), NodePath("geodesic-sphere2/GD_mesh_015"), NodePath("geodesic-sphere2/GD_mesh_016"), NodePath("geodesic-sphere2/GD_mesh_017"), NodePath("geodesic-sphere2/GD_mesh_018"), NodePath("geodesic-sphere2/GD_mesh_019"), NodePath("geodesic-sphere2/GD_mesh_020"), NodePath("geodesic-sphere2/GD_mesh_021"), NodePath("geodesic-sphere2/GD_mesh_022"), NodePath("geodesic-sphere2/GD_mesh_023"), NodePath("geodesic-sphere2/GD_mesh_024"), NodePath("geodesic-sphere2/GD_mesh_025"), NodePath("geodesic-sphere2/GD_mesh_026"), NodePath("geodesic-sphere2/GD_mesh_027"), NodePath("geodesic-sphere2/GD_mesh_028"), NodePath("geodesic-sphere2/GD_mesh_029"), NodePath("geodesic-sphere2/GD_mesh_030"), NodePath("geodesic-sphere2/GD_mesh_031"), NodePath("geodesic-sphere2/GD_mesh_032"), NodePath("geodesic-sphere2/GD_mesh_033"), NodePath("geodesic-sphere2/GD_mesh_034"), NodePath("geodesic-sphere2/GD_mesh_035"), NodePath("geodesic-sphere2/GD_mesh_036"), NodePath("geodesic-sphere2/GD_mesh_037"), NodePath("geodesic-sphere2/GD_mesh_038"), NodePath("geodesic-sphere2/GD_mesh_039"), NodePath("geodesic-sphere2/GD_mesh_040"), NodePath("geodesic-sphere2/GD_mesh_041"), NodePath("geodesic-sphere2/GD_mesh_042"), NodePath("geodesic-sphere2/GD_mesh_043"), NodePath("geodesic-sphere2/GD_mesh_044"), NodePath("geodesic-sphere2/GD_mesh_045"), NodePath("geodesic-sphere2/GD_mesh_046"), NodePath("geodesic-sphere2/GD_mesh_047"), NodePath("geodesic-sphere2/GD_mesh_048"), NodePath("geodesic-sphere2/GD_mesh_049"), NodePath("geodesic-sphere2/GD_mesh_050"), NodePath("geodesic-sphere2/GD_mesh_051"), NodePath("geodesic-sphere2/GD_mesh_052"), NodePath("geodesic-sphere2/GD_mesh_053"), NodePath("geodesic-sphere2/GD_mesh_054"), NodePath("geodesic-sphere2/GD_mesh_055"), NodePath("geodesic-sphere2/GD_mesh_056"), NodePath("geodesic-sphere2/GD_mesh_057"), NodePath("geodesic-sphere2/GD_mesh_058"), NodePath("geodesic-sphere2/GD_mesh_059"), NodePath("geodesic-sphere2/GD_mesh_060"), NodePath("geodesic-sphere2/GD_mesh_061"), NodePath("geodesic-sphere2/GD_mesh_062"), NodePath("geodesic-sphere2/GD_mesh_063"), NodePath("geodesic-sphere2/GD_mesh_064"), NodePath("geodesic-sphere2/GD_mesh_065"), NodePath("geodesic-sphere2/GD_mesh_066"), NodePath("geodesic-sphere2/GD_mesh_067"), NodePath("geodesic-sphere2/GD_mesh_068"), NodePath("geodesic-sphere2/GD_mesh_069"), NodePath("geodesic-sphere2/GD_mesh_070"), NodePath("geodesic-sphere2/GD_mesh_071"), NodePath("geodesic-sphere2/GD_mesh_072"), NodePath("geodesic-sphere2/GD_mesh_073"), NodePath("geodesic-sphere2/GD_mesh_074"), NodePath("geodesic-sphere2/GD_mesh_075"), NodePath("geodesic-sphere2/GD_mesh_076"), NodePath("geodesic-sphere2/GD_mesh_077"), NodePath("geodesic-sphere2/GD_mesh_078"), NodePath("geodesic-sphere2/GD_mesh_079"), NodePath("geodesic-sphere2/GD_mesh_080"), NodePath("geodesic-sphere2/GD_mesh_081"), NodePath("geodesic-sphere2/GD_mesh_082"), NodePath("geodesic-sphere2/GD_mesh_083"), NodePath("geodesic-sphere2/GD_mesh_084"), NodePath("geodesic-sphere2/GD_mesh_085"), NodePath("geodesic-sphere2/GD_mesh_086"), NodePath("geodesic-sphere2/GD_mesh_087"), NodePath("geodesic-sphere2/GD_mesh_088"), NodePath("geodesic-sphere2/GD_mesh_089"), NodePath("geodesic-sphere2/GD_mesh_090"), NodePath("geodesic-sphere2/GD_mesh_091"), NodePath("geodesic-sphere2/GD_mesh_092"), NodePath("geodesic-sphere2/GD_mesh_093")]
23+
time_between_flashes = 0.03
2224

2325
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=586491415]
2426
environment = SubResource("Environment_njmsf")

misc/hdr_output/output_max_linear_value/color_flash.gd

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@ extends MeshInstance3D
44

55
var _base_color: Color
66
var _animation_value: float = 0.0
7-
var _time_passed: float = 0.0
87

98

9+
func flash() -> void:
10+
_animation_value = 1.0
11+
1012
func _init() -> void:
1113
_base_color = (get_active_material(0) as StandardMaterial3D).albedo_color
1214
set_process(true)
1315

1416

1517
func _process(delta: float) -> void:
16-
_time_passed += delta
17-
if (_time_passed > 2.0):
18-
_animation_value = 1.0;
19-
_time_passed -= 2.0
20-
2118
_animation_value -= delta / fade_time
2219
if (_animation_value < 0.0):
2320
_animation_value = 0.0
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,35 @@
11
extends Node3D
22

3+
@export var base_colors: Array[Color]
34
@export var meshes: Array[MeshInstance3D]
5+
@export var time_between_flashes: float = 0.2
6+
7+
var _time_passed: float = 0.0
8+
var _mesh_index: int = 0
9+
410

511
func _ready() -> void:
12+
seed(0)
13+
meshes.shuffle()
14+
15+
var color_index = 0
16+
617
for mesh in meshes:
18+
color_index += 1
19+
if color_index >= base_colors.size():
20+
color_index = 0
21+
22+
var material: StandardMaterial3D = mesh.get_active_material(0).duplicate() as StandardMaterial3D
23+
material.albedo_color = base_colors[color_index]
24+
mesh.material_override = material
725
mesh.set_script(preload("res://output_max_linear_value/color_flash.gd"))
26+
27+
28+
func _process(delta: float) -> void:
29+
_time_passed += delta
30+
if (_time_passed > time_between_flashes):
31+
meshes[_mesh_index].flash()
32+
_mesh_index += 1
33+
if _mesh_index >= meshes.size():
34+
_mesh_index = 0
35+
_time_passed -= time_between_flashes

0 commit comments

Comments
 (0)