From 8ce6c8a5b9b42d845709b3f532ca7f07d8316305 Mon Sep 17 00:00:00 2001 From: ArtyIF Date: Mon, 30 Dec 2024 18:00:19 +0300 Subject: [PATCH] Mute (most) sounds on freeze, burnout particles quality settings --- .../burnout/burnout_render_high.tres | 20 ++++++++++++ .../particles/burnout/burnout_render_low.tres | 20 ++++++++++++ .../burnout/burnout_render_medium.tres | 21 +++++++++++++ .../burnout/burnout_render_ultra.tres | 19 ++++++++++++ .../burnout/burnout_render_very_low.tres | 20 ++++++++++++ addons/aacc/scenes/burnout_particles.tscn | 22 ++++++++++--- addons/aacc/scenes/hit_sound.tscn | 2 +- addons/aacc/scenes/land_sound.tscn | 2 +- addons/aacc/scripts/aacc_global.gd | 10 ++++++ .../scripts/audio/car_engine_sound_basic.gd | 5 +++ .../scripts/audio/car_tire_screech_sound.gd | 8 +++-- addons/aacc/scripts/car.gd | 1 - addons/aacc/scripts/car_wheel.gd | 21 ++++++------- .../particles/burnout_particles_quality.gd | 31 +++++++++++++++++++ .../burnout_particles_quality.gd.uid | 1 + 15 files changed, 181 insertions(+), 22 deletions(-) create mode 100644 addons/aacc/materials/particles/burnout/burnout_render_high.tres create mode 100644 addons/aacc/materials/particles/burnout/burnout_render_low.tres create mode 100644 addons/aacc/materials/particles/burnout/burnout_render_medium.tres create mode 100644 addons/aacc/materials/particles/burnout/burnout_render_ultra.tres create mode 100644 addons/aacc/materials/particles/burnout/burnout_render_very_low.tres create mode 100644 addons/aacc/scripts/particles/burnout_particles_quality.gd create mode 100644 addons/aacc/scripts/particles/burnout_particles_quality.gd.uid diff --git a/addons/aacc/materials/particles/burnout/burnout_render_high.tres b/addons/aacc/materials/particles/burnout/burnout_render_high.tres new file mode 100644 index 0000000..19980dc --- /dev/null +++ b/addons/aacc/materials/particles/burnout/burnout_render_high.tres @@ -0,0 +1,20 @@ +[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://c8e0oe0drsip2"] + +[ext_resource type="Texture2D" uid="uid://dcfh0h4h0tw74" path="res://addons/aacc/textures/WispySmoke01_8x8.tga" id="1_wcy51"] + +[resource] +transparency = 4 +shading_mode = 2 +diffuse_mode = 2 +specular_mode = 2 +vertex_color_use_as_albedo = true +albedo_texture = ExtResource("1_wcy51") +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 8 +particles_anim_v_frames = 8 +particles_anim_loop = false +proximity_fade_enabled = true +distance_fade_mode = 1 +distance_fade_min_distance = 0.5 +distance_fade_max_distance = 2.0 diff --git a/addons/aacc/materials/particles/burnout/burnout_render_low.tres b/addons/aacc/materials/particles/burnout/burnout_render_low.tres new file mode 100644 index 0000000..c09758d --- /dev/null +++ b/addons/aacc/materials/particles/burnout/burnout_render_low.tres @@ -0,0 +1,20 @@ +[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://cssl2n4bwup7n"] + +[ext_resource type="Texture2D" uid="uid://dcfh0h4h0tw74" path="res://addons/aacc/textures/WispySmoke01_8x8.tga" id="1_jhelc"] + +[resource] +transparency = 4 +shading_mode = 2 +diffuse_mode = 2 +specular_mode = 2 +vertex_color_use_as_albedo = true +albedo_texture = ExtResource("1_jhelc") +disable_receive_shadows = true +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 8 +particles_anim_v_frames = 8 +particles_anim_loop = false +distance_fade_mode = 1 +distance_fade_min_distance = 0.5 +distance_fade_max_distance = 2.0 diff --git a/addons/aacc/materials/particles/burnout/burnout_render_medium.tres b/addons/aacc/materials/particles/burnout/burnout_render_medium.tres new file mode 100644 index 0000000..8138789 --- /dev/null +++ b/addons/aacc/materials/particles/burnout/burnout_render_medium.tres @@ -0,0 +1,21 @@ +[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://3pj8yaou00og"] + +[ext_resource type="Texture2D" uid="uid://dcfh0h4h0tw74" path="res://addons/aacc/textures/WispySmoke01_8x8.tga" id="1_7idyy"] + +[resource] +transparency = 4 +shading_mode = 2 +diffuse_mode = 2 +specular_mode = 2 +vertex_color_use_as_albedo = true +albedo_texture = ExtResource("1_7idyy") +disable_receive_shadows = true +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 8 +particles_anim_v_frames = 8 +particles_anim_loop = false +proximity_fade_enabled = true +distance_fade_mode = 1 +distance_fade_min_distance = 0.5 +distance_fade_max_distance = 2.0 diff --git a/addons/aacc/materials/particles/burnout/burnout_render_ultra.tres b/addons/aacc/materials/particles/burnout/burnout_render_ultra.tres new file mode 100644 index 0000000..c348258 --- /dev/null +++ b/addons/aacc/materials/particles/burnout/burnout_render_ultra.tres @@ -0,0 +1,19 @@ +[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://c8e0oe0drsip2"] + +[ext_resource type="Texture2D" uid="uid://dcfh0h4h0tw74" path="res://addons/aacc/textures/WispySmoke01_8x8.tga" id="1_cjtm3"] + +[resource] +transparency = 4 +diffuse_mode = 2 +specular_mode = 2 +vertex_color_use_as_albedo = true +albedo_texture = ExtResource("1_cjtm3") +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 8 +particles_anim_v_frames = 8 +particles_anim_loop = false +proximity_fade_enabled = true +distance_fade_mode = 1 +distance_fade_min_distance = 0.5 +distance_fade_max_distance = 2.0 diff --git a/addons/aacc/materials/particles/burnout/burnout_render_very_low.tres b/addons/aacc/materials/particles/burnout/burnout_render_very_low.tres new file mode 100644 index 0000000..4db9293 --- /dev/null +++ b/addons/aacc/materials/particles/burnout/burnout_render_very_low.tres @@ -0,0 +1,20 @@ +[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://67bxlf4dvjc"] + +[ext_resource type="Texture2D" uid="uid://dcfh0h4h0tw74" path="res://addons/aacc/textures/WispySmoke01_8x8.tga" id="1_4nqps"] + +[resource] +transparency = 4 +shading_mode = 0 +diffuse_mode = 2 +specular_mode = 2 +vertex_color_use_as_albedo = true +albedo_texture = ExtResource("1_4nqps") +disable_receive_shadows = true +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 8 +particles_anim_v_frames = 8 +particles_anim_loop = false +distance_fade_mode = 1 +distance_fade_min_distance = 0.5 +distance_fade_max_distance = 2.0 diff --git a/addons/aacc/scenes/burnout_particles.tscn b/addons/aacc/scenes/burnout_particles.tscn index 91a52ca..eff268a 100644 --- a/addons/aacc/scenes/burnout_particles.tscn +++ b/addons/aacc/scenes/burnout_particles.tscn @@ -1,15 +1,21 @@ -[gd_scene load_steps=4 format=3 uid="uid://bgcsoin0se8xf"] +[gd_scene load_steps=9 format=3 uid="uid://bgcsoin0se8xf"] [ext_resource type="Material" uid="uid://0nsued0at226" path="res://addons/aacc/materials/particles/burnout/burnout_process.tres" id="1_urvgu"] -[ext_resource type="Material" uid="uid://3pj8yaou00og" path="res://addons/aacc/materials/particles/burnout/burnout_render_compatibility.tres" id="2_ygvqw"] +[ext_resource type="Script" uid="uid://3nxhrhbqiab" path="res://addons/aacc/scripts/particles/burnout_particles_quality.gd" id="3_2w4mv"] +[ext_resource type="Material" uid="uid://67bxlf4dvjc" path="res://addons/aacc/materials/particles/burnout/burnout_render_very_low.tres" id="4_a15ek"] +[ext_resource type="Material" uid="uid://cssl2n4bwup7n" path="res://addons/aacc/materials/particles/burnout/burnout_render_low.tres" id="4_r6cyj"] +[ext_resource type="Material" uid="uid://3pj8yaou00og" path="res://addons/aacc/materials/particles/burnout/burnout_render_medium.tres" id="5_r6cyj"] +[ext_resource type="Material" uid="uid://c8e0oe0drsip2" path="res://addons/aacc/materials/particles/burnout/burnout_render_ultra.tres" id="7_a15ek"] +[ext_resource type="Material" uid="uid://c8e0oe0drsip2" path="res://addons/aacc/materials/particles/burnout/burnout_render_high.tres" id="7_pe51t"] [sub_resource type="QuadMesh" id="QuadMesh_si8b4"] -material = ExtResource("2_ygvqw") +material = ExtResource("7_a15ek") size = Vector2(2, 2) [node name="BurnoutParticles" type="GPUParticles3D"] layers = 2 -sorting_offset = 10.0 +sorting_offset = 1000.0 +material_override = ExtResource("4_r6cyj") cast_shadow = 0 gi_mode = 0 emitting = false @@ -18,7 +24,13 @@ amount_ratio = 0.0 lifetime = 2.0 fixed_fps = 0 collision_base_size = 2.0 -visibility_aabb = AABB(-25, -2, -25, 50, 10, 50) +visibility_aabb = AABB(-100, -50, -100, 200, 100, 200) draw_order = 3 process_material = ExtResource("1_urvgu") draw_pass_1 = SubResource("QuadMesh_si8b4") +script = ExtResource("3_2w4mv") +very_low_quality = ExtResource("4_a15ek") +low_quality = ExtResource("4_r6cyj") +medium_quality = ExtResource("5_r6cyj") +high_quality = ExtResource("7_pe51t") +ultra_quality = ExtResource("7_a15ek") diff --git a/addons/aacc/scenes/hit_sound.tscn b/addons/aacc/scenes/hit_sound.tscn index e039713..9a3011f 100644 --- a/addons/aacc/scenes/hit_sound.tscn +++ b/addons/aacc/scenes/hit_sound.tscn @@ -17,5 +17,5 @@ unit_size = 5.0 max_db = 0.0 autoplay = true bus = &"SFX" -doppler_tracking = 2 +doppler_tracking = 1 script = ExtResource("2_mgomb") diff --git a/addons/aacc/scenes/land_sound.tscn b/addons/aacc/scenes/land_sound.tscn index d014ee5..69a737a 100644 --- a/addons/aacc/scenes/land_sound.tscn +++ b/addons/aacc/scenes/land_sound.tscn @@ -9,5 +9,5 @@ unit_size = 5.0 max_db = 0.0 autoplay = true bus = &"SFX" -doppler_tracking = 2 +doppler_tracking = 1 script = ExtResource("2_fiyv0") diff --git a/addons/aacc/scripts/aacc_global.gd b/addons/aacc/scripts/aacc_global.gd index f9fb681..9ad61d7 100644 --- a/addons/aacc/scripts/aacc_global.gd +++ b/addons/aacc/scripts/aacc_global.gd @@ -4,3 +4,13 @@ var current_car: Car var current_car_input: CarInput var current_shadow_color: Color = Color.BLACK var current_shadow_color_amount: float = 0.0 + +enum BurnoutParticlesQuality { + OFF = 0, # disabled + VERY_LOW = 1, # unlit, no proximity fade + LOW = 2, # vertex lit, no shadow, no proximity fade (highest working for compatibility as of now) + MEDIUM = 3, # vertex lit, no shadow, proximity fade + HIGH = 4, # vertex lit, shadow, proximity fade + ULTRA = 5 # pixel lit, shadow, proximity fade +} +var current_burnout_particles_quality: BurnoutParticlesQuality = BurnoutParticlesQuality.LOW diff --git a/addons/aacc/scripts/audio/car_engine_sound_basic.gd b/addons/aacc/scripts/audio/car_engine_sound_basic.gd index 28e9f39..cdc4a04 100644 --- a/addons/aacc/scripts/audio/car_engine_sound_basic.gd +++ b/addons/aacc/scripts/audio/car_engine_sound_basic.gd @@ -12,3 +12,8 @@ func _ready() -> void: func _physics_process(delta: float) -> void: volume_db = linear_to_db(lerp(min_volume, 1.0, car.accel_amount.get_current_value())) pitch_scale = lerp(engine_pitch_range.x, engine_pitch_range.y, car.revs.get_current_value()) + + if car.freeze and playing: + stop() + elif not car.freeze and not playing: + play() diff --git a/addons/aacc/scripts/audio/car_tire_screech_sound.gd b/addons/aacc/scripts/audio/car_tire_screech_sound.gd index 80cf782..ebe2ba8 100644 --- a/addons/aacc/scripts/audio/car_tire_screech_sound.gd +++ b/addons/aacc/scripts/audio/car_tire_screech_sound.gd @@ -3,12 +3,14 @@ class_name CarTireScreechSound extends AudioStreamPlayer3D @export var pitch_range: Vector2 = Vector2(0.5, 1.0) @onready var car: Car = get_node("..") +var smooth_burnout_amount = SmoothedFloat.new(0.0, 4.0, 4.0) -func _physics_process(_delta: float) -> void: - pitch_scale = lerp(pitch_range.x, pitch_range.y, car.burnout_amount) +func _physics_process(delta: float) -> void: + smooth_burnout_amount.advance_to(car.burnout_amount, delta) + pitch_scale = lerp(pitch_range.x, pitch_range.y, smooth_burnout_amount.get_current_value()) volume_db = linear_to_db(car.burnout_amount) - if is_inf(volume_db): + if is_inf(volume_db) or car.freeze: volume_db = -80.0 if volume_db >= -60.0 and not playing: play(randf_range(0.0, stream.get_length())) diff --git a/addons/aacc/scripts/car.gd b/addons/aacc/scripts/car.gd index 820243c..1b393f5 100644 --- a/addons/aacc/scripts/car.gd +++ b/addons/aacc/scripts/car.gd @@ -199,7 +199,6 @@ func reset() -> void: for wheel in wheels: wheel.reset() - #region Processing func get_input_steer_multiplier() -> float: if local_linear_velocity.z > 0.0: return 1.0 diff --git a/addons/aacc/scripts/car_wheel.gd b/addons/aacc/scripts/car_wheel.gd index e08334e..15e4df1 100644 --- a/addons/aacc/scripts/car_wheel.gd +++ b/addons/aacc/scripts/car_wheel.gd @@ -162,7 +162,7 @@ func update_visuals(delta: float) -> void: visual_node.transform = new_transform func update_burnout() -> void: - if not is_colliding: + if not is_colliding or car.freeze: skid_trail.is_emitting = false burnout_particles.amount_ratio = 0.0 burnout_particles.emitting = false @@ -195,18 +195,17 @@ func _physics_process(delta: float) -> void: last_compression = compression last_compression_set = true - if not car.freeze: - var suspension_magnitude: float = 0.0 - suspension_magnitude += compression * suspension_spring + var suspension_magnitude: float = 0.0 + suspension_magnitude += compression * suspension_spring - var compression_delta: float = (compression - last_compression) / delta - suspension_magnitude += compression_delta * suspension_damper - last_compression = compression + var compression_delta: float = (compression - last_compression) / delta + suspension_magnitude += compression_delta * suspension_damper + last_compression = compression - suspension_magnitude *= collision_normal.dot(global_basis.y) - - if not car.do_not_apply_forces: - car.apply_force(collision_normal * suspension_magnitude, collision_point - car.global_position) + suspension_magnitude *= collision_normal.dot(global_basis.y) + + if not car.do_not_apply_forces and not car.freeze: + car.apply_force(collision_normal * suspension_magnitude, collision_point - car.global_position) else: is_colliding = false last_compression = 0.0 diff --git a/addons/aacc/scripts/particles/burnout_particles_quality.gd b/addons/aacc/scripts/particles/burnout_particles_quality.gd new file mode 100644 index 0000000..1d0d0ec --- /dev/null +++ b/addons/aacc/scripts/particles/burnout_particles_quality.gd @@ -0,0 +1,31 @@ +extends GPUParticles3D + +@export var very_low_quality: BaseMaterial3D +@export var low_quality: BaseMaterial3D +@export var medium_quality: BaseMaterial3D +@export var high_quality: BaseMaterial3D +@export var ultra_quality: BaseMaterial3D + +var _last_quality: AACCGlobal.BurnoutParticlesQuality = AACCGlobal.BurnoutParticlesQuality.LOW + +func _process(delta: float) -> void: + if AACCGlobal.current_burnout_particles_quality != _last_quality: + match AACCGlobal.current_burnout_particles_quality: + AACCGlobal.BurnoutParticlesQuality.OFF: + visible = false + AACCGlobal.BurnoutParticlesQuality.VERY_LOW: + visible = true + material_override = very_low_quality + AACCGlobal.BurnoutParticlesQuality.LOW: + visible = true + material_override = low_quality + AACCGlobal.BurnoutParticlesQuality.MEDIUM: + visible = true + material_override = medium_quality + AACCGlobal.BurnoutParticlesQuality.HIGH: + visible = true + material_override = high_quality + AACCGlobal.BurnoutParticlesQuality.ULTRA: + visible = true + material_override = ultra_quality + _last_quality = AACCGlobal.current_burnout_particles_quality diff --git a/addons/aacc/scripts/particles/burnout_particles_quality.gd.uid b/addons/aacc/scripts/particles/burnout_particles_quality.gd.uid new file mode 100644 index 0000000..8014beb --- /dev/null +++ b/addons/aacc/scripts/particles/burnout_particles_quality.gd.uid @@ -0,0 +1 @@ +uid://3nxhrhbqiab