From 8ae6993dab243255f8fb4afcf7af6ddd47f39dad Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Sat, 9 Jan 2021 18:45:52 +0000 Subject: [PATCH] add subtractive ground --- Assets/Audio/Audio Visualiser.asset | 2 +- Assets/Materials/Tunnel_Party.mat | 6 +- Assets/Scenes/Chief's Sandbox.unity | 90 +++++++++++++++++------------ Assets/Scripts/LoseLife.cs | 4 +- Assets/Shaders/tunnel.shader | 29 +++++++++- 5 files changed, 86 insertions(+), 45 deletions(-) diff --git a/Assets/Audio/Audio Visualiser.asset b/Assets/Audio/Audio Visualiser.asset index f64809e..1a1a9eb 100644 --- a/Assets/Audio/Audio Visualiser.asset +++ b/Assets/Audio/Audio Visualiser.asset @@ -20,7 +20,7 @@ MonoBehaviour: channel: 0 sample: 525 _tunnelAnimations: - - name: _ShakeStrength + - name: _FractalWeight multiplier: 2 channel: 0 sample: 355 diff --git a/Assets/Materials/Tunnel_Party.mat b/Assets/Materials/Tunnel_Party.mat index b338528..dba2b87 100644 --- a/Assets/Materials/Tunnel_Party.mat +++ b/Assets/Materials/Tunnel_Party.mat @@ -117,15 +117,16 @@ Material: - _FractalPower: 1 - _FractalRotateSpeed: 20 - _FractalScale: 6 - - _FractalWeight: 0.15 + - _FractalWeight: 0.35 - _GlossMapScale: 0 - _Glossiness: 0 - _GlossyReflections: 0 + - _GroundWeight: 1 - _Intensity: 1 - _Metallic: 0 - _Nebula1Power: 3 - _Nebula2Power: 5 - - _NebulaWeight: 0.5 + - _NebulaWeight: 0.4 - _OcclusionStrength: 1 - _OverallPower: 1 - _Parallax: 0.005 @@ -146,6 +147,7 @@ Material: - _Color: {r: 1, g: 1, b: 1, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _FractalColor: {r: 1.3876811, g: 1.0683917, b: 2.3455496, a: 1} + - _GroundColor: {r: 1.287958, g: 0.565445, b: 2.251309, a: 1} - _NebulaColor1: {r: 0, g: 0.67775345, b: 1, a: 1} - _NebulaColor2: {r: 0.54217625, g: 0.25, b: 1, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} diff --git a/Assets/Scenes/Chief's Sandbox.unity b/Assets/Scenes/Chief's Sandbox.unity index e705f98..0bb695e 100644 --- a/Assets/Scenes/Chief's Sandbox.unity +++ b/Assets/Scenes/Chief's Sandbox.unity @@ -277,49 +277,17 @@ MonoBehaviour: pauseOnBeat: 16 pauseLengthInBeats: 0 beatOffset: 2 ---- !u!1 &531937973 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 3397488661916228000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} +--- !u!114 &531937975 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} m_PrefabInstance: {fileID: 1077224733} m_PrefabAsset: {fileID: 0} ---- !u!114 &531937974 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 531937973} + m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 3147f962613cca54f8a0b78929a2854b, type: 3} m_Name: m_EditorClassIdentifier: - _intensity: {fileID: 11400000, guid: a9fdc2c236f2e264a8e573af06ca295d, type: 2} - _duration: {fileID: 11400000, guid: 650f42715fd5234439ee753fd4bcb106, type: 2} - _anim: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: -2 - outSlope: -2 - tangentMode: 0 - weightedMode: 0 - inWeight: 0 - outWeight: 0 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: -0 - outSlope: -0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0 - outWeight: 0 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 --- !u!1 &728836291 GameObject: m_ObjectHideFlags: 0 @@ -608,6 +576,54 @@ PrefabInstance: propertyPath: m_LocalPosition.z value: -100 objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.size + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[0].time + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[1].time + value: 0.08109998 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[2].time + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[0].value + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[1].value + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[1].inSlope + value: -3.190137 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[2].inSlope + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[1].inWeight + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[1].outSlope + value: -3.190137 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[2].outSlope + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 5076175860835241000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} + propertyPath: _anim.m_Curve.Array.data[1].outWeight + value: 0.09022057 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 1f82f952c53fc7449a0091cf29ba3def, type: 3} --- !u!1 &1173812004 @@ -806,7 +822,7 @@ MonoBehaviour: - {fileID: 1611642542} - {fileID: 728836294} polygon: {fileID: 1639649353} - _cameraShake: {fileID: 0} + _cameraShake: {fileID: 531937975} --- !u!1 &1215971662 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/LoseLife.cs b/Assets/Scripts/LoseLife.cs index aec2f8f..b099c0f 100644 --- a/Assets/Scripts/LoseLife.cs +++ b/Assets/Scripts/LoseLife.cs @@ -22,6 +22,8 @@ public class LoseLife : MonoBehaviour public void LifeLost(int livesLeft) { + _cameraShake.Shake(); + healthMarkers[livesLeft].transform.DOScale(Vector3.zero, 1f).SetEase(Ease.InBack).SetUpdate(true); _health.enabled = false; var timeVal = Time.timeScale; @@ -35,8 +37,6 @@ public class LoseLife : MonoBehaviour sequence.Append(polygon.material.DOFloat(0,"_FlashAmount", 0.2f).SetUpdate(true)); } - _cameraShake.Shake(); - sequence.Play().OnComplete(() => { _health.enabled = true; diff --git a/Assets/Shaders/tunnel.shader b/Assets/Shaders/tunnel.shader index 9653207..d050aad 100644 --- a/Assets/Shaders/tunnel.shader +++ b/Assets/Shaders/tunnel.shader @@ -9,11 +9,13 @@ Shader "custom/tunnel" [HDR] _NebulaColor1("Nebula Color 1", Color) = (1,1,1,1) [HDR] _NebulaColor2("Nebula Color 2", Color) = (1,1,1,1) [HDR] _FractalColor("Fractal Color", Color) = (1,1,1,1) + [HDR] _GroundColor("Ground Color", Color) = (1,1,1,1) _FractalWeight("Fractal Weight", Range(0.0,1.0)) = 1.0 _NebulaWeight("Nebula Weight", Range(0.0,1.0)) = 1.0 _BarsWeight("Bars Weight", Range(0.0,1.0)) = 1.0 _StarsWeight("Stars Weight", Range(0.0,1.0)) = 1.0 + _GroundWeight("Ground Weight", Range(0.0,1.0)) = 1.0 _FractalScale("Fractal Scale", Float) = 6.0 _FractalRotateSpeed("Fractal Rotate Speed", Float) = 20.0 @@ -63,8 +65,9 @@ Shader "custom/tunnel" float4 _BackgroundColor; float4 _NebulaColor1; float4 _NebulaColor2; - float4 _FractalColor; + float4 _GroundColor; + float _FractalScale = 6.0; float _FractalRotateSpeed = 20.0; float _FractalPower = 1.0; @@ -77,6 +80,7 @@ Shader "custom/tunnel" float _BarsWeight; float _StarsWeight; + float _GroundWeight; float _Intensity; float _CameraShake = 0.0; @@ -191,6 +195,20 @@ Shader "custom/tunnel" return fractal * _Intensity * _BarsWeight; } + float4 ground(float2 p, float r, float a) + { + float4 nothing = float4(0,0,0,0); + float angle = PI; + + float t = (abs(a/PI)*PI) * -min(p.y, 0); + t = min(r*0.4, t); + // t += ; + // t *= (1.0-r*0.5); + + // float y = -p.y; + + return lerp(nothing, _GroundColor, t) * _GroundWeight; + } float4 frag(Varyings IN) : SV_Target { @@ -218,6 +236,7 @@ Shader "custom/tunnel" fractal1 *= max(0, r-_FractalInner); fractal1 *= _FractalWeight; fractal1 *= _Intensity; + fractal1 *= max(2.0*normalize(p).y+0.25,0); float2 fuv2 = p / _FractalScale + float2(0.5,0.5); fuv2 = rotateUV(fuv2,-_Time*_FractalRotateSpeed*3.561); @@ -227,12 +246,16 @@ Shader "custom/tunnel" fractal2 *= max(0, r-_FractalInner); fractal2 *= _FractalWeight; fractal2 *= _Intensity; + fractal2 *= max(2.0*normalize(p).y+0.25,0); float4 color = _BackgroundColor; - color += nebula(r, a); - color += bars(r, p); color += fractal1; color += fractal2; + + color -= ground(p, r, a); + + color += nebula(r, a); + color += bars(r, p); color += stars(r, a); // bars, nebula, fractal,