diff --git a/.import/sky2.jpg-bf80cb1dda623823975e8be3440606f5.md5 b/.import/sky2.jpg-bf80cb1dda623823975e8be3440606f5.md5 new file mode 100644 index 0000000..9b12fb0 --- /dev/null +++ b/.import/sky2.jpg-bf80cb1dda623823975e8be3440606f5.md5 @@ -0,0 +1,3 @@ +source_md5="9fa407d9977812173983453120ee812e" +dest_md5="0595521ab1661cf3d800c40f50cf8655" + diff --git a/.import/sky2.jpg-bf80cb1dda623823975e8be3440606f5.stex b/.import/sky2.jpg-bf80cb1dda623823975e8be3440606f5.stex new file mode 100644 index 0000000..770e188 Binary files /dev/null and b/.import/sky2.jpg-bf80cb1dda623823975e8be3440606f5.stex differ diff --git a/.import/sky2.jpg-dc6eca33f2484285b9b7bb36d0d1c5e6.md5 b/.import/sky2.jpg-dc6eca33f2484285b9b7bb36d0d1c5e6.md5 new file mode 100644 index 0000000..9b12fb0 --- /dev/null +++ b/.import/sky2.jpg-dc6eca33f2484285b9b7bb36d0d1c5e6.md5 @@ -0,0 +1,3 @@ +source_md5="9fa407d9977812173983453120ee812e" +dest_md5="0595521ab1661cf3d800c40f50cf8655" + diff --git a/.import/sky2.jpg-dc6eca33f2484285b9b7bb36d0d1c5e6.stex b/.import/sky2.jpg-dc6eca33f2484285b9b7bb36d0d1c5e6.stex new file mode 100644 index 0000000..770e188 Binary files /dev/null and b/.import/sky2.jpg-dc6eca33f2484285b9b7bb36d0d1c5e6.stex differ diff --git a/.import/sky2e.jpg-fcd27e7be5dc9c60995c31aa32b89cfb.md5 b/.import/sky2e.jpg-fcd27e7be5dc9c60995c31aa32b89cfb.md5 new file mode 100644 index 0000000..9c72380 --- /dev/null +++ b/.import/sky2e.jpg-fcd27e7be5dc9c60995c31aa32b89cfb.md5 @@ -0,0 +1,3 @@ +source_md5="6f03573776abdfd807ae378ffbc16dde" +dest_md5="44a55859fe121110799b7e5d45cc011a" + diff --git a/.import/sky2e.jpg-fcd27e7be5dc9c60995c31aa32b89cfb.stex b/.import/sky2e.jpg-fcd27e7be5dc9c60995c31aa32b89cfb.stex new file mode 100644 index 0000000..05e9db0 Binary files /dev/null and b/.import/sky2e.jpg-fcd27e7be5dc9c60995c31aa32b89cfb.stex differ diff --git a/default_bus_layout.tres b/default_bus_layout.tres new file mode 100644 index 0000000..7efd1f7 --- /dev/null +++ b/default_bus_layout.tres @@ -0,0 +1,19 @@ +[gd_resource type="AudioBusLayout" load_steps=3 format=2] + +[sub_resource type="AudioEffectCapture" id=1] +resource_name = "Capture" + +[sub_resource type="AudioEffectSpectrumAnalyzer" id=2] +resource_name = "SpectrumAnalyzer" + +[resource] +bus/1/name = "Input" +bus/1/solo = false +bus/1/mute = true +bus/1/bypass_fx = false +bus/1/volume_db = 0.0 +bus/1/send = "Master" +bus/1/effect/0/effect = SubResource( 1 ) +bus/1/effect/0/enabled = true +bus/1/effect/1/effect = SubResource( 2 ) +bus/1/effect/1/enabled = true diff --git a/default_env.tres b/default_env.tres index 4411e50..3a2a3dc 100644 --- a/default_env.tres +++ b/default_env.tres @@ -1,8 +1,13 @@ -[gd_resource type="Environment" load_steps=2 format=2] +[gd_resource type="Environment" load_steps=3 format=2] + +[ext_resource path="res://textures/sky2e.jpg" type="Texture" id=1] [sub_resource type="PanoramaSky" id=1] +panorama = ExtResource( 1 ) [resource] background_mode = 2 background_sky = SubResource( 1 ) +background_sky_custom_fov = 72.0 ambient_light_sky_contribution = 0.49 +fog_color = Color( 0.27451, 0.643137, 0.741176, 1 ) diff --git a/koboldspawner.gd b/koboldspawner.gd index 2ce3d68..6391a7e 100644 --- a/koboldspawner.gd +++ b/koboldspawner.gd @@ -12,6 +12,17 @@ var lights var texsize = 128 +var abusi +var abusc +var abuss + +var bval2 = 0.0 +var lbval2 = 0.0 +var dbval2 = 0.0 +var rms = 0.0 +var arms = 0.0 +var rpeak = 0.0 + func _ready(): #for i in len(textureset): # textureset[i] = load("res://textures/kobolds/%s.png" % textureset[i]) @@ -27,6 +38,10 @@ func _ready(): add_child(kobold) kobolds.append([Vector3(rand_range(-2,2),2,rand_range(-3,3)),Vector3.ZERO,kobold]) lights = get_parent().lights + abusi = AudioServer.get_bus_index("Input") + abusc = AudioServer.get_bus_effect(abusi,0) + abuss = AudioServer.get_bus_effect_instance(abusi,1) + abusc.buffer_length = 0.1 const bouncemin = 1 const bouncemax = 2 @@ -37,6 +52,18 @@ var bounceboost = 2 var velocity = Vector3.ZERO func _physics_process(delta): + rms = 0 + var adata = abusc.get_buffer(int(AudioServer.get_mix_rate()*delta)+1) + for v in adata: + rms += pow(v.x+v.y,2) + arms = arms*0.9 + rms*0.1 + rpeak = clamp(rms/max(arms*2,1)-0.5,0,1) + #lbval2 = bval2 + #bval2 = abuss.get_magnitude_for_frequency_range(18000,20000).length()*100 + #dbval2 = (bval2-lbval2)*delta*1000 + bounceboost = 1 + rpeak + clamp(rms/250,0,1) + $"/root/Spatial/DebugText".text = "%0.4f\n%0.4f\n%0.4f\n%d\n%d" % [rms,arms,rpeak,abusc.get_buffer_length_frames(),abusc.get_frames_available()] + #print(rms) for i in range(sc,kobcount,skip): var kobold = kobolds[i] kobold[1].y -= 9.81*delta*skip diff --git a/lights.gd b/lights.gd index 6edc368..a015a7d 100644 --- a/lights.gd +++ b/lights.gd @@ -2,6 +2,10 @@ extends MeshInstance var t = 0.0 var mat +var peakt = 0.0 +var peako = false + +const dim = 0.2 var lights = [ [Vector3(6,-4.5,-2.25),Vector3.ZERO], @@ -10,18 +14,34 @@ var lights = [ [Vector3(10,-4.5,-8),Vector3.ZERO] ] +func rcv3(): + var tcol = Color.from_hsv(randf(),rand_range(0.85,1),1.0) + return Vector3(tcol.r,tcol.g,tcol.b) + func _ready(): for light in lights: light[0] = to_global(light[0]) mat = get_surface_material(1) + for light in lights: + light[1] = rcv3()*dim func _process(delta): t += delta - lights[0][1] = Vector3(1,0,0)*(sin(t*4)/2+0.5) - lights[1][1] = Vector3(0,1,0)*(sin(t*5.123)/2+0.5) - lights[2][1] = Vector3(0,0,1)*(sin(t*6.7)/2+0.5) - lights[3][1] = Vector3(1,0.5,0)*(sin(t*3.141)/2+0.5) + if !peako and $kobolds.rpeak >= 0.5 and peakt >= 0.2: + peako = true + lights[randi()%len(lights)][1] = rcv3() + if peako and $kobolds.rpeak <= 0.3: + peako = false + peakt = 0.0 + #lights[0][1] = Vector3(1,0,0)*float(cycle==0) #(sin(t*4)/2+0.5) + #lights[1][1] = Vector3(0,1,0)*float(cycle==1) #(sin(t*5.123)/2+0.5) + #lights[2][1] = Vector3(0,0,1)*float(cycle==2) #(sin(t*6.7)/2+0.5) + #lights[3][1] = Vector3(1,0.5,0)*float(cycle==3) #(sin(t*3.141)/2+0.5) mat.set_shader_param("col1",lights[0][1]) mat.set_shader_param("col2",lights[1][1]) mat.set_shader_param("col3",lights[2][1]) mat.set_shader_param("col4",lights[3][1]) + for light in lights: + if Color(light[1].x,light[1].y,light[1].z).v > 0.2: + light[1] *= 0.9 + peakt += delta diff --git a/main.tscn b/main.tscn index 2b8f9d8..33e1eeb 100644 --- a/main.tscn +++ b/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=13 format=2] [ext_resource path="res://speen.gd" type="Script" id=1] [ext_resource path="res://beach.obj" type="ArrayMesh" id=2] @@ -18,6 +18,8 @@ _data = { "tilts": PoolRealArray( 0, 0, 0, 0, 0, 0 ) } +[sub_resource type="AudioStreamMicrophone" id=2] + [node name="Spatial" type="Spatial"] [node name="island" type="MeshInstance" parent="."] @@ -70,3 +72,13 @@ anchor_right = 1.0 anchor_bottom = 1.0 color = Color( 0, 0, 0, 1 ) script = ExtResource( 9 ) + +[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] +stream = SubResource( 2 ) +autoplay = true +bus = "Input" + +[node name="DebugText" type="Label" parent="."] +visible = false +margin_right = 40.0 +margin_bottom = 14.0 diff --git a/project.godot b/project.godot index 53844c1..4aaaa7c 100644 --- a/project.godot +++ b/project.godot @@ -20,6 +20,7 @@ config/icon="res://icon.png" [audio] +driver="" enable_audio_input=true [display] diff --git a/sources/theduck.blend b/sources/theduck.blend new file mode 100644 index 0000000..148c357 Binary files /dev/null and b/sources/theduck.blend differ diff --git a/sources/theduck.blend1 b/sources/theduck.blend1 new file mode 100644 index 0000000..c593b06 Binary files /dev/null and b/sources/theduck.blend1 differ diff --git a/textures/sky2.jpg b/textures/sky2.jpg new file mode 100644 index 0000000..4cb8778 Binary files /dev/null and b/textures/sky2.jpg differ diff --git a/textures/sky2.jpg.import b/textures/sky2.jpg.import new file mode 100644 index 0000000..6395a26 --- /dev/null +++ b/textures/sky2.jpg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/sky2.jpg-dc6eca33f2484285b9b7bb36d0d1c5e6.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://textures/sky2.jpg" +dest_files=[ "res://.import/sky2.jpg-dc6eca33f2484285b9b7bb36d0d1c5e6.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/textures/sky2e.jpg b/textures/sky2e.jpg new file mode 100644 index 0000000..a8a32b3 Binary files /dev/null and b/textures/sky2e.jpg differ diff --git a/textures/sky2e.jpg.import b/textures/sky2e.jpg.import new file mode 100644 index 0000000..25c5165 --- /dev/null +++ b/textures/sky2e.jpg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/sky2e.jpg-fcd27e7be5dc9c60995c31aa32b89cfb.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://textures/sky2e.jpg" +dest_files=[ "res://.import/sky2e.jpg-fcd27e7be5dc9c60995c31aa32b89cfb.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/textures/testsky.tres b/textures/testsky.tres new file mode 100644 index 0000000..017f56c --- /dev/null +++ b/textures/testsky.tres @@ -0,0 +1,9 @@ +[gd_resource type="GradientTexture2D" load_steps=2 format=2] + +[sub_resource type="Gradient" id=2] +colors = PoolColorArray( 0.3476, 0.59092, 0.79, 1, 0.550781, 0.7789, 1, 1 ) + +[resource] +gradient = SubResource( 2 ) +fill_from = Vector2( 0.7, 0.5 ) +fill_to = Vector2( 0.7, 0.4 )