From ee58ea38efdf7900879cf64a77dbeb67aa3413bd Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Mon, 11 Jan 2021 09:28:15 +0000 Subject: [PATCH] scale bounce with intensity, shake camera on calm --- .../Accessibility/Accessibility Options.asset | 2 +- .../Rendering/AudioVisualizerRuntime.cs | 2 + Assets/Shaders/enemy.shader | 44 +++---------------- Assets/Shaders/obstacle.shader | 8 +++- Assets/TunnelController.cs | 2 +- 5 files changed, 15 insertions(+), 43 deletions(-) diff --git a/Assets/Accessibility/Accessibility Options.asset b/Assets/Accessibility/Accessibility Options.asset index 9ca6e5d..948e968 100644 --- a/Assets/Accessibility/Accessibility Options.asset +++ b/Assets/Accessibility/Accessibility Options.asset @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c271cfa846431634db54fa41238b7b35, type: 3} m_Name: Accessibility Options m_EditorClassIdentifier: - _mode: 2 + _mode: 0 _calm: _value: 0 _tunnel: {fileID: 2100000, guid: e26770f868f0d0d44960f5354b21e17c, type: 2} diff --git a/Assets/Scripts/Rendering/AudioVisualizerRuntime.cs b/Assets/Scripts/Rendering/AudioVisualizerRuntime.cs index d8c1679..18eab4f 100644 --- a/Assets/Scripts/Rendering/AudioVisualizerRuntime.cs +++ b/Assets/Scripts/Rendering/AudioVisualizerRuntime.cs @@ -34,6 +34,8 @@ public class AudioVisualizerRuntime : MonoBehaviour channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, _fft); _system.Initialise(_fractal.material, _tunnel.Active.material, _ship.material); + + Shader.SetGlobalFloat("_Intensity", _accessibility.Intensity.Value); } private void LateUpdate() diff --git a/Assets/Shaders/enemy.shader b/Assets/Shaders/enemy.shader index 64283e4..f18bf95 100644 --- a/Assets/Shaders/enemy.shader +++ b/Assets/Shaders/enemy.shader @@ -81,6 +81,7 @@ Shader "custom/enemy" float _PulseIntensity; float _BaseTubeRadius; + float _Intensity; // float _VertexScale; // float _FadeStrength; @@ -122,49 +123,11 @@ Shader "custom/enemy" float wpz = mo_wpos.z; float r = length(radius) + wpz*wpz*wpz*_RadiusWithDistance; - // compress horiztonally - // vpos.x = vpos.x * _HorizontalScale; - // vpos.y = vpos.y * _VerticalScale * 1.0-(r-radius); - // vpos = mul(UNITY_MATRIX_P, - // mul(UNITY_MATRIX_MV, float4(0,0,0,1)) - // + float4(vpos.x, vpos.y, 0,0) - // + float4(1, 1,1,1)); - - // recalculate wpos with updated vpos - // wpos = TransformObjectToWorld(vpos); - - // matrix m = GetObjectToWorldMatrix(); - - //float d = 1.0+length(wpos)*0.5; - //float2 uv = wpos.zx; - // float noise = SAMPLE_TEXTURE2D_LOD(_NoiseMap, sampler_NoiseMap, uv, 0) - 0.5; - // vpos += _VertexScale*float3(0,0,5)*d; - // vpos += sin(180)*sin(1800)*float3(0,0,5)*d; - // noise *= d*d * 0.1; - // vpos *= lerp (0.9,1.1,noise); - - // float3 owpos = TransformObjectToWorld(float3(0,0,0)); - - // calculate position on circle - - // float3 object_origin = TransformObjectToWorld(float3(0,0,0)); - // float r_origin = float - - // float wpz = abs(mo_wpos.z-6); // offset due to player position - // // wpz *= wpz; - // r += wpz*_RadiusWithDistance; - // mo_wpos.z *= _SpeedMultiplier; - float x = mo_wpos; - // float x = mo_wpos.x+vpos.x; x -= _PlayerXPos; - // x += 0.5*PI; float a = 2*PI*(x/d); a -= 0.5*PI; - // a *= (radius - r) * -1.0; - - // vpos.y += 0.5*radius*cos(a); float3 wpos = float3(cos(a)*r,sin(a)*r,mo_wpos.z); @@ -178,7 +141,10 @@ Shader "custom/enemy" wpos += float3(noise1, noise2, 0) * 2.0; wpos += float3(vpos.xy,0); wpos.y += radius; - wpos.z *= (_SpeedMultiplier+5*(_DistanceToNextBeat*_DistanceSinceLastBeat)); + + float bounceStrength=5.0*_Intensity; + float bounce = (_SpeedMultiplier+bounceStrength*(_DistanceToNextBeat*_DistanceSinceLastBeat)); + wpos.z *= bounce; // wpos.z *= max(1, (wpos.z-6)* _SpeedMultiplier); vpos = TransformWorldToObject(wpos); diff --git a/Assets/Shaders/obstacle.shader b/Assets/Shaders/obstacle.shader index 813c1fa..482a649 100644 --- a/Assets/Shaders/obstacle.shader +++ b/Assets/Shaders/obstacle.shader @@ -83,6 +83,7 @@ Shader "custom/obstacle" float _VerticalScale; float _BaseTubeRadius; + float _Intensity; // float _VertexScale; // float _FadeStrength; @@ -222,8 +223,11 @@ Shader "custom/obstacle" wpos += float3(vpos.xy,0); wpos.y += radius; - wpos.z *= (_SpeedMultiplier+5*(_DistanceToNextBeat*_DistanceSinceLastBeat)); - // wpos.z *= max(1, (wpos.z-6)* _SpeedMultiplier); + + float boundsStrength = 5.0*_Intensity; + float bounce = (_SpeedMultiplier+boundsStrength*(_DistanceToNextBeat*_DistanceSinceLastBeat)); + wpos.z *= bounce; + vpos = TransformWorldToObject(wpos); // TransformWorldToObject() diff --git a/Assets/TunnelController.cs b/Assets/TunnelController.cs index a761fe3..79e4b3a 100644 --- a/Assets/TunnelController.cs +++ b/Assets/TunnelController.cs @@ -79,7 +79,7 @@ public class TunnelController : MonoBehaviour var normalisedElapsed = elapsed / _duration; - var shake = Mathf.Max(_anim.Evaluate(normalisedElapsed), _baseCameraShake) * cameraShakeIntensity; + var shake = Mathf.Max(_anim.Evaluate(normalisedElapsed), _baseCameraShake) * _intensity; Shader.SetGlobalFloat(CameraShake, shake); }