diff --git a/Assets/Data.meta b/Assets/Accessibility.meta similarity index 100% rename from Assets/Data.meta rename to Assets/Accessibility.meta diff --git a/Assets/Accessibility/Accessibility Options.asset b/Assets/Accessibility/Accessibility Options.asset new file mode 100644 index 0000000..921b71e --- /dev/null +++ b/Assets/Accessibility/Accessibility Options.asset @@ -0,0 +1,25 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c271cfa846431634db54fa41238b7b35, type: 3} + m_Name: Accessibility Options + m_EditorClassIdentifier: + _mode: 2 + _calm: + _tunnel: {fileID: 0} + _vibe: + _tunnel: {fileID: 0} + _party: + _tunnel: {fileID: 0} + _intensitySettings: + - _tunnel: {fileID: 0} + - _tunnel: {fileID: 0} + - _tunnel: {fileID: 0} diff --git a/Assets/Accessibility/Accessibility Options.asset.meta b/Assets/Accessibility/Accessibility Options.asset.meta new file mode 100644 index 0000000..194855d --- /dev/null +++ b/Assets/Accessibility/Accessibility Options.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a96923938dea0d542aa804067d5b5e81 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/FMOD/Cache.meta b/Assets/Audio.meta similarity index 77% rename from Assets/Plugins/FMOD/Cache.meta rename to Assets/Audio.meta index d233906..9d7e265 100644 --- a/Assets/Plugins/FMOD/Cache.meta +++ b/Assets/Audio.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 399618523f73e624688f86b01b832ae9 +guid: bf3eaf632c32d8c4c9eef99f2d40d8aa folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Settings/Audio Visualiser Settings.asset b/Assets/Audio/Audio Visualiser.asset similarity index 77% rename from Assets/Settings/Audio Visualiser Settings.asset rename to Assets/Audio/Audio Visualiser.asset index 3ef9da8..bcb4c1e 100644 --- a/Assets/Settings/Audio Visualiser Settings.asset +++ b/Assets/Audio/Audio Visualiser.asset @@ -10,7 +10,7 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: a918b83cb0f52b445bf4975f41eaf321, type: 3} - m_Name: Audio Visualiser Settings + m_Name: Audio Visualiser m_EditorClassIdentifier: _fractalAnimations: - name: _Fractality @@ -18,14 +18,6 @@ MonoBehaviour: channel: 0 sample: 525 _tunnelAnimations: - - name: _OverallPower - multiplier: -1000 - channel: 0 - sample: 173 - - name: _OverallPower - multiplier: -1000 - channel: 0 - sample: 173 - name: _ShakeStrength multiplier: 2 channel: 0 @@ -35,3 +27,4 @@ MonoBehaviour: multiplier: 3703.2 channel: 1 sample: 874 + _accessibility: {fileID: 11400000, guid: a96923938dea0d542aa804067d5b5e81, type: 2} diff --git a/Assets/Settings/Audio Visualiser Settings.asset.meta b/Assets/Audio/Audio Visualiser.asset.meta similarity index 100% rename from Assets/Settings/Audio Visualiser Settings.asset.meta rename to Assets/Audio/Audio Visualiser.asset.meta diff --git a/Assets/Materials/Tunnel.mat b/Assets/Materials/Tunnel_Calm.mat similarity index 91% rename from Assets/Materials/Tunnel.mat rename to Assets/Materials/Tunnel_Calm.mat index 9dbd88a..dd3d362 100644 --- a/Assets/Materials/Tunnel.mat +++ b/Assets/Materials/Tunnel_Calm.mat @@ -20,7 +20,7 @@ Material: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Tunnel + m_Name: Tunnel_Safe m_Shader: {fileID: 4800000, guid: 9d7afb8f866fe8a4cbbf660a52c17084, type: 3} m_ShaderKeywords: m_LightmapFlags: 4 @@ -102,6 +102,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _AlphaClip: 0 + - _BarsWeight: 0 - _Blend: 0 - _BumpScale: 1 - _ClearCoatMask: 0 @@ -112,10 +113,19 @@ Material: - _DetailNormalMapScale: 1 - _DstBlend: 0 - _EnvironmentReflections: 1 + - _FractalInner: 0.3 + - _FractalPower: 1 + - _FractalRotateSpeed: 20 + - _FractalScale: 6 + - _FractalWeight: 0 - _GlossMapScale: 0 - _Glossiness: 0 - _GlossyReflections: 0 + - _Intensity: 1 - _Metallic: 0 + - _Nebula1Power: 1 + - _Nebula2Power: 1 + - _NebulaWeight: 0 - _OcclusionStrength: 1 - _OverallPower: 1 - _Parallax: 0.005 @@ -126,10 +136,12 @@ Material: - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 + - _StarsWeight: 0.1 - _Surface: 0 - _WorkflowMode: 1 - _ZWrite: 1 m_Colors: + - _BackgroundColor: {r: 0.09794411, g: 0.27564344, b: 0.2924528, a: 0} - _BaseColor: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Materials/Tunnel.mat.meta b/Assets/Materials/Tunnel_Calm.mat.meta similarity index 100% rename from Assets/Materials/Tunnel.mat.meta rename to Assets/Materials/Tunnel_Calm.mat.meta diff --git a/Assets/Materials/Tunnel_Party.mat b/Assets/Materials/Tunnel_Party.mat new file mode 100644 index 0000000..706f49f --- /dev/null +++ b/Assets/Materials/Tunnel_Party.mat @@ -0,0 +1,152 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-825856505695050074 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 4 +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Tunnel_Safe 1 + m_Shader: {fileID: 4800000, guid: 9d7afb8f866fe8a4cbbf660a52c17084, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FractalMap: + m_Texture: {fileID: 8400000, guid: 410a70db0834e924c9bff4b2f170f423, type: 2} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NebulaMap: + m_Texture: {fileID: 2800000, guid: 76b8a8711756f0244a896b7e1c505583, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _StarMap: + m_Texture: {fileID: 2800000, guid: c58c631a5672d3442b2210c8883b9bba, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _AlphaClip: 0 + - _BarsWeight: 0 + - _Blend: 0 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _Cull: 2 + - _Cutoff: 0.5 + - _DetailAlbedoMapScale: 1 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _FractalInner: 0.3 + - _FractalPower: 1 + - _FractalRotateSpeed: 20 + - _FractalScale: 6 + - _FractalWeight: 0 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Intensity: 1 + - _Metallic: 0 + - _Nebula1Power: 1 + - _Nebula2Power: 1 + - _NebulaWeight: 0 + - _OcclusionStrength: 1 + - _OverallPower: 1 + - _Parallax: 0.005 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _ShakeStrength: 0 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _StarsWeight: 0.1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BackgroundColor: {r: 0.09794411, g: 0.27564344, b: 0.2924528, a: 0} + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _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} + - _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} + m_BuildTextureStacks: [] diff --git a/Assets/Materials/Tunnel_Party.mat.meta b/Assets/Materials/Tunnel_Party.mat.meta new file mode 100644 index 0000000..afeb7ec --- /dev/null +++ b/Assets/Materials/Tunnel_Party.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 439b4d6018bd23e4e91136d099c5b815 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials/Tunnel_Vibe.mat b/Assets/Materials/Tunnel_Vibe.mat new file mode 100644 index 0000000..706f49f --- /dev/null +++ b/Assets/Materials/Tunnel_Vibe.mat @@ -0,0 +1,152 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-825856505695050074 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 4 +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Tunnel_Safe 1 + m_Shader: {fileID: 4800000, guid: 9d7afb8f866fe8a4cbbf660a52c17084, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _FractalMap: + m_Texture: {fileID: 8400000, guid: 410a70db0834e924c9bff4b2f170f423, type: 2} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NebulaMap: + m_Texture: {fileID: 2800000, guid: 76b8a8711756f0244a896b7e1c505583, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _StarMap: + m_Texture: {fileID: 2800000, guid: c58c631a5672d3442b2210c8883b9bba, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _AlphaClip: 0 + - _BarsWeight: 0 + - _Blend: 0 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _Cull: 2 + - _Cutoff: 0.5 + - _DetailAlbedoMapScale: 1 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _FractalInner: 0.3 + - _FractalPower: 1 + - _FractalRotateSpeed: 20 + - _FractalScale: 6 + - _FractalWeight: 0 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Intensity: 1 + - _Metallic: 0 + - _Nebula1Power: 1 + - _Nebula2Power: 1 + - _NebulaWeight: 0 + - _OcclusionStrength: 1 + - _OverallPower: 1 + - _Parallax: 0.005 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _ShakeStrength: 0 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _StarsWeight: 0.1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BackgroundColor: {r: 0.09794411, g: 0.27564344, b: 0.2924528, a: 0} + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _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} + - _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} + m_BuildTextureStacks: [] diff --git a/Assets/Materials/Tunnel_Vibe.mat.meta b/Assets/Materials/Tunnel_Vibe.mat.meta new file mode 100644 index 0000000..061949e --- /dev/null +++ b/Assets/Materials/Tunnel_Vibe.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9429becea685bce4fa7b6595601ea615 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Rendering.prefab b/Assets/Prefabs/Rendering.prefab index d4385b2..5bc8f0f 100644 --- a/Assets/Prefabs/Rendering.prefab +++ b/Assets/Prefabs/Rendering.prefab @@ -408,7 +408,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2100000, guid: 735a92a62479ffd458216009452fec2b, type: 2} + - {fileID: 2100000, guid: 439b4d6018bd23e4e91136d099c5b815, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -502,10 +502,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3832fa92b7c91804697fe9f4f858b5d4, type: 3} m_Name: m_EditorClassIdentifier: + _ship: {fileID: 0} _fractal: {fileID: 3397488660425852632} _tunnel: {fileID: 3397488660842926088} - _channel: 0 - _sample: 0 + _system: {fileID: 11400000, guid: 65b0561f3154c9f438c3a1e1b443d03d, type: 2} + _accessibility: {fileID: 11400000, guid: a96923938dea0d542aa804067d5b5e81, type: 2} --- !u!1 &3397488661354499722 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/AccessibilityOptions.cs b/Assets/Scripts/AccessibilityOptions.cs new file mode 100644 index 0000000..38d1d3f --- /dev/null +++ b/Assets/Scripts/AccessibilityOptions.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using Unity.Collections; +using UnityEngine; + +[Serializable] +public enum AccessibilityMode +{ + Calm, + Vibe, + Party +} + +[CreateAssetMenu] +public class AccessibilityOptions : ScriptableObject +{ + public AccessibilityMode Mode + { + get => _mode; + set => _mode = value; + } + [SerializeField] private AccessibilityMode _mode; + + [Serializable] + public struct IntensitySetting + { + public Material Tunnel => _tunnel; + [SerializeField] private Material _tunnel; + } + + public IntensitySetting Intensity => this[_mode]; + + [SerializeField] private IntensitySetting _calm; + [SerializeField] private IntensitySetting _vibe; + [SerializeField] private IntensitySetting _party; + + public IntensitySetting this[AccessibilityMode mode] + { + get + { + switch (mode) + { + case AccessibilityMode.Calm: return _calm; + case AccessibilityMode.Vibe: return _vibe; + case AccessibilityMode.Party: return _party; + default: return default; + } + } + } + + // [SerializeField] private IntensitySetting[] _intensitySettings; +} diff --git a/Assets/Scripts/Rendering/AudioVisualizerSettings.cs.meta b/Assets/Scripts/AccessibilityOptions.cs.meta similarity index 83% rename from Assets/Scripts/Rendering/AudioVisualizerSettings.cs.meta rename to Assets/Scripts/AccessibilityOptions.cs.meta index d91f8c8..9c8bee6 100644 --- a/Assets/Scripts/Rendering/AudioVisualizerSettings.cs.meta +++ b/Assets/Scripts/AccessibilityOptions.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a918b83cb0f52b445bf4975f41eaf321 +guid: c271cfa846431634db54fa41238b7b35 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Rendering/AudioVisualizer.cs b/Assets/Scripts/Rendering/AudioVisualizer.cs index ed6b954..4e06118 100644 --- a/Assets/Scripts/Rendering/AudioVisualizer.cs +++ b/Assets/Scripts/Rendering/AudioVisualizer.cs @@ -1,41 +1,89 @@ using System; -using System.Collections; -using System.Collections.Generic; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using FMODUnity; -using NUnit.Framework; -using TMPro; +using FMOD; using UnityEngine; -using UnityEngine.Rendering.Universal; +using INITFLAGS = FMOD.Studio.INITFLAGS; -public class AudioVisualizer : MonoBehaviour +[CreateAssetMenu(menuName = "Audio Visualizer Settings")] +public class AudioVisualizer : ScriptableObject { - [SerializeField] private Renderer _ship; - [SerializeField] private Renderer _fractal; - [SerializeField] private Renderer _tunnel; - [SerializeField] private AudioVisualizerSettings _settings; - - // https://qa.fmod.com/t/getting-spectrum-of-master-channel-in-unity/12579/2 - - // private FMOD.Studio.EventInstance _event; - private FMOD.DSP _fft; - - private float _initialPower; - - private void Start() + [Serializable] + private struct ShaderPropertyAnimation { - // _event = RuntimeManager.CreateInstance("event:/Music"); - - RuntimeManager.CoreSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out _fft); - RuntimeManager.CoreSystem.getMasterChannelGroup(out var channelGroup); - channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, _fft); - - _settings.Initialise(_fractal.material, _tunnel.material, _ship.material); + public string name; + public float multiplier; + [UnityEngine.Range(0, 5)] + public int channel; + [UnityEngine.Range(0, 2048)] + public int sample; + + public float Initial { get; set; } } - private void LateUpdate() + // private Material _fractal; + // private Material _tunnel; + // private Material _ship; + [SerializeField] private ShaderPropertyAnimation[] _fractalAnimations; + [SerializeField] private ShaderPropertyAnimation[] _tunnelAnimations; + [SerializeField] private ShaderPropertyAnimation[] _shipAnimations; + [SerializeField] private AccessibilityOptions _accessibility; + + public void Initialise(Material fractal, Material tunnel, Material ship) { - _settings.Update(_fft, _fractal, _tunnel, _ship); + // _fractal = fractal; + // _tunnel = tunnel; + // _ship = ship; + + InitialiseAnimations(_fractalAnimations, fractal); + InitialiseAnimations(_tunnelAnimations, tunnel); + InitialiseAnimations(_shipAnimations, ship); } -} \ No newline at end of file + + private void InitialiseAnimations(ShaderPropertyAnimation[] animations, Material material) + { + for (int i = 0; i < animations.Length; i++) + { + var anim = animations[i]; + anim.Initial = material.GetFloat(anim.name); + animations[i] = anim; + } + } + + public void Update(DSP fft, Renderer fractal, Renderer tunnel, Renderer ship) + { + fft.getParameterData((int) FMOD.DSP_FFT.SPECTRUMDATA, out var unmanagedData, out var length); + var fftData = (FMOD.DSP_PARAMETER_FFT) Marshal.PtrToStructure(unmanagedData, typeof(FMOD.DSP_PARAMETER_FFT)); + + var spectrum = fftData.spectrum; + var l = spectrum.Length; + if (l == 0) return; + + for (int i = 0; i < _fractalAnimations.Length; i++) + { + var anim = _fractalAnimations[i]; + var a = spectrum[anim.channel][anim.sample]; + + fractal.material.SetFloat(anim.name, anim.Initial + anim.multiplier * a); + } + + for (int i = 0; i < _tunnelAnimations.Length; i++) + { + var anim = _tunnelAnimations[i]; + var a = spectrum[anim.channel][anim.sample]; + + tunnel.material.SetFloat(anim.name, anim.Initial + anim.multiplier * a); + } + + UpdateAnimations(spectrum, _shipAnimations, ship); + } + + private void UpdateAnimations(float[][] spectrum, ShaderPropertyAnimation[] animations, Renderer renderer) + { + for (int i = 0; i < animations.Length; i++) + { + var anim = animations[i]; + var a = spectrum[anim.channel][anim.sample]; + renderer.material.SetFloat(anim.name, anim.Initial + anim.multiplier * a); + } + } +} diff --git a/Assets/Scripts/Rendering/AudioVisualizer.cs.meta b/Assets/Scripts/Rendering/AudioVisualizer.cs.meta index 9b7b31e..d91f8c8 100644 --- a/Assets/Scripts/Rendering/AudioVisualizer.cs.meta +++ b/Assets/Scripts/Rendering/AudioVisualizer.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3832fa92b7c91804697fe9f4f858b5d4 +guid: a918b83cb0f52b445bf4975f41eaf321 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Rendering/AudioVisualizerRuntime.cs b/Assets/Scripts/Rendering/AudioVisualizerRuntime.cs new file mode 100644 index 0000000..0f3eb6d --- /dev/null +++ b/Assets/Scripts/Rendering/AudioVisualizerRuntime.cs @@ -0,0 +1,43 @@ +using System; +using FMODUnity; +using UnityEngine; + +public class AudioVisualizerRuntime : MonoBehaviour +{ + [SerializeField] private Renderer _ship; + [SerializeField] private Renderer _fractal; + [SerializeField] private Renderer _tunnel; + [SerializeField] private AudioVisualizer _system; + [SerializeField] private AccessibilityOptions _accessibility; + + // https://qa.fmod.com/t/getting-spectrum-of-master-channel-in-unity/12579/2 + + // private FMOD.Studio.EventInstance _event; + private FMOD.DSP _fft; + + private float _initialPower; + + private void Awake() + { + // pick correct materials for accessibility + // _ship.material = _accessibility.Intensity.Ship; + _tunnel.material = new Material(_accessibility.Intensity.Tunnel); + } + + private void Start() + { + // _event = RuntimeManager.CreateInstance("event:/Music"); + + RuntimeManager.CoreSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out _fft); + RuntimeManager.CoreSystem.getMasterChannelGroup(out var channelGroup); + channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, _fft); + + + _system.Initialise(_fractal.material, _tunnel.material, _ship.material); + } + + private void LateUpdate() + { + _system.Update(_fft, _fractal, _tunnel, _ship); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Rendering/AudioVisualizerRuntime.cs.meta b/Assets/Scripts/Rendering/AudioVisualizerRuntime.cs.meta new file mode 100644 index 0000000..9b7b31e --- /dev/null +++ b/Assets/Scripts/Rendering/AudioVisualizerRuntime.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3832fa92b7c91804697fe9f4f858b5d4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Rendering/AudioVisualizerSettings.cs b/Assets/Scripts/Rendering/AudioVisualizerSettings.cs deleted file mode 100644 index 3769532..0000000 --- a/Assets/Scripts/Rendering/AudioVisualizerSettings.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using FMOD; -using UnityEngine; -using INITFLAGS = FMOD.Studio.INITFLAGS; - -[CreateAssetMenu(menuName = "Audio Visualizer Settings")] -public class AudioVisualizerSettings : ScriptableObject -{ - [Serializable] - private struct ShaderPropertyAnimation - { - public string name; - public float multiplier; - [UnityEngine.Range(0, 5)] - public int channel; - [UnityEngine.Range(0, 2048)] - public int sample; - - public float Initial { get; set; } - } - - [SerializeField] private ShaderPropertyAnimation[] _fractalAnimations; - [SerializeField] private ShaderPropertyAnimation[] _tunnelAnimations; - [SerializeField] private ShaderPropertyAnimation[] _shipAnimations; - - public void Initialise(Material fractal, Material tunnel, Material ship) - { - InitialiseAnimations(_fractalAnimations, fractal); - InitialiseAnimations(_tunnelAnimations, tunnel); - InitialiseAnimations(_shipAnimations, ship); - } - - private void InitialiseAnimations(ShaderPropertyAnimation[] animations, Material material) - { - for (int i = 0; i < animations.Length; i++) - { - var anim = animations[i]; - anim.Initial = material.GetFloat(anim.name); - animations[i] = anim; - } - } - - public void Update(DSP fft, Renderer fractal, Renderer tunnel, Renderer ship) - { - fft.getParameterData((int) FMOD.DSP_FFT.SPECTRUMDATA, out var unmanagedData, out var length); - var fftData = (FMOD.DSP_PARAMETER_FFT) Marshal.PtrToStructure(unmanagedData, typeof(FMOD.DSP_PARAMETER_FFT)); - - var spectrum = fftData.spectrum; - var l = spectrum.Length; - if (l == 0) return; - - for (int i = 0; i < _fractalAnimations.Length; i++) - { - var anim = _fractalAnimations[i]; - var a = spectrum[anim.channel][anim.sample]; - - fractal.material.SetFloat(anim.name, anim.Initial + anim.multiplier * a); - } - - for (int i = 0; i < _tunnelAnimations.Length; i++) - { - var anim = _tunnelAnimations[i]; - var a = spectrum[anim.channel][anim.sample]; - - tunnel.material.SetFloat(anim.name, anim.Initial + anim.multiplier * a); - } - - UpdateAnimations(spectrum, _shipAnimations, ship); - } - - private void UpdateAnimations(float[][] spectrum, ShaderPropertyAnimation[] animations, Renderer renderer) - { - for (int i = 0; i < animations.Length; i++) - { - var anim = animations[i]; - var a = spectrum[anim.channel][anim.sample]; - renderer.material.SetFloat(anim.name, anim.Initial + anim.multiplier * a); - } - } -} diff --git a/Assets/Shaders/tunnel.shader b/Assets/Shaders/tunnel.shader index a945ff2..d198f33 100644 --- a/Assets/Shaders/tunnel.shader +++ b/Assets/Shaders/tunnel.shader @@ -5,17 +5,31 @@ Shader "custom/tunnel" // called Base Map. Properties { + _BackgroundColor("Background Color", Color) = (0,0,0,0) [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) + _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 + + _FractalScale("Fractal Scale", Float) = 6.0 + _FractalRotateSpeed("Fractal Rotate Speed", Float) = 20.0 + _FractalPower("Fractal Power", Float) = 1.0 + _FractalInner("Fractal Inner", Float) = 0.2 + + _Nebula1Power("Nebula 1 Power", Float) = 1.0 + _Nebula2Power("Nebula 2 Power", Float) = 1.0 + _NebulaMap("Nebula Map", 2D) = "black" _StarMap("Star Map", 2D) = "black" _FractalMap("Fractal Map", 2D) = "black" _ShakeStrength("Shake Strength", Float) = 0.01 - _OverallPower("Overall Power", Float) = 1.0 + _Intensity("Intensity", Float) = 1.0 } SubShader @@ -46,14 +60,27 @@ Shader "custom/tunnel" float2 uv : TEXCOORD0; }; + float4 _BackgroundColor; float4 _NebulaColor1; float4 _NebulaColor2; + float4 _FractalColor; + float _FractalScale = 6.0; + float _FractalRotateSpeed = 20.0; + float _FractalPower = 1.0; + float _FractalInner = 0.2; + float _FractalWeight = 1.0; + float _Nebula1Power = 1.0; + float _Nebula2Power = 1.0; + float _NebulaWeight = 1.0; + + float _BarsWeight; + float _StarsWeight; + + float _Intensity; float _ShakeStrength; - float _OverallPower; - TEXTURE2D(_NebulaMap); SAMPLER(sampler_NebulaMap); TEXTURE2D(_StarMap); @@ -87,9 +114,85 @@ Shader "custom/tunnel" cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid ); } - - half4 frag(Varyings IN) : SV_Target + float4 nebula(float r, float a) + { + // sample nebula 1 + float n1_stretch = 1.0/50.0; + float n1_speed = 20.0; + float n1_spin = 10.0; + // float n1_power = 2.0; + float n1_cutoff = 0.5; + + float2 nuv1; + nuv1.x = n1_stretch/(r*r) + _Time * n1_speed; + nuv1.y = a/PI + _Time * n1_spin; + half4 nebula1 = SAMPLE_TEXTURE2D(_NebulaMap, sampler_NebulaMap, nuv1); + nebula1 *= _NebulaColor1; + nebula1 *= max(0,_Nebula1Power*r-n1_cutoff); + + // sample nebula 2 - same as nebula 1 but in another direction + float n2_stretch = 1.0/100.0; + float n2_speed = 30.0; + float n2_spin = -5.0; + // float n2_power = 4.0; + float n2_cutoff = 0.5; + + float2 nuv2; + nuv2.x = n2_stretch/(r*r) + _Time * n2_speed; + nuv2.y = a/PI + _Time * n2_spin; + half4 nebula2 = SAMPLE_TEXTURE2D(_NebulaMap, sampler_NebulaMap, nuv2.yx); + nebula2 *= _NebulaColor2; + nebula2 *= max(0,_Nebula2Power*r - n2_cutoff); + + return (nebula1 + nebula2) * _Intensity * _NebulaWeight; + } + + float4 stars(float r, float a) + { + // sample stars + float starStretch = 1.0/100.0; + float starSpeed = 10.0 * _Intensity; + float starWrap = 3.5f; + + // star uv + float2 suv; + // use the root to make them into radial lines instead of a tunnel + suv.x = starStretch/sqrt(r) + _Time * starSpeed; + suv.y = (float)starWrap*a/PI; + half4 star = SAMPLE_TEXTURE2D(_StarMap, sampler_StarMap, suv); + star *= r * r * 2.0; + + return star * _Intensity * _StarsWeight; + } + + // same as fractals but calling it from a function turns them into bars?? + float4 bars(float r, float p) + { + // fractal uv + float2 fuv1 = p / _FractalScale + float2(0.5,0.5); + fuv1 = rotateUV(fuv1,_Time*_FractalRotateSpeed); + half4 fractal1 = SAMPLE_TEXTURE2D(_FractalMap, sampler_FractalMap, fuv1); + fractal1 *= _FractalColor; + fractal1 *= max(0, r-_FractalInner); + fractal1 *= _FractalPower; + + // fractal 2 + float2 fuv2 = p / _FractalScale + float2(0.5,0.5); + fuv2 = rotateUV(fuv2,-_Time*_FractalRotateSpeed*3.561); + fuv2.x=1.0-fuv2.x; + half4 fractal2 = SAMPLE_TEXTURE2D(_FractalMap, sampler_FractalMap, fuv2); + fractal2 *= _FractalColor * sin(_Time*3); + fractal2 *= max(0, r-_FractalInner); + fractal2 *= _FractalPower; + + half4 fractal = max(fractal1,fractal2) * _Intensity; + + return fractal * _Intensity * _BarsWeight; + } + + + float4 frag(Varyings IN) : SV_Target { float2 res = _ScreenParams; float2 p = -1.0+2.0*IN.positionHCS.xy/res.xy; @@ -100,87 +203,42 @@ Shader "custom/tunnel" cameraShake.x = cos(shake*12.3341)+sin(shake*19.231057); cameraShake.y = cos(shake*17.12311)+sin(shake*14.2315165); cameraShake*=_ShakeStrength; - p += cameraShake; + // p += cameraShake; // shared tunnel vars float r = length(p); float a = atan(p.y/p.x); - - // sample nebula 1 - float n1_stretch = 1.0/50.0; - float n1_speed = 20.0; - float n1_spin = 10.0; - float n1_power = 2.0; - float n1_cutoff = 0.5; - - float2 nuv1; - nuv1.x = n1_stretch/(r*r) + _Time * n1_speed; - nuv1.y = a/PI + _Time * n1_spin; - half4 nebula1 = SAMPLE_TEXTURE2D(_NebulaMap, sampler_NebulaMap, nuv1); - nebula1 *= _NebulaColor1; - nebula1 *= max(0,n1_power*r-n1_cutoff); - - // sample nebula 2 - same as nebula 1 but in another direction - float n2_stretch = 1.0/100.0; - float n2_speed = 30.0; - float n2_spin = -5.0; - float n2_power = 4.0; - float n2_cutoff = 0.5; - float2 nuv2; - nuv2.x = n2_stretch/(r*r) + _Time * n2_speed; - nuv2.y = a/PI + _Time * n2_spin; - half4 nebula2 = SAMPLE_TEXTURE2D(_NebulaMap, sampler_NebulaMap, nuv2.yx); - nebula2 *= _NebulaColor2; - nebula2 *= max(0,n2_power*r - n2_cutoff); - - // sample stars - float starStretch = 1.0/100.0; - float starSpeed = 10.0; - int starWrap = 3; - - // star uv - float2 suv; - // use the root to make them into radial lines instead of a tunnel - suv.x = starStretch/sqrt(r) + _Time * starSpeed; - suv.y = (float)starWrap*a/PI; - half4 star = SAMPLE_TEXTURE2D(_StarMap, sampler_StarMap, suv); - star *= r * r * 2.0; - - // sample fractal - float fractalScale = 6.0; - float fractalRotateSpeed = 20.0; - float fractalPower = 1.0; - float fractal_inner = 0.2; - - // fractal uv - float2 fuv1 = p / fractalScale + float2(0.5,0.5); - fuv1 = rotateUV(fuv1,_Time*fractalRotateSpeed); + // for some reason trying to sample the fractal in a function turns it into bars + // looks cool but no idea why it happens so these fractals are inline + float2 fuv1 = p / _FractalScale + float2(0.5,0.5); + fuv1 = rotateUV(fuv1,_Time*_FractalRotateSpeed); half4 fractal1 = SAMPLE_TEXTURE2D(_FractalMap, sampler_FractalMap, fuv1); fractal1 *= _FractalColor; - fractal1 *= max(0, r-fractal_inner); - fractal1 *= fractalPower*0.5; - - // fractal 2 - float2 fuv2 = rotateUV(fuv1,-_Time*fractalRotateSpeed*3.561); + fractal1 *= max(0, r-_FractalInner); + fractal1 *= _FractalWeight; + fractal1 *= _Intensity; + + float2 fuv2 = p / _FractalScale + float2(0.5,0.5); + fuv2 = rotateUV(fuv2,-_Time*_FractalRotateSpeed*3.561); fuv2.x=1.0-fuv2.x; half4 fractal2 = SAMPLE_TEXTURE2D(_FractalMap, sampler_FractalMap, fuv2); fractal2 *= _FractalColor * sin(_Time*3); - fractal2 *= max(0, r-fractal_inner); - fractal2 *= fractalPower*0.5; - - half4 fractal = max(fractal1,fractal2); + fractal2 *= max(0, r-_FractalInner); + fractal2 *= _FractalWeight; + fractal2 *= _Intensity; - half4 color = half4(0,0,0,0); - color += nebula1; - color += nebula2; - color += fractal; - // color += fractal1; - // color += fractal2; - color += star; + float4 color = _BackgroundColor; + color += nebula(r, a); + color += bars(r, p); + color += fractal1; + color += fractal2; + color += stars(r, a); + // bars, nebula, fractal, + // average across all fx + color = saturate(color); - color *= _OverallPower; return color; }