Skip to content

Commit

Permalink
Mute (most) sounds on freeze, burnout particles quality settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyIF committed Dec 30, 2024
1 parent 5d6436d commit 8ce6c8a
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 22 deletions.
20 changes: 20 additions & 0 deletions addons/aacc/materials/particles/burnout/burnout_render_high.tres
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions addons/aacc/materials/particles/burnout/burnout_render_low.tres
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions addons/aacc/materials/particles/burnout/burnout_render_medium.tres
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions addons/aacc/materials/particles/burnout/burnout_render_ultra.tres
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
22 changes: 17 additions & 5 deletions addons/aacc/scenes/burnout_particles.tscn
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
2 changes: 1 addition & 1 deletion addons/aacc/scenes/hit_sound.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion addons/aacc/scenes/land_sound.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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")
10 changes: 10 additions & 0 deletions addons/aacc/scripts/aacc_global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions addons/aacc/scripts/audio/car_engine_sound_basic.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
8 changes: 5 additions & 3 deletions addons/aacc/scripts/audio/car_tire_screech_sound.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
1 change: 0 additions & 1 deletion addons/aacc/scripts/car.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 10 additions & 11 deletions addons/aacc/scripts/car_wheel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions addons/aacc/scripts/particles/burnout_particles_quality.gd
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://3nxhrhbqiab

0 comments on commit 8ce6c8a

Please sign in to comment.