├── .gitignore ├── Assets ├── Raymarching.meta ├── Raymarching │ ├── Docs.meta │ ├── Materials.meta │ ├── Materials │ │ ├── TextureMaterial.asset │ │ └── TextureMaterial.asset.meta │ ├── Modifiers.meta │ ├── Modifiers │ │ ├── Bend.asset │ │ ├── Bend.asset.meta │ │ ├── Displacement3D.asset │ │ ├── Displacement3D.asset.meta │ │ ├── Displacement4D.asset │ │ ├── Displacement4D.asset.meta │ │ ├── InfiniteRepetition.asset │ │ ├── InfiniteRepetition.asset.meta │ │ ├── Onion.asset │ │ ├── Onion.asset.meta │ │ ├── SineWave.asset │ │ ├── SineWave.asset.meta │ │ ├── TwistX.asset │ │ ├── TwistX.asset.meta │ │ ├── TwistY.asset │ │ ├── TwistY.asset.meta │ │ ├── TwistZ.asset │ │ └── TwistZ.asset.meta │ ├── Operations.meta │ ├── Operations │ │ ├── Blend.asset │ │ ├── Blend.asset.meta │ │ ├── Cut.asset │ │ ├── Cut.asset.meta │ │ ├── Mask.asset │ │ ├── Mask.asset.meta │ │ ├── SmoothCut.asset │ │ ├── SmoothCut.asset.meta │ │ ├── SmoothMask.asset │ │ └── SmoothMask.asset.meta │ ├── Raymarching.asmdef │ ├── Raymarching.asmdef.meta │ ├── SDFs.meta │ ├── SDFs │ │ ├── Capsule.asset │ │ ├── Capsule.asset.meta │ │ ├── Cube.asset │ │ ├── Cube.asset.meta │ │ ├── Hypercube.asset │ │ ├── Hypercube.asset.meta │ │ ├── Sphere.asset │ │ └── Sphere.asset.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── Raymarch.cs │ │ ├── Raymarch.cs.meta │ │ ├── RaymarchBase.cs │ │ ├── RaymarchBase.cs.meta │ │ ├── RaymarchCamera.cs │ │ ├── RaymarchCamera.cs.meta │ │ ├── RaymarchEditor.cs │ │ ├── RaymarchEditor.cs.meta │ │ ├── RaymarchLight.cs │ │ ├── RaymarchLight.cs.meta │ │ ├── RaymarchObject.cs │ │ ├── RaymarchObject.cs.meta │ │ ├── RaymarchOperation.cs │ │ ├── RaymarchOperation.cs.meta │ │ ├── RaymarchRenderFeature.cs │ │ ├── RaymarchRenderFeature.cs.meta │ │ ├── RaymarchScene.cs │ │ ├── RaymarchScene.cs.meta │ │ ├── RaymarchShaderGen.cs │ │ ├── RaymarchShaderGen.cs.meta │ │ ├── Shader.meta │ │ ├── Shader │ │ │ ├── ParameterType.cs │ │ │ ├── ParameterType.cs.meta │ │ │ ├── ShaderType.cs │ │ │ ├── ShaderType.cs.meta │ │ │ ├── ShaderVariable.cs │ │ │ └── ShaderVariable.cs.meta │ │ ├── ShaderFeatures.meta │ │ ├── ShaderFeatures │ │ │ ├── MaterialShaderFeatureAsset.cs │ │ │ ├── MaterialShaderFeatureAsset.cs.meta │ │ │ ├── ModifierShaderFeatureAsset.cs │ │ │ ├── ModifierShaderFeatureAsset.cs.meta │ │ │ ├── OperationShaderFeatureAsset.cs │ │ │ ├── OperationShaderFeatureAsset.cs.meta │ │ │ ├── SDFShaderFeatureAsset.cs │ │ │ ├── SDFShaderFeatureAsset.cs.meta │ │ │ ├── ShaderFeature.cs │ │ │ ├── ShaderFeature.cs.meta │ │ │ ├── ShaderFeatureAsset.cs │ │ │ ├── ShaderFeatureAsset.cs.meta │ │ │ ├── ToggleableShaderFeature.cs │ │ │ └── ToggleableShaderFeature.cs.meta │ │ ├── Util.meta │ │ └── Util │ │ │ ├── RenderPipelineDefines.cs │ │ │ ├── RenderPipelineDefines.cs.meta │ │ │ ├── SerializableGuid.cs │ │ │ ├── SerializableGuid.cs.meta │ │ │ ├── Util.cs │ │ │ └── Util.cs.meta │ ├── Shaders.meta │ └── Shaders │ │ ├── Generated.meta │ │ ├── Generated │ │ ├── MaterialFunctions.hlsl │ │ ├── MaterialFunctions.hlsl.meta │ │ ├── ModifierFunctions.hlsl │ │ ├── ModifierFunctions.hlsl.meta │ │ ├── OperationFunctions.hlsl │ │ ├── OperationFunctions.hlsl.meta │ │ ├── SDFFunctions.hlsl │ │ └── SDFFunctions.hlsl.meta │ │ ├── Light.hlsl │ │ ├── Light.hlsl.meta │ │ ├── RaymarchTemplateShader.shader │ │ ├── RaymarchTemplateShader.shader.meta │ │ ├── Structs.hlsl │ │ └── Structs.hlsl.meta ├── Scenes.meta ├── Scenes │ ├── RayMarching.unity │ ├── RayMarching.unity.meta │ ├── Raymarching.meta │ └── Raymarching │ │ ├── Global Volume Profile.asset │ │ ├── Global Volume Profile.asset.meta │ │ ├── RayMarching_RaymarchShader.shader │ │ ├── RayMarching_RaymarchShader.shader.meta │ │ ├── Raymarching Skybox.mat │ │ └── Raymarching Skybox.mat.meta ├── Scripts.meta ├── Scripts │ ├── DirtyFlag.cs │ ├── DirtyFlag.cs.meta │ ├── Editor.meta │ ├── ScreenCanvasFPS.cs │ ├── ScreenCanvasFPS.cs.meta │ ├── ScreenCanvasNameAndVersionText.cs │ ├── ScreenCanvasNameAndVersionText.cs.meta │ ├── SimpleCameraController.cs │ └── SimpleCameraController.cs.meta ├── TextMesh Pro.meta ├── URP.meta ├── URP │ ├── UniversalRP-HighQuality.asset │ ├── UniversalRP-HighQuality.asset.meta │ ├── UniversalRP-LowQuality.asset │ ├── UniversalRP-LowQuality.asset.meta │ ├── UniversalRP-MediumQuality.asset │ ├── UniversalRP-MediumQuality.asset.meta │ ├── UniversalRenderPipelineGlobalSettings.asset │ ├── UniversalRenderPipelineGlobalSettings.asset.meta │ ├── UniversalRenderer.asset │ └── UniversalRenderer.asset.meta ├── XR.meta └── XR │ ├── Loaders.meta │ ├── Loaders │ ├── Mock HMD Loader.asset │ ├── Mock HMD Loader.asset.meta │ ├── Open XR Loader No Pre Init.asset │ ├── Open XR Loader No Pre Init.asset.meta │ ├── Open XR Loader.asset │ └── Open XR Loader.asset.meta │ ├── Settings.meta │ ├── Settings │ ├── Mock HMD Build Settings.asset │ ├── Mock HMD Build Settings.asset.meta │ ├── Open XR Package Settings.asset │ ├── Open XR Package Settings.asset.meta │ ├── OpenXR Editor Settings.asset │ └── OpenXR Editor Settings.asset.meta │ ├── XRGeneralSettings.asset │ └── XRGeneralSettings.asset.meta ├── Docs ├── GettingStarted.md ├── README.md ├── RaymarchObjects.md ├── RaymarchRenderFeature.md ├── RaymarchScene.md └── SDFShaderFeature.md ├── LICENSE.md ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── BurstAotSettings_StandaloneWindows.json ├── ClusterInputManager.asset ├── CommonBurstAotSettings.json ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── MemorySettings.asset ├── NavMeshAreas.asset ├── PackageManagerSettings.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── SceneTemplateSettings.json ├── ShaderGraphSettings.asset ├── TagManager.asset ├── TimeManager.asset ├── TimelineSettings.asset ├── URPProjectSettings.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset ├── XRPackageSettings.asset ├── XRSettings.asset └── boot.config ├── README.md └── UserSettings ├── EditorUserSettings.asset ├── Layouts ├── CurrentMaximizeLayout.dwlt └── default-2021.dwlt └── Search.settings /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Never ignore Asset meta data 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # TextMesh Pro files 20 | [Aa]ssets/TextMesh*Pro/ 21 | 22 | # Autogenerated Jetbrains Rider plugin 23 | [Aa]ssets/Plugins/Editor/JetBrains* 24 | 25 | # Visual Studio cache directory 26 | .vs/ 27 | 28 | # Jetbrains 29 | .idea/ 30 | 31 | # Gradle cache directory 32 | .gradle/ 33 | 34 | # Autogenerated VS/MD/Consulo solution and project files 35 | ExportedObj/ 36 | .consulo/ 37 | *.csproj 38 | *.unityproj 39 | *.sln 40 | *.suo 41 | *.tmp 42 | *.user 43 | *.userprefs 44 | *.pidb 45 | *.booproj 46 | *.svd 47 | *.pdb 48 | *.mdb 49 | *.opendb 50 | *.VC.db 51 | 52 | # Unity3D generated meta files 53 | *.pidb.meta 54 | *.pdb.meta 55 | *.mdb.meta 56 | 57 | # Unity3D generated file on crash reports 58 | sysinfo.txt 59 | 60 | # Builds 61 | *.apk 62 | *.unitypackage 63 | 64 | # Crashlytics generated file 65 | crashlytics-build.properties 66 | 67 | .obsidian/ 68 | 69 | -------------------------------------------------------------------------------- /Assets/Raymarching.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ebb6e28454fbbef41bca495324d5cf73 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Docs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c3ce65e23fe33f148821d440f2f7c2dd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e7bf2f433c2a75499caf9bd1cb131e5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Materials/TextureMaterial.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 89849a2e411c49f28d5b63ed77a2023d, type: 3} 13 | m_Name: TextureMaterial 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 375473c31f33804fa12534d02a465e6a 17 | functionBody: "float3x3 R = float3x3(float3(cos(_Time.y),sin(_Time.y),0),float3(-sin(_Time.y),cos(_Time.y),0),float3(0,0,-1));\n//pos 18 | = \rmul(pos, R / 8);\n\n\nreturn float4(\nfloat3((tex2D(Texture,\r pos.xy).rgb\n+ 19 | tex2D(Texture, pos.zy).rgb\n + tex2D(Texture, pos.xz).rgb) /\r 3.0), 1) * colour;" 20 | shaderVariables: 21 | - name: Texture 22 | shaderType: 7 23 | parameterType: 0 24 | floatValue: 0 25 | intValue: 0 26 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 27 | textureValue: {fileID: 0} 28 | -------------------------------------------------------------------------------- /Assets/Raymarching/Materials/TextureMaterial.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68533ef4ca7169043bf7d7199392d505 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f3e7469a9779f3408e5866ed5f51c3f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/Bend.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c992fa5b27b1504439742fa83be21c99, type: 3} 13 | m_Name: Bend 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 2be6754ffa059042bc9060a1615db095 17 | functionBody: 'float c = cos(BendAmount*pos.x); 18 | 19 | float s = sin(BendAmount*pos.x); 20 | 21 | float2x2 22 | m = float2x2(c,-s,s,c); 23 | 24 | return float4(mul(m,pos.xy), pos.z, pos.w); ' 25 | shaderVariables: 26 | - name: BendAmount 27 | shaderType: 0 28 | parameterType: 0 29 | floatValue: 0 30 | intValue: 0 31 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 32 | textureValue: {fileID: 0} 33 | modifierType: 0 34 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/Bend.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d077c243d9fe2b843b642edbd11a0c37 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/Displacement3D.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c992fa5b27b1504439742fa83be21c99, type: 3} 13 | m_Name: Displacement3D 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 1f69611ae90bd64eb83151f90f2fefb1 17 | functionBody: 'float displacement = sin(Displacement*pos.x)*sin(Displacement*pos.y)*sin(Displacement*pos.z); 18 | 19 | 20 | return 21 | objDistance + displacement;' 22 | shaderVariables: 23 | - name: Displacement 24 | shaderType: 0 25 | parameterType: 0 26 | floatValue: 1 27 | intValue: 0 28 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 29 | textureValue: {fileID: 0} 30 | modifierType: 1 31 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/Displacement3D.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4af6b268508dd2a43a8d86ed2f062ed4 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/Displacement4D.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c992fa5b27b1504439742fa83be21c99, type: 3} 13 | m_Name: Displacement4D 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 1f69611ae90bd64eb83151f90f2fefb1 17 | functionBody: 'float displacement = sin(Displacement*pos.x)*sin(Displacement*pos.y)*sin(Displacement*pos.z)*sin(Displacement*pos.w); 18 | 19 | 20 | return 21 | objDistance + displacement;' 22 | shaderVariables: 23 | - name: Displacement 24 | shaderType: 0 25 | parameterType: 0 26 | floatValue: 1 27 | intValue: 0 28 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 29 | textureValue: {fileID: 0} 30 | modifierType: 1 31 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/Displacement4D.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2d1c2401020c6348b1e535ffe022032 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/InfiniteRepetition.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c992fa5b27b1504439742fa83be21c99, type: 3} 13 | m_Name: InfiniteRepetition 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 0f272c802c4045489b9597d4fb74dba8 17 | functionBody: return fmod(pos + 0.5 * RepPeriod, RepPeriod) - 0.5 * RepPeriod; 18 | shaderVariables: 19 | - name: RepPeriod 20 | shaderType: 5 21 | parameterType: 0 22 | floatValue: 0 23 | intValue: 0 24 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 25 | textureValue: {fileID: 0} 26 | modifierType: 0 27 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/InfiniteRepetition.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc32ea7368ee12e40b977ebb0e658972 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/Onion.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c992fa5b27b1504439742fa83be21c99, type: 3} 13 | m_Name: Onion 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 6fc5baec62384a428fad6d23b416efe1 17 | functionBody: return abs(objDistance) - Thickness; 18 | shaderVariables: 19 | - name: Thickness 20 | shaderType: 0 21 | floatValue: 0 22 | intValue: 0 23 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 24 | textureValue: {fileID: 0} 25 | modifierType: 1 26 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/Onion.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8819671c347cd24e9b6345d52827ed4 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/SineWave.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c992fa5b27b1504439742fa83be21c99, type: 3} 13 | m_Name: SineWave 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 51c7bfa635b10744833fc4a471b08d44 17 | functionBody: " float direction = 0;\r\n\r\n if (Dir.x >= 1)\r\n 18 | {\r\n direction += pos.x;\r\n }\r\n else if (Dir.x <= 19 | -1)\r\n {\r\n direction -= pos.x;\r\n }\r\n\r\n 20 | if (Dir.y >= 1)\r\n {\r\n direction += pos.y;\r\n }\r\n 21 | else if (Dir.y <= -1)\r\n {\r\n direction -= pos.y;\r\n 22 | }\r\n\r\n if (Dir.z >= 1)\r\n {\r\n direction += pos.z;\r\n 23 | }\r\n else if (Dir.z <= -1)\r\n {\r\n direction -= pos.z;\r\n 24 | }\r\n\nif(Dir.w >=1)\n{\ndirection += pos.w;\n}\nelse if (Dir.w <= -1)\n{\ndirection 25 | -= pos.w;\n}\n\r\n return objDistance - sin(direction * Freq +\r (_Time.y 26 | * Speed)) * Amplitude;" 27 | shaderVariables: 28 | - name: Freq 29 | shaderType: 0 30 | parameterType: 0 31 | floatValue: 1 32 | intValue: 0 33 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 34 | textureValue: {fileID: 0} 35 | - name: Amplitude 36 | shaderType: 0 37 | parameterType: 0 38 | floatValue: 1 39 | intValue: 0 40 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 41 | textureValue: {fileID: 0} 42 | - name: Speed 43 | shaderType: 0 44 | parameterType: 0 45 | floatValue: 1 46 | intValue: 0 47 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 48 | textureValue: {fileID: 0} 49 | - name: Dir 50 | shaderType: 5 51 | parameterType: 0 52 | floatValue: 0 53 | intValue: 0 54 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 55 | textureValue: {fileID: 0} 56 | modifierType: 1 57 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/SineWave.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d15e6185016c744a9889f3a16680f33 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/TwistX.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c992fa5b27b1504439742fa83be21c99, type: 3} 13 | m_Name: TwistX 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 70adafa266a33e44ad7b8bf1ce7c82fc 17 | functionBody: 'float c = cos(TwistAmountX*pos.x); 18 | 19 | float s = sin(TwistAmountX*pos.x); 20 | 21 | float2x2 22 | m = float2x2(c,-s,s,c); 23 | 24 | return float4(mul(m,pos.yz), pos.x, pos.w);' 25 | shaderVariables: 26 | - name: TwistAmountX 27 | shaderType: 0 28 | parameterType: 0 29 | floatValue: 0 30 | intValue: 0 31 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 32 | textureValue: {fileID: 0} 33 | modifierType: 0 34 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/TwistX.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 858292388241dbd4ea44d3c47402103f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/TwistY.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c992fa5b27b1504439742fa83be21c99, type: 3} 13 | m_Name: TwistY 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 5463cc848643f2458030230feaa53e13 17 | functionBody: 'float c = cos(TwistAmountY*pos.y); 18 | 19 | float s = sin(TwistAmountY*pos.y); 20 | 21 | float2x2 22 | m = float2x2(c,-s,s,c); 23 | 24 | return float4(mul(m,pos.xz), pos.y, pos.w);' 25 | shaderVariables: 26 | - name: TwistAmountY 27 | shaderType: 0 28 | parameterType: 0 29 | floatValue: 0 30 | intValue: 0 31 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 32 | textureValue: {fileID: 0} 33 | modifierType: 0 34 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/TwistY.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a50f5e34812b6c14c8d5509d2c236cbb 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/TwistZ.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c992fa5b27b1504439742fa83be21c99, type: 3} 13 | m_Name: TwistZ 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 9435d0c1c1175747b9996d01b0db1171 17 | functionBody: 'float c = cos(TwistAmountZ*pos.z); 18 | 19 | float s = sin(TwistAmountZ*pos.z); 20 | 21 | float2x2 22 | m = float2x2(c,-s,s,c); 23 | 24 | return float4( mul(m,pos.xy), pos.z, pos.w);' 25 | shaderVariables: 26 | - name: TwistAmountZ 27 | shaderType: 0 28 | parameterType: 0 29 | floatValue: 0 30 | intValue: 0 31 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 32 | textureValue: {fileID: 0} 33 | modifierType: 0 34 | -------------------------------------------------------------------------------- /Assets/Raymarching/Modifiers/TwistZ.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f8fe211ce69b3a4fb2b636b90d0d954 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 709e9bd738d135a47a55fc3ac0f71014 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations/Blend.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: ff5ef3ef526b46b48b17cc45c3c240ac, type: 3} 13 | m_Name: Blend 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: b6118cc054fc344586aa264d1da70b87 17 | functionBody: "float h = clamp(0.5 + 0.5 * (objDistance - resultDistance) / Smooth, 18 | 0.0, 1.0);\r\n \nresultDistance = lerp(objDistance, resultDistance, 19 | h) - Smooth * h * (1.0 - h);\r\nresultColour = lerp(objColour, resultColour, 20 | h);" 21 | shaderVariables: 22 | - name: Smooth 23 | shaderType: 0 24 | parameterType: 0 25 | floatValue: 1 26 | intValue: 0 27 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 28 | textureValue: {fileID: 0} 29 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations/Blend.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25e623070afac8141a93080a379dfa8c 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations/Cut.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: ff5ef3ef526b46b48b17cc45c3c240ac, type: 3} 13 | m_Name: Cut 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 5f2868e6655bfa4bb03360efeb593db7 17 | functionBody: "if (-objDistance > resultDistance)\n{\n resultDistance = -objDistance;\n}" 18 | shaderVariables: [] 19 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations/Cut.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e4938dd30c4c414e93f2c5a790056d2 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations/Mask.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: ff5ef3ef526b46b48b17cc45c3c240ac, type: 3} 13 | m_Name: Mask 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: fd3722069d8d5e4096ab73d8d481bdad 17 | functionBody: 'if (objDistance > resultDistance) 18 | 19 | { 20 | 21 | resultDistance = objDistance; 22 | 23 | }' 24 | shaderVariables: [] 25 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations/Mask.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0dbb4fd7549b95248bc53121d3508488 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations/SmoothCut.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: ff5ef3ef526b46b48b17cc45c3c240ac, type: 3} 13 | m_Name: SmoothCut 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 0e9ae4e130db6b4fa07df634e603543e 17 | functionBody: 'float h = clamp(0.5 - 0.5 * (resultDistance + objDistance) / Smooth, 18 | 0.0, 1.0); 19 | 20 | resultDistance = lerp(resultDistance, -objDistance, h) + Smooth 21 | * h * (1.0 - h);' 22 | shaderVariables: 23 | - name: Smooth 24 | shaderType: 0 25 | parameterType: 0 26 | floatValue: 1 27 | intValue: 0 28 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 29 | textureValue: {fileID: 0} 30 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations/SmoothCut.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 802eab5e98d0fb24386c292f4c5a738f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations/SmoothMask.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: ff5ef3ef526b46b48b17cc45c3c240ac, type: 3} 13 | m_Name: SmoothMask 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: be5a01f4468c9a4fae1b8dfb6eb494f7 17 | functionBody: 'float h = clamp(0.5 - 0.5 * (resultDistance - objDistance) / Smooth, 18 | 0.0, 1.0); 19 | 20 | resultDistance = lerp(resultDistance, objDistance, h) + Smooth 21 | * h * (1.0 - h);' 22 | shaderVariables: 23 | - name: Smooth 24 | shaderType: 0 25 | parameterType: 0 26 | floatValue: 1 27 | intValue: 0 28 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 29 | textureValue: {fileID: 0} 30 | -------------------------------------------------------------------------------- /Assets/Raymarching/Operations/SmoothMask.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55396ae086256cd4e930408f047c0a50 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Raymarching.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Raymarching", 3 | "rootNamespace": "Raymarching", 4 | "references": [ 5 | "GUID:15fc0a57446b3144c949da3e2b9737a9", 6 | "GUID:b4517ec124862cb4bb3b8b27d72843a6", 7 | "GUID:df380645f10b7bc4b97d4f5eb6303d95", 8 | "GUID:e40ba710768534012815d3193fa296cb", 9 | "GUID:d8b63aba1907145bea998dd612889d6b", 10 | "GUID:75469ad4d38634e559750d17036d5f7c" 11 | ], 12 | "includePlatforms": [], 13 | "excludePlatforms": [], 14 | "allowUnsafeCode": false, 15 | "overrideReferences": false, 16 | "precompiledReferences": [], 17 | "autoReferenced": true, 18 | "defineConstraints": [], 19 | "versionDefines": [], 20 | "noEngineReferences": false 21 | } -------------------------------------------------------------------------------- /Assets/Raymarching/Raymarching.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e249997b450099448911ae37040f648 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Raymarching/SDFs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c866b247f7a7e584db49cd6d44f3e030 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/SDFs/Capsule.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 1d47c79d4ab4cc64692a822c84963803, type: 3} 13 | m_Name: Capsule 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: e8acd96d81ea8d46a4fe7ff03e5332bb 17 | functionBody: "//Height = max(0, Height -1);\n\nfloat3 pa = pos.xyz - float3(0, 18 | abs(Height) * 0.5, 0);\r\nfloat3 ba = float3(0, -abs(Height) * 0.5, 0) - float3(0, 19 | abs(Height) * 0.5, 0);\r\n\nfloat h = clamp(dot(pa, ba) / dot(ba, ba),\r 0.0, 20 | 1.0);\r\nreturn length( pa - ba*h ) - Radius;" 21 | shaderVariables: 22 | - name: Height 23 | shaderType: 0 24 | parameterType: 0 25 | floatValue: 0 26 | intValue: 0 27 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 28 | textureValue: {fileID: 0} 29 | - name: Radius 30 | shaderType: 0 31 | parameterType: 0 32 | floatValue: 0 33 | intValue: 0 34 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 35 | textureValue: {fileID: 0} 36 | -------------------------------------------------------------------------------- /Assets/Raymarching/SDFs/Capsule.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a20fdda344ec1a4f83cfe968c26e738 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/SDFs/Cube.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 1d47c79d4ab4cc64692a822c84963803, type: 3} 13 | m_Name: Cube 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: ac5a8405559d5c428e1f8d191d017e1e 17 | functionBody: 'float4 o = abs(pos) - Dimensions; 18 | 19 | return length(max(o, 0.0)) 20 | + min(max(o.x, max(o.y, o.z)), 0.0);' 21 | shaderVariables: 22 | - name: Dimensions 23 | shaderType: 5 24 | parameterType: 0 25 | floatValue: 0 26 | intValue: 0 27 | vectorValue: {x: 1, y: 1, z: 1, w: 1} 28 | textureValue: {fileID: 0} 29 | -------------------------------------------------------------------------------- /Assets/Raymarching/SDFs/Cube.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e24907e1386fe94ba62ffe78afa2ecc 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/SDFs/Hypercube.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 1d47c79d4ab4cc64692a822c84963803, type: 3} 13 | m_Name: Hypercube 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 6cfcb77892dfbf4e90ce9825f126d7f5 17 | functionBody: " float4 d = abs(pos) - Dimensions;\r\n return min(max(d.x, 18 | max(d.y, max(d.z, d.w))), 0.0) + length(max(d, 0.0));" 19 | shaderVariables: 20 | - name: Dimensions 21 | shaderType: 5 22 | parameterType: 0 23 | floatValue: 0 24 | intValue: 0 25 | vectorValue: {x: 1, y: 1, z: 1, w: 1} 26 | textureValue: {fileID: 0} 27 | -------------------------------------------------------------------------------- /Assets/Raymarching/SDFs/Hypercube.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 59488ebdc037ce74b896d1e921c667a1 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/SDFs/Sphere.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 1d47c79d4ab4cc64692a822c84963803, type: 3} 13 | m_Name: Sphere 14 | m_EditorClassIdentifier: 15 | guid: 16 | serializedGuid: 0d935c5a93ece247970ec043d92e6116 17 | functionBody: return length(pos) - Radius; 18 | shaderVariables: 19 | - name: Radius 20 | shaderType: 0 21 | parameterType: 0 22 | floatValue: 1 23 | intValue: 0 24 | vectorValue: {x: 0, y: 0, z: 0, w: 0} 25 | textureValue: {fileID: 0} 26 | -------------------------------------------------------------------------------- /Assets/Raymarching/SDFs/Sphere.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67f9a2136eb814541a202ec5f8f5d1d2 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab880078a0bd48b49c2a00e3d00a352f 3 | timeCreated: 1630837574 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Raymarch.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Object = UnityEngine.Object; 3 | 4 | #if UNITY_EDITOR 5 | using System; 6 | using System.Reflection; 7 | using UnityEngine.Rendering; 8 | using UnityEngine.Rendering.Universal; 9 | #endif 10 | 11 | public static class Raymarch 12 | { 13 | #region Raymarch Shader 14 | 15 | private static Shader _shader; 16 | 17 | public static Shader Shader 18 | { 19 | get => _shader; 20 | set 21 | { 22 | _shader = value; 23 | 24 | if (_shader == null) 25 | { 26 | #if UNITY_EDITOR 27 | if (Application.isPlaying) 28 | { 29 | Object.Destroy(Material); 30 | } 31 | else 32 | { 33 | Object.DestroyImmediate(Material); 34 | } 35 | #else 36 | Object.Destroy(Material); 37 | #endif 38 | 39 | Material = null; 40 | } 41 | else 42 | { 43 | Material = new Material(_shader) 44 | { 45 | hideFlags = HideFlags.HideAndDontSave 46 | }; 47 | } 48 | } 49 | } 50 | 51 | public static Material Material { get; private set; } 52 | 53 | public static void ResetData() 54 | { 55 | Shader = null; 56 | } 57 | 58 | public static bool ShouldRender() 59 | { 60 | return Material != null; 61 | } 62 | 63 | #endregion Raymarch Shader 64 | 65 | #region Upload Shader Data Event 66 | 67 | public delegate void UploadShaderData(Material material); 68 | 69 | // NOTE(WSWhitehouse): This event is private so scripts can only add/remove callbacks through 70 | // the functions below. Meaning this script can perform any checks on the callbacks. 71 | private static event UploadShaderData _OnUploadShaderData; 72 | 73 | public static event UploadShaderData OnUploadShaderData 74 | { 75 | add 76 | { 77 | // NOTE(WSWhitehouse): Unsubscribing first in editor to ensure an object doesn't upload data multiple times 78 | #if UNITY_EDITOR 79 | _OnUploadShaderData -= value; 80 | #endif 81 | _OnUploadShaderData += value; 82 | } 83 | 84 | remove => _OnUploadShaderData -= value; 85 | } 86 | 87 | public static void UploadShaderDataInvoke() 88 | { 89 | _OnUploadShaderData?.Invoke(Material); 90 | } 91 | 92 | #endregion Upload Shader Data Event 93 | 94 | #if UNITY_EDITOR 95 | /* NOTE(WSWhitehouse): 96 | * This function performs the appropriate renderer checks depending on the current pipeline. 97 | * This should only be called in the editor as it is quite expensive (uses a lot of reflection) and 98 | * can make changes to the renderer which isn't something that should be allowed during runtime. 99 | * 100 | * URP - Checks if scriptable render pipeline renderer has a RaymarchRenderFeature attached 101 | * 102 | * Currently no other render pipelines are supported 103 | */ 104 | public static bool PerformRendererChecks() 105 | { 106 | if (Application.isPlaying) 107 | { 108 | // NOTE(WSWhitehouse): callingMethodName is the name of the function that called this function 109 | string callingMethodName = new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().Name; 110 | Debug.LogError($"Raymarch: {callingMethodName} called PerformRendererChecks during runtime, this is not supported!"); 111 | return false; 112 | } 113 | 114 | #if UNITY_PIPELINE_URP 115 | 116 | if (GraphicsSettings.currentRenderPipeline is not UniversalRenderPipelineAsset) 117 | { 118 | Debug.LogError("Raymarch: URP Pipeline is active but the current render pipeline is not URP"); 119 | return false; 120 | } 121 | 122 | var urpPipeline = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset; 123 | 124 | // NOTE(WSWhitehouse): IDE is screaming about possible null reference exception here. 125 | // Ignore it, the null check exists in the if statement above. 126 | Type type = urpPipeline.GetType(); 127 | FieldInfo propertyInfo = type.GetField("m_RendererDataList", BindingFlags.Instance | BindingFlags.NonPublic); 128 | 129 | if (propertyInfo == null) 130 | { 131 | Debug.LogError( 132 | $"Raymarch: URP Asset ({urpPipeline.name}) doesnt include 'm_RendererDataList'. Cannot check for render feature"); 133 | return false; 134 | } 135 | 136 | var scriptableRenderData = (ScriptableRendererData[]) propertyInfo.GetValue(urpPipeline); 137 | 138 | if (scriptableRenderData == null) 139 | { 140 | Debug.LogError($"Raymarch: {urpPipeline.name} ScriptableRenderData equals null"); 141 | return false; 142 | } 143 | 144 | if (scriptableRenderData.Length == 0) 145 | { 146 | Debug.LogError($"Raymarch: {urpPipeline.name} doesn't contain any ScriptableRenderData"); 147 | return false; 148 | } 149 | 150 | foreach (var renderData in scriptableRenderData) 151 | { 152 | foreach (var rendererFeature in renderData.rendererFeatures) 153 | { 154 | if (rendererFeature is RaymarchRenderFeature) 155 | { 156 | return true; 157 | } 158 | } 159 | } 160 | 161 | #else 162 | Debug.LogError("Raymarch: Current Unity Pipeline is not supported!"); 163 | #endif 164 | 165 | return false; 166 | } 167 | #endif 168 | } -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Raymarch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecb58cfaaebb46bcac9e75833fa46a4f 3 | timeCreated: 1631639639 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | #if UNITY_EDITOR 5 | using System.Text; 6 | using UnityEditor; 7 | using UnityEngine.SceneManagement; 8 | #endif 9 | 10 | [DisallowMultipleComponent, ExecuteAlways] 11 | public abstract class RaymarchBase : MonoBehaviour 12 | { 13 | #region GUID 14 | 15 | [SerializeField, HideInInspector] private SerializableGuid guid; 16 | public SerializableGuid GUID => guid; 17 | 18 | #endregion GUID 19 | 20 | public bool IsActive => gameObject.activeInHierarchy && enabled; 21 | 22 | private struct ShaderIDs 23 | { 24 | public int IsActive; 25 | } 26 | 27 | private ShaderIDs _shaderIDs = new ShaderIDs(); 28 | 29 | public abstract bool IsValid(); 30 | 31 | protected virtual void OnEnable() 32 | { 33 | // NOTE(WSWhitehouse): Empty on enable function to force these MonoBehaviours to have a enabled state 34 | } 35 | 36 | public virtual void Awake() 37 | { 38 | Raymarch.OnUploadShaderData += UploadShaderData; 39 | 40 | string guid = GUID.ToShaderSafeString(); 41 | _shaderIDs.IsActive = Shader.PropertyToID($"_{nameof(IsActive)}{guid}"); 42 | } 43 | 44 | protected virtual void OnDestroy() 45 | { 46 | Raymarch.OnUploadShaderData -= UploadShaderData; 47 | } 48 | 49 | private void UploadShaderData(Material material) 50 | { 51 | material.SetInteger(_shaderIDs.IsActive, IsActive ? 1 : 0); 52 | } 53 | 54 | #if UNITY_EDITOR 55 | public string GetShaderVariables() 56 | { 57 | string guid = GUID.ToShaderSafeString(); 58 | StringBuilder result = new StringBuilder(); 59 | 60 | result.AppendLine($"uniform int _{nameof(IsActive)}{guid};"); 61 | 62 | return string.Concat(result.ToString(), GetShaderVariablesImpl()); 63 | } 64 | 65 | protected virtual string GetShaderVariablesImpl() 66 | { 67 | return string.Empty; 68 | } 69 | 70 | [MenuItem("CONTEXT/RaymarchBase/Force Render Scene")] 71 | private static void ForceRenderScene() 72 | { 73 | RaymarchShaderGen.ForceRenderScene(); 74 | } 75 | 76 | [MenuItem("CONTEXT/RaymarchBase/Reset GUID")] 77 | private static void ResetGUID(MenuCommand command) 78 | { 79 | if (command.context is not RaymarchBase rmBase) return; 80 | rmBase.guid.ResetGUID(); 81 | RaymarchShaderGen.GenerateRaymarchShader(); 82 | } 83 | #endif 84 | } 85 | 86 | #if UNITY_EDITOR 87 | [CustomEditor(typeof(RaymarchBase)), CanEditMultipleObjects] 88 | public class RaymarchBaseEditor : Editor 89 | { 90 | private RaymarchBase Target => target as RaymarchBase; 91 | 92 | protected GUIStyle BoldLabelStyle; 93 | 94 | // NOTE(WSWhitehouse): Do *NOT* override this function as it handles enabling/disabling 95 | // of the GUI while in play mode. Instead, override "DrawInspector()". The function is 96 | // marked sealed to ensure it cannot be overriden. 97 | public sealed override void OnInspectorGUI() 98 | { 99 | BoldLabelStyle = new GUIStyle(GUI.skin.GetStyle("label")) 100 | { 101 | fontStyle = FontStyle.Bold 102 | }; 103 | 104 | serializedObject.Update(); 105 | 106 | EditorGUI.BeginChangeCheck(); // global change check 107 | 108 | bool guiEnabledCache = GUI.enabled; 109 | GUI.enabled = false; 110 | EditorGUILayout.TextField( 111 | new GUIContent("GUID", "You cannot change the GUID manually, this is only here for debug purposes."), 112 | Target.GUID.ToShaderSafeString()); 113 | GUI.enabled = guiEnabledCache; 114 | 115 | EditorGUILayout.Space(); 116 | 117 | DrawInspector(); 118 | 119 | if (EditorGUI.EndChangeCheck()) // global change check 120 | { 121 | Undo.RecordObject(Target, Target.name); 122 | EditorUtility.SetDirty(Target); 123 | // NOTE(WSWhitehouse): Don't generate shader here, only on some select variable fields (e.g. SDF, material and modifiers)! 124 | } 125 | 126 | serializedObject.ApplyModifiedProperties(); 127 | } 128 | 129 | protected virtual void DrawInspector() 130 | { 131 | } 132 | } 133 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e1bf43fde1e465881daf2b92b3302ae 3 | timeCreated: 1633451746 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchCamera.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | [ExecuteAlways] 4 | public class RaymarchCamera : MonoBehaviour 5 | { 6 | [SerializeField] private float cameraPositionW = 0.0f; 7 | 8 | public float CameraPositionW 9 | { 10 | get => cameraPositionW; 11 | set => cameraPositionW = value; 12 | } 13 | 14 | [SerializeField] private Vector3 cameraRotation4D = Vector3.zero; 15 | 16 | public Vector3 CameraRotation4D 17 | { 18 | get => cameraRotation4D; 19 | set => cameraRotation4D = value; 20 | } 21 | 22 | struct ShaderIDs 23 | { 24 | public int CamPositionW; 25 | public int CamRotation4D; 26 | } 27 | 28 | private ShaderIDs _shaderIDs = new ShaderIDs(); 29 | 30 | public void Awake() 31 | { 32 | Raymarch.OnUploadShaderData += UploadShaderData; 33 | 34 | _shaderIDs.CamPositionW = Shader.PropertyToID("_CamPositionW"); 35 | _shaderIDs.CamRotation4D = Shader.PropertyToID("_CamRotation4D"); 36 | } 37 | 38 | private void OnDestroy() 39 | { 40 | Raymarch.OnUploadShaderData -= UploadShaderData; 41 | } 42 | 43 | private void UploadShaderData(Material material) 44 | { 45 | material.SetFloat(_shaderIDs.CamPositionW, CameraPositionW); 46 | material.SetVector(_shaderIDs.CamRotation4D, CameraRotation4D); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 766863855fb6432b906ab64dfd2492d2 3 | timeCreated: 1635762562 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchEditor.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | 3 | using System.Linq; 4 | using System.Collections.Generic; 5 | using UnityEditor; 6 | using UnityEditor.SceneManagement; 7 | using UnityEngine; 8 | using UnityEngine.SceneManagement; 9 | 10 | /* NOTE(WSWhitehouse): 11 | * This script contains all unity editor functions and menu items. 12 | */ 13 | 14 | namespace RaymarchEditor 15 | { 16 | public static class MenuItems 17 | { 18 | [MenuItem("Raymarching/Update All Raymarch Scenes")] 19 | public static void UpdateAllRaymarchScenes() 20 | { 21 | if (Application.isPlaying) Debug.LogError("Cannot update all raymarch scenes while playing!"); 22 | 23 | Debug.Log("Updating all raymarch scenes"); 24 | 25 | string[] guids = AssetDatabase.FindAssets($"t:{nameof(SceneAsset)}", null); 26 | 27 | List scenePaths = new List(guids.Length); 28 | scenePaths.AddRange(guids.Select(AssetDatabase.GUIDToAssetPath)); 29 | 30 | Scene currentScene = SceneManager.GetActiveScene(); 31 | string currentScenePath = string.Empty; 32 | 33 | 34 | foreach (var path in scenePaths) 35 | { 36 | // NOTE(WSWhitehouse): Ignore scenes that are located in the packages 37 | if (path.StartsWith("Packages/")) continue; 38 | 39 | Scene openScene = EditorSceneManager.OpenScene(path); 40 | 41 | if (openScene.name == currentScene.name) 42 | { 43 | currentScenePath = path; 44 | } 45 | 46 | if (RaymarchScene.Get() == null) continue; 47 | RaymarchShaderGen.GenerateRaymarchShader(); 48 | } 49 | 50 | if (!string.IsNullOrEmpty(currentScenePath)) 51 | EditorSceneManager.OpenScene(currentScenePath); 52 | } 53 | 54 | [MenuItem("Raymarching/Generate Raymarch Shader %#x")] // shortcut: Ctrl + Shift + X 55 | public static void GenerateRaymarchShader() 56 | { 57 | RaymarchShaderGen.GenerateRaymarchShader(); 58 | } 59 | 60 | [MenuItem("Raymarching/Force Render Scene %#z")] // shortcut: Ctrl + Shift + Z 61 | public static void ForceRenderScene() 62 | { 63 | RaymarchShaderGen.ForceRenderScene(); 64 | } 65 | 66 | [MenuItem("GameObject/Raymarching/Create Scene")] 67 | public static void CreateRaymarchScene() 68 | { 69 | var rmScene = RaymarchScene.Get(); 70 | if (rmScene != null) 71 | { 72 | Debug.LogError($"There is already an RM Scene in this scene ({SceneManager.GetActiveScene().name})"); 73 | EditorGUIUtility.PingObject(rmScene); 74 | Selection.SetActiveObjectWithContext(rmScene.gameObject, rmScene.gameObject); 75 | return; 76 | } 77 | 78 | var obj = new GameObject("RM Scene"); 79 | rmScene = obj.AddComponent(); 80 | 81 | Selection.SetActiveObjectWithContext(obj, obj); 82 | } 83 | 84 | [MenuItem("GameObject/Raymarching/Create Object")] 85 | public static void CreateRaymarchObject() 86 | { 87 | var obj = new GameObject("RM Object"); 88 | obj.AddComponent(); 89 | 90 | Selection.SetActiveObjectWithContext(obj, obj); 91 | } 92 | 93 | [MenuItem("GameObject/Raymarching/Create Operation")] 94 | public static void CreateRaymarchOperation() 95 | { 96 | var obj = new GameObject("RM Operation"); 97 | obj.AddComponent(); 98 | 99 | Selection.SetActiveObjectWithContext(obj, obj); 100 | } 101 | } 102 | } 103 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c534b09a588d4de0a899a1dab48c7ffc 3 | timeCreated: 1637607322 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchLight.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using UnityEngine; 3 | 4 | #if UNITY_EDITOR 5 | using System.Text; 6 | using UnityEditor; 7 | #endif 8 | 9 | public enum LightMode 10 | { 11 | Baked, 12 | Realtime 13 | } 14 | 15 | [DisallowMultipleComponent, ExecuteAlways, RequireComponent(typeof(Light))] 16 | public class RaymarchLight : RaymarchBase 17 | { 18 | private Light _light; 19 | 20 | private Light Light 21 | { 22 | get 23 | { 24 | if (_light == null) 25 | { 26 | _light = GetComponent(); 27 | } 28 | 29 | return _light; 30 | } 31 | } 32 | 33 | [SerializeField] private LightMode lightMode; 34 | public LightMode LightMode => lightMode; 35 | public LightType LightType => Light.type; 36 | 37 | public Vector3 Position => transform.position; 38 | public Vector3 Direction => transform.forward; 39 | 40 | public Color Colour => Light.color; 41 | public float Range => Light.range; 42 | public float Intensity => Light.intensity; 43 | 44 | public float SpotAngle => Light.spotAngle * Mathf.Deg2Rad; 45 | public float InnerSpotAngle => Light.innerSpotAngle * Mathf.Deg2Rad; 46 | 47 | private struct ShaderIDs 48 | { 49 | public int Position; 50 | public int Direction; 51 | public int Colour; 52 | public int Range; 53 | public int Intensity; 54 | public int SpotAngle; 55 | public int InnerSpotAngle; 56 | } 57 | 58 | private ShaderIDs _shaderIDs = new ShaderIDs(); 59 | 60 | private void InitShaderIDs() 61 | { 62 | string guid = GUID.ToShaderSafeString(); 63 | 64 | _shaderIDs.Position = Shader.PropertyToID($"_Position{guid}"); 65 | _shaderIDs.Direction = Shader.PropertyToID($"_Direction{guid}"); 66 | _shaderIDs.Colour = Shader.PropertyToID($"_Colour{guid}"); 67 | _shaderIDs.Range = Shader.PropertyToID($"_Range{guid}"); 68 | _shaderIDs.Intensity = Shader.PropertyToID($"_Intensity{guid}"); 69 | _shaderIDs.SpotAngle = Shader.PropertyToID($"_SpotAngle{guid}"); 70 | _shaderIDs.InnerSpotAngle = Shader.PropertyToID($"_InnerSpotAngle{guid}"); 71 | } 72 | 73 | public override void Awake() 74 | { 75 | if (LightMode == LightMode.Realtime) 76 | { 77 | InitShaderIDs(); 78 | Raymarch.OnUploadShaderData += UploadShaderData; 79 | base.Awake(); 80 | } 81 | } 82 | 83 | protected override void OnDestroy() 84 | { 85 | if (LightMode == LightMode.Realtime) 86 | { 87 | Raymarch.OnUploadShaderData -= UploadShaderData; 88 | base.OnDestroy(); 89 | } 90 | } 91 | 92 | public override bool IsValid() 93 | { 94 | return true; 95 | } 96 | 97 | private void UploadShaderData(Material material) 98 | { 99 | material.SetVector(_shaderIDs.Position, Position); 100 | material.SetVector(_shaderIDs.Direction, Direction); 101 | material.SetVector(_shaderIDs.Colour, Colour); 102 | material.SetFloat(_shaderIDs.Range, Range); 103 | material.SetFloat(_shaderIDs.Intensity, Intensity); 104 | material.SetFloat(_shaderIDs.SpotAngle, SpotAngle); 105 | material.SetFloat(_shaderIDs.InnerSpotAngle, InnerSpotAngle); 106 | } 107 | 108 | #if UNITY_EDITOR 109 | protected override string GetShaderVariablesImpl() 110 | { 111 | if (LightMode == LightMode.Baked) 112 | return string.Empty; 113 | 114 | string guid = GUID.ToShaderSafeString(); 115 | StringBuilder result = new StringBuilder(); 116 | 117 | result.AppendLine($"uniform float3 _Position{guid};"); 118 | result.AppendLine($"uniform float3 _Direction{guid};"); 119 | result.AppendLine($"uniform float4 _Colour{guid};"); 120 | result.AppendLine($"uniform float _Range{guid};"); 121 | result.AppendLine($"uniform float _Intensity{guid};"); 122 | result.AppendLine($"uniform float _SpotAngle{guid};"); 123 | result.AppendLine($"uniform float _InnerSpotAngle{guid};"); 124 | 125 | return result.ToString(); 126 | } 127 | #endif 128 | } 129 | 130 | #if UNITY_EDITOR 131 | [CustomEditor(typeof(RaymarchLight)), CanEditMultipleObjects] 132 | public class RaymarchLightEditor : RaymarchBaseEditor 133 | { 134 | private RaymarchLight Target => target as RaymarchLight; 135 | 136 | protected override void DrawInspector() 137 | { 138 | DrawDefaultInspector(); 139 | } 140 | } 141 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchLight.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b59b367701734e09a4cf052069c6479c 3 | timeCreated: 1631192640 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e27c3810803f4944ac2a8a57ccd3bdcc 3 | timeCreated: 1630866983 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchOperation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | #if UNITY_EDITOR 5 | using System.Text; 6 | using UnityEditor; 7 | #endif 8 | 9 | 10 | [DisallowMultipleComponent, ExecuteAlways] 11 | public class RaymarchOperation : RaymarchBase 12 | { 13 | [SerializeField] public ShaderFeature operation; 14 | 15 | public override void Awake() 16 | { 17 | operation.Awake(GUID); 18 | base.Awake(); 19 | } 20 | 21 | protected override void OnDestroy() 22 | { 23 | operation.OnDestroy(); 24 | base.OnDestroy(); 25 | } 26 | 27 | public override bool IsValid() 28 | { 29 | return operation.IsValid(); 30 | } 31 | 32 | #if UNITY_EDITOR 33 | /* 34 | * NOTE(WSWhitehouse): 35 | * The index values are used to keep track of operations during shader generation. They should not be 36 | * used during runtime. 37 | */ 38 | public int StartIndex { get; set; } 39 | public int EndIndex { get; set; } 40 | 41 | protected override string GetShaderVariablesImpl() 42 | { 43 | return operation.GetShaderVariables(GUID); 44 | } 45 | #endif 46 | } 47 | 48 | #if UNITY_EDITOR 49 | [CustomEditor(typeof(RaymarchOperation)), CanEditMultipleObjects] 50 | public class RaymarchOperationEditor : RaymarchBaseEditor 51 | { 52 | private RaymarchOperation Target => target as RaymarchOperation; 53 | 54 | protected override void DrawInspector() 55 | { 56 | EditorGUILayout.LabelField("Operation Function", BoldLabelStyle); 57 | EditorGUI.BeginChangeCheck(); 58 | Target.operation.ShaderFeatureAsset = 59 | (OperationShaderFeatureAsset) EditorGUILayout.ObjectField(GUIContent.none, Target.operation.ShaderFeatureAsset, 60 | typeof(OperationShaderFeatureAsset), false); 61 | if (EditorGUI.EndChangeCheck()) 62 | { 63 | RaymarchShaderGen.GenerateRaymarchShader(); 64 | } 65 | 66 | Target.operation = 67 | ShaderFeature.Editor.ShaderVariableField( 68 | new GUIContent("Operation Variables"), Target.operation); 69 | } 70 | } 71 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchOperation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00193114080c480bac7489c858edda55 3 | timeCreated: 1634214768 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using UnityEngine.Rendering.Universal; 4 | 5 | public class RaymarchRenderFeature : ScriptableRendererFeature 6 | { 7 | [SerializeField] private RenderPassEvent passEvent = RenderPassEvent.AfterRenderingSkybox; 8 | 9 | private RaymarchRenderPass _renderPass; 10 | 11 | public override void Create() 12 | { 13 | _renderPass = new RaymarchRenderPass(name) 14 | { 15 | renderPassEvent = passEvent 16 | }; 17 | } 18 | 19 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) 20 | { 21 | ref Camera camera = ref renderingData.cameraData.camera; 22 | if (camera.cameraType is not (CameraType.SceneView or CameraType.Game)) 23 | { 24 | // NOTE(WSWhitehouse): Not adding this render pass to cameras that arent for the Game and Scene 25 | return; 26 | } 27 | 28 | renderer.EnqueuePass(_renderPass); 29 | } 30 | } 31 | 32 | public class RaymarchRenderPass : ScriptableRenderPass 33 | { 34 | private RenderTargetIdentifier _destination; 35 | // private RenderTexture _destinationRT; 36 | 37 | public RaymarchRenderPass(string profilerTag) 38 | { 39 | profilingSampler = new ProfilingSampler(profilerTag); 40 | } 41 | 42 | public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) 43 | { 44 | RenderTextureDescriptor descriptor = cameraTextureDescriptor; 45 | // descriptor.enableRandomWrite = true; 46 | 47 | // _destinationRT = RenderTexture.GetTemporary(descriptor); 48 | // _destination = new RenderTargetIdentifier(_destination); 49 | 50 | cmd.GetTemporaryRT(Shader.PropertyToID("_Destination"), descriptor); 51 | _destination = new RenderTargetIdentifier("_Destination"); 52 | } 53 | 54 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) 55 | { 56 | CommandBuffer cmd = CommandBufferPool.Get(profilingSampler.name); 57 | using (new ProfilingScope(cmd, profilingSampler)) 58 | { 59 | ref CameraData cameraData = ref renderingData.cameraData; 60 | ref Camera camera = ref cameraData.camera; 61 | 62 | RenderTargetIdentifier cameraColourTexture = cameraData.renderer.cameraColorTarget; 63 | 64 | if (!Raymarch.ShouldRender()) 65 | { 66 | return; 67 | } 68 | 69 | Raymarch.Material.SetMatrix(Shader.PropertyToID("_CamToWorldMatrix"), camera.cameraToWorldMatrix); 70 | Raymarch.UploadShaderDataInvoke(); 71 | 72 | /* NOTE(WSWhitehouse): 73 | * Using cmd.Blit in URP XR projects has compatibility issues with the URP XR integration. 74 | * Using cmd.Blit might implicitly enable or disable XR shader keywords, which breaks XR SPI 75 | * rendering. Use cmd.DrawMesh instead! Update URP to v13 to use cmd.Blit! 76 | * https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@13.0/manual/renderer-features/how-to-fullscreen-blit-in-xr-spi.html 77 | */ 78 | 79 | cmd.Blit(cameraColourTexture, _destination, Raymarch.Material); 80 | cmd.Blit(_destination, cameraColourTexture); 81 | 82 | // cmd.CopyTexture(cameraColourTexture, _destination); 83 | // Raymarch.Material.SetTexture(Shader.PropertyToID("_MainTex"), _destinationRT, RenderTextureSubElement.Color); 84 | // cmd.SetRenderTarget(cameraColourTexture, 0, CubemapFace.Unknown, -1); 85 | // cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, Raymarch.Material); 86 | } 87 | 88 | context.ExecuteCommandBuffer(cmd); 89 | cmd.Clear(); 90 | CommandBufferPool.Release(cmd); 91 | 92 | context.Submit(); 93 | } 94 | 95 | public override void OnCameraCleanup(CommandBuffer cmd) 96 | { 97 | // _destinationRT.Release(); 98 | cmd.ReleaseTemporaryRT(Shader.PropertyToID("_Destination")); 99 | } 100 | } -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 30153d48daea4b7187628866f8221c68 3 | timeCreated: 1631455114 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchScene.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using UnityEngine; 4 | using UnityEngine.SceneManagement; 5 | 6 | #if UNITY_EDITOR 7 | using UnityEditor; 8 | using UnityEditor.SceneManagement; 9 | #endif 10 | 11 | [Serializable] 12 | public class RaymarchSettings 13 | { 14 | public float renderDistance = 100.0f; 15 | public float hitResolution = 0.001f; 16 | public float relaxation = 1.2f; 17 | public int maxIterations = 164; 18 | } 19 | 20 | [Serializable] 21 | public class LightingSettings 22 | { 23 | [Header("Colour")] 24 | public Color ambientColour = new Color(0.2117f, 0.2274f, 0.2588f, 1); 25 | public float colourMultiplier = 1f; 26 | 27 | [Header("Ambient Occlusion")] 28 | public bool aoEnabled = true; 29 | public float aoStepSize = 0.2f; 30 | public float aoIntensity = 0.25f; 31 | public int aoIterations = 3; 32 | } 33 | 34 | [Serializable] 35 | public class DebugSettings 36 | { 37 | public bool enableDebugSymbols = false; 38 | } 39 | 40 | [DisallowMultipleComponent, ExecuteAlways] 41 | public class RaymarchScene : MonoBehaviour 42 | { 43 | /// 44 | /// Get currently active RM Scene. Returns null if one cannot be found. 45 | /// This function does NOT cache the result, so do not call in Update, etc. 46 | /// 47 | /// Currently active Raymarch Scene - can be null! 48 | public static RaymarchScene Get() => FindObjectOfType(); 49 | 50 | [SerializeField] private RaymarchSettings raymarchSettings = new RaymarchSettings(); 51 | public RaymarchSettings RaymarchSettings => raymarchSettings; 52 | 53 | [SerializeField] private LightingSettings lightingSettings = new LightingSettings(); 54 | public LightingSettings LightingSettings => lightingSettings; 55 | 56 | [SerializeField] private DebugSettings debugSettings = new DebugSettings(); 57 | public DebugSettings DebugSettings => debugSettings; 58 | 59 | // Active Raymarch Shader 60 | [SerializeField] private Shader raymarchShader; 61 | 62 | public Shader RaymarchShader 63 | { 64 | get => raymarchShader; 65 | set 66 | { 67 | raymarchShader = value; 68 | UpdateRaymarchData(); 69 | 70 | #if UNITY_EDITOR 71 | EditorUtility.SetDirty(this); 72 | #endif 73 | } 74 | } 75 | 76 | private void UpdateRaymarchData() 77 | { 78 | Raymarch.Shader = RaymarchShader; 79 | } 80 | 81 | private void Awake() 82 | { 83 | UpdateRaymarchData(); 84 | } 85 | 86 | private void OnDestroy() 87 | { 88 | Raymarch.ResetData(); 89 | } 90 | 91 | #if UNITY_EDITOR 92 | 93 | [SerializeField] public Shader templateShader; 94 | 95 | private void OnEnable() 96 | { 97 | if (Application.isPlaying) return; 98 | EditorSceneManager.sceneSaving += OnSceneSaving; 99 | 100 | UpdateRaymarchData(); 101 | } 102 | 103 | private void OnDisable() 104 | { 105 | if (Application.isPlaying) return; 106 | EditorSceneManager.sceneSaving -= OnSceneSaving; 107 | } 108 | 109 | private void OnSceneSaving(Scene scene, string path) 110 | { 111 | if (scene != gameObject.scene) return; // not saving this scene 112 | 113 | UpdateRaymarchData(); 114 | } 115 | #endif 116 | } 117 | 118 | #if UNITY_EDITOR 119 | [CustomEditor(typeof(RaymarchScene)), CanEditMultipleObjects] 120 | public class RaymarchSceneEditor : Editor 121 | { 122 | private RaymarchScene Target => target as RaymarchScene; 123 | 124 | // Serialized Properties 125 | private SerializedProperty _raymarchShaderProperty; 126 | private SerializedProperty _templateShaderProperty; 127 | private SerializedProperty _raymarchSettingsProperty; 128 | private SerializedProperty _lightingSettingsProperty; 129 | private SerializedProperty _debugSettingsProperty; 130 | 131 | // Dropdowns 132 | private static bool _raymarchSettingsDropDown = false; 133 | private static bool _lightingSettingsDropDown = false; 134 | private static bool _debugSettingsDropDown = false; 135 | 136 | // Renderer Check 137 | private static bool? _rendererOkay = null; 138 | 139 | private void OnEnable() 140 | { 141 | _raymarchShaderProperty = serializedObject.FindProperty("raymarchShader"); 142 | _templateShaderProperty = serializedObject.FindProperty("templateShader"); 143 | _raymarchSettingsProperty = serializedObject.FindProperty("raymarchSettings"); 144 | _lightingSettingsProperty = serializedObject.FindProperty("lightingSettings"); 145 | _debugSettingsProperty = serializedObject.FindProperty("debugSettings"); 146 | } 147 | 148 | public override void OnInspectorGUI() 149 | { 150 | GUIStyle wordWrapStyle = EditorStyles.wordWrappedLabel; 151 | wordWrapStyle.fontStyle = FontStyle.Bold; 152 | 153 | serializedObject.Update(); 154 | 155 | EditorGUI.BeginChangeCheck(); 156 | 157 | EditorGUILayout.LabelField("Active Shader", wordWrapStyle); 158 | 159 | bool cachedGUIEnabled = GUI.enabled; 160 | GUI.enabled = false; 161 | 162 | EditorGUILayout.PropertyField(_raymarchShaderProperty, GUIContent.none, true); 163 | 164 | GUI.enabled = cachedGUIEnabled; 165 | 166 | if (GUILayout.Button("Regenerate Shader")) 167 | { 168 | RaymarchShaderGen.GenerateRaymarchShader(); 169 | } 170 | 171 | if (GUILayout.Button(new GUIContent("Force Render Scene", 172 | "If the objects aren't rendering in the scene, press this button."))) 173 | { 174 | RaymarchShaderGen.ForceRenderScene(); 175 | } 176 | 177 | if (GUILayout.Button(new GUIContent("Perform Renderer Checks", 178 | "Checks to see if the renderer is set up correctly"))) 179 | { 180 | _rendererOkay = Raymarch.PerformRendererChecks(); 181 | } 182 | 183 | string rendererOkayLabel = "Not performed renderer checks"; 184 | if (_rendererOkay.HasValue) 185 | { 186 | rendererOkayLabel = _rendererOkay.Value ? "Renderer okay" : "RaymarchRenderFeature cannot be found. Please add one."; 187 | } 188 | 189 | EditorGUILayout.LabelField($"Renderer Status: {rendererOkayLabel}"); 190 | 191 | EditorGUILayout.Space(); 192 | 193 | EditorGUILayout.LabelField("Template Shader", wordWrapStyle); 194 | EditorGUILayout.PropertyField(_templateShaderProperty, GUIContent.none, true); 195 | 196 | EditorGUILayout.Space(); 197 | 198 | _raymarchSettingsDropDown = 199 | EditorGUILayout.BeginFoldoutHeaderGroup(_raymarchSettingsDropDown, new GUIContent("Raymarch Settings")); 200 | if (_raymarchSettingsDropDown) 201 | { 202 | EditorGUILayout.BeginVertical(GUI.skin.box); 203 | 204 | var raymarchSettings = Util.Editor.GetSerializedPropertyChildren(_raymarchSettingsProperty).ToArray(); 205 | foreach (var raymarchSetting in raymarchSettings) 206 | { 207 | EditorGUILayout.PropertyField(raymarchSetting, 208 | new GUIContent(raymarchSetting.displayName, raymarchSetting.tooltip), true); 209 | } 210 | 211 | EditorGUILayout.EndVertical(); 212 | } 213 | 214 | EditorGUILayout.EndFoldoutHeaderGroup(); 215 | 216 | _lightingSettingsDropDown = 217 | EditorGUILayout.BeginFoldoutHeaderGroup(_lightingSettingsDropDown, new GUIContent("Lighting Settings")); 218 | if (_lightingSettingsDropDown) 219 | { 220 | EditorGUILayout.BeginVertical(GUI.skin.box); 221 | 222 | var lightingSettings = Util.Editor.GetSerializedPropertyChildren(_lightingSettingsProperty).ToArray(); 223 | foreach (var lightingSetting in lightingSettings) 224 | { 225 | EditorGUILayout.PropertyField(lightingSetting, 226 | new GUIContent(lightingSetting.displayName, lightingSetting.tooltip), true); 227 | } 228 | 229 | EditorGUILayout.EndVertical(); 230 | } 231 | 232 | EditorGUILayout.EndFoldoutHeaderGroup(); 233 | 234 | _debugSettingsDropDown = 235 | EditorGUILayout.BeginFoldoutHeaderGroup(_debugSettingsDropDown, new GUIContent("Debug Settings")); 236 | if (_debugSettingsDropDown) 237 | { 238 | EditorGUILayout.BeginVertical(GUI.skin.box); 239 | 240 | var debugSettings = Util.Editor.GetSerializedPropertyChildren(_debugSettingsProperty).ToArray(); 241 | foreach (var debugSetting in debugSettings) 242 | { 243 | EditorGUILayout.PropertyField(debugSetting, 244 | new GUIContent(debugSetting.displayName, debugSetting.tooltip), true); 245 | } 246 | 247 | EditorGUILayout.EndVertical(); 248 | } 249 | 250 | EditorGUILayout.EndFoldoutHeaderGroup(); 251 | 252 | if (EditorGUI.EndChangeCheck()) 253 | { 254 | EditorUtility.SetDirty(Target); 255 | } 256 | 257 | serializedObject.ApplyModifiedProperties(); 258 | } 259 | } 260 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchScene.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5938843ce97542d9b6f7282bcbe170be 3 | timeCreated: 1633086021 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/RaymarchShaderGen.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0df2a1c2ec843dfa2eb567f9b9ffb69 3 | timeCreated: 1633347633 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4302afdf8e5a4ed8af16be12c445dd21 3 | timeCreated: 1634806944 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Shader/ParameterType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public enum ParameterType 4 | { 5 | None, 6 | In, 7 | Out, 8 | InOut 9 | } 10 | 11 | public static class ParameterTypeExtensions 12 | { 13 | public static string ToShaderString(this ParameterType parameterType) 14 | { 15 | return parameterType switch 16 | { 17 | ParameterType.None => string.Empty, 18 | ParameterType.In => "in ", 19 | ParameterType.Out => "out ", 20 | ParameterType.InOut => "inout ", 21 | _ => throw new ArgumentOutOfRangeException() 22 | }; 23 | } 24 | } -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Shader/ParameterType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e0fb6b5ad8f4a2e8b5e63d64d79c50c 3 | timeCreated: 1634382167 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Shader/ShaderType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | public enum ShaderType 5 | { 6 | Void = -1, 7 | Float, 8 | Int, 9 | Bool, 10 | Vector2, 11 | Vector3, 12 | Vector4, 13 | Colour, 14 | Texture2D 15 | } 16 | 17 | public static class ShaderTypeExtensions 18 | { 19 | public static string ToShaderString(this ShaderType shaderType) 20 | { 21 | return shaderType switch 22 | { 23 | ShaderType.Void => "void", 24 | ShaderType.Float => "float", 25 | ShaderType.Int => "int", 26 | ShaderType.Bool => "int", 27 | ShaderType.Vector2 => "float2", 28 | ShaderType.Vector3 => "float3", 29 | ShaderType.Vector4 => "float4", 30 | ShaderType.Colour => "float4", 31 | ShaderType.Texture2D => "sampler2D", 32 | _ => throw new ArgumentOutOfRangeException() 33 | }; 34 | } 35 | 36 | public static ShaderType ToShaderType(this Type type) 37 | { 38 | if (type == typeof(void)) 39 | { 40 | return ShaderType.Void; 41 | } 42 | 43 | if (type == typeof(float)) 44 | { 45 | return ShaderType.Float; 46 | } 47 | 48 | if (type == typeof(int)) 49 | { 50 | return ShaderType.Int; 51 | } 52 | 53 | if (type == typeof(bool)) 54 | { 55 | return ShaderType.Bool; 56 | } 57 | 58 | if (type == typeof(Vector2)) 59 | { 60 | return ShaderType.Vector2; 61 | } 62 | 63 | if (type == typeof(Vector3)) 64 | { 65 | return ShaderType.Vector3; 66 | } 67 | 68 | if (type == typeof(Vector4)) 69 | { 70 | return ShaderType.Vector4; 71 | } 72 | 73 | if (type == typeof(Color)) 74 | { 75 | return ShaderType.Colour; 76 | } 77 | 78 | if (type == typeof(Texture2D)) 79 | { 80 | return ShaderType.Texture2D; 81 | } 82 | 83 | throw new NotSupportedException($"{type.Name} is not a supported Shader Type."); 84 | } 85 | } -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Shader/ShaderType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2565a587578439f87dd2466455807c8 3 | timeCreated: 1633945618 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Shader/ShaderVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78aecff2aa3aac647883cd2ff6e748c0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b56e9a7490f54bf19074befc619eba00 3 | timeCreated: 1634033467 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/MaterialShaderFeatureAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #if UNITY_EDITOR 4 | using UnityEditor; 5 | #endif 6 | 7 | [CreateAssetMenu(menuName = "Raymarching/Material")] 8 | public class MaterialShaderFeatureAsset : ShaderFeatureAsset 9 | { 10 | protected override string GetFunctionPrefix() 11 | { 12 | return "Mat"; 13 | } 14 | 15 | protected override ShaderType GetReturnType() 16 | { 17 | return ShaderType.Vector4; 18 | } 19 | 20 | protected override ShaderVariable[] GetDefaultParameters() 21 | { 22 | return new ShaderVariable[] 23 | { 24 | new ShaderVariable("pos", ShaderType.Vector3), 25 | new ShaderVariable("colour", ShaderType.Vector4), 26 | // new ShaderVariable("normal", ShaderType.Vector3) 27 | }; 28 | } 29 | 30 | #if UNITY_EDITOR 31 | public override void SignalShaderFeatureUpdated() 32 | { 33 | base.SignalShaderFeatureUpdated(); 34 | RaymarchShaderGen.GenerateUtilShader("MaterialFunctions"); 35 | } 36 | #endif 37 | } 38 | 39 | #if UNITY_EDITOR 40 | [CustomEditor(typeof(MaterialShaderFeatureAsset))] 41 | public class MaterialShaderFeatureEditor : ShaderFeatureEditor 42 | { 43 | private MaterialShaderFeatureAsset Target => target as MaterialShaderFeatureAsset; 44 | 45 | protected override void DrawInspector() 46 | { 47 | base.DrawInspector(); 48 | } 49 | } 50 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/MaterialShaderFeatureAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89849a2e411c49f28d5b63ed77a2023d 3 | timeCreated: 1633526240 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/ModifierShaderFeatureAsset.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | #if UNITY_EDITOR 5 | using UnityEditor; 6 | #endif 7 | 8 | public enum ModifierType 9 | { 10 | PreSDF = 0, 11 | PostSDF 12 | } 13 | 14 | [CreateAssetMenu(menuName = "Raymarching/Modifier")] 15 | public class ModifierShaderFeatureAsset : ShaderFeatureAsset 16 | { 17 | [SerializeField] private ModifierType modifierType; 18 | 19 | public ModifierType ModifierType 20 | { 21 | get => modifierType; 22 | set => modifierType = value; 23 | } 24 | 25 | protected override string GetFunctionPrefix() 26 | { 27 | return "Mod"; 28 | } 29 | 30 | protected override ShaderType GetReturnType() 31 | { 32 | return ModifierType switch 33 | { 34 | ModifierType.PreSDF => ShaderType.Vector4, 35 | ModifierType.PostSDF => ShaderType.Float, 36 | _ => throw new ArgumentOutOfRangeException() 37 | }; 38 | } 39 | 40 | protected override ShaderVariable[] GetDefaultParameters() 41 | { 42 | return ModifierType switch 43 | { 44 | ModifierType.PreSDF => new ShaderVariable[] 45 | { 46 | new ShaderVariable("pos", ShaderType.Vector4) 47 | }, 48 | ModifierType.PostSDF => new ShaderVariable[] 49 | { 50 | new ShaderVariable("pos", ShaderType.Vector4), 51 | new ShaderVariable("objDistance", ShaderType.Float) 52 | }, 53 | _ => throw new ArgumentOutOfRangeException() 54 | }; 55 | } 56 | 57 | #if UNITY_EDITOR 58 | public override void SignalShaderFeatureUpdated() 59 | { 60 | base.SignalShaderFeatureUpdated(); 61 | RaymarchShaderGen.GenerateUtilShader("ModifierFunctions"); 62 | } 63 | #endif 64 | } 65 | 66 | #if UNITY_EDITOR 67 | [CustomEditor(typeof(ModifierShaderFeatureAsset))] 68 | public class ModifierShaderFeatureEditor : ShaderFeatureEditor 69 | { 70 | private ModifierShaderFeatureAsset Target => target as ModifierShaderFeatureAsset; 71 | 72 | private readonly string[] modifierTypeStrings = Enum.GetNames(typeof(ModifierType)); 73 | 74 | protected override void DrawInspector() 75 | { 76 | EditorGUI.BeginChangeCheck(); 77 | Target.ModifierType = (ModifierType) GUILayout.Toolbar((int) Target.ModifierType, modifierTypeStrings); 78 | if (EditorGUI.EndChangeCheck()) 79 | { 80 | Target.SignalShaderFeatureUpdated(); 81 | } 82 | 83 | base.DrawInspector(); 84 | } 85 | } 86 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/ModifierShaderFeatureAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c992fa5b27b1504439742fa83be21c99 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/OperationShaderFeatureAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #if UNITY_EDITOR 4 | using UnityEditor; 5 | #endif 6 | 7 | [CreateAssetMenu(menuName = "Raymarching/Operation")] 8 | public class OperationShaderFeatureAsset : ShaderFeatureAsset 9 | { 10 | protected override string GetFunctionPrefix() 11 | { 12 | return "Oper"; 13 | } 14 | 15 | protected override ShaderType GetReturnType() 16 | { 17 | return ShaderType.Void; 18 | } 19 | 20 | protected override ShaderVariable[] GetDefaultParameters() 21 | { 22 | return new ShaderVariable[] 23 | { 24 | new ShaderVariable("resultDistance", ShaderType.Float, ParameterType.InOut), 25 | new ShaderVariable("resultColour", ShaderType.Vector4, ParameterType.InOut), 26 | new ShaderVariable("objDistance", ShaderType.Float), 27 | new ShaderVariable("objColour", ShaderType.Vector4) 28 | }; 29 | } 30 | 31 | #if UNITY_EDITOR 32 | public override void SignalShaderFeatureUpdated() 33 | { 34 | base.SignalShaderFeatureUpdated(); 35 | RaymarchShaderGen.GenerateUtilShader("OperationFunctions"); 36 | } 37 | #endif 38 | } 39 | 40 | #if UNITY_EDITOR 41 | [CustomEditor(typeof(OperationShaderFeatureAsset))] 42 | public class OperationShaderFeatureEditor : ShaderFeatureEditor 43 | { 44 | private MaterialShaderFeatureAsset Target => target as MaterialShaderFeatureAsset; 45 | 46 | protected override void DrawInspector() 47 | { 48 | base.DrawInspector(); 49 | } 50 | } 51 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/OperationShaderFeatureAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff5ef3ef526b46b48b17cc45c3c240ac 3 | timeCreated: 1634378869 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/SDFShaderFeatureAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #if UNITY_EDITOR 4 | using UnityEditor; 5 | #endif 6 | 7 | [CreateAssetMenu(menuName = "Raymarching/Signed Distance Function (SDF)")] 8 | public class SDFShaderFeatureAsset : ShaderFeatureAsset 9 | { 10 | protected override string GetFunctionPrefix() 11 | { 12 | return "SDF"; 13 | } 14 | 15 | protected override ShaderType GetReturnType() 16 | { 17 | return ShaderType.Float; 18 | } 19 | 20 | protected override ShaderVariable[] GetDefaultParameters() 21 | { 22 | return new ShaderVariable[] 23 | { 24 | new ShaderVariable("pos", ShaderType.Vector4) 25 | }; 26 | } 27 | 28 | #if UNITY_EDITOR 29 | public override void SignalShaderFeatureUpdated() 30 | { 31 | base.SignalShaderFeatureUpdated(); 32 | RaymarchShaderGen.GenerateUtilShader("SDFFunctions"); 33 | } 34 | #endif 35 | } 36 | 37 | #if UNITY_EDITOR 38 | [CustomEditor(typeof(SDFShaderFeatureAsset))] 39 | public class SDFShaderFeatureEditor : ShaderFeatureEditor 40 | { 41 | private SDFShaderFeatureAsset Target => target as SDFShaderFeatureAsset; 42 | 43 | protected override void DrawInspector() 44 | { 45 | base.DrawInspector(); 46 | } 47 | } 48 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/SDFShaderFeatureAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d47c79d4ab4cc64692a822c84963803 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/ShaderFeature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Serialization; 5 | 6 | #if UNITY_EDITOR 7 | using System.Text; 8 | using UnityEditor; 9 | #endif 10 | 11 | /* 12 | * NOTE(WSWhitehouse): 13 | * This script is used to implement Shader Features Assets on scene objects. It creates local copies 14 | * of variables so they can be updated on a per-object basis by responding to the 15 | * OnShaderVariablesChanged event in the Shader Feature Asset. It also handles getting shader 16 | * IDs and uploading the local Shader Feature Asset variables to the shader. Also includes an editor 17 | * class for useful OnInspectorGUI functions. 18 | */ 19 | 20 | [Serializable] 21 | public class ShaderFeature where T : ShaderFeatureAsset 22 | { 23 | #region Shader Feature 24 | 25 | [SerializeField, FormerlySerializedAs("shaderFeature")] 26 | private T shaderFeatureAsset; 27 | 28 | public T ShaderFeatureAsset 29 | { 30 | get => shaderFeatureAsset; 31 | #if UNITY_EDITOR 32 | // NOTE(WSWhitehouse): Cannot change the shader feature asset during runtime, for editor only 33 | set 34 | { 35 | if (Application.isPlaying) return; 36 | if (EqualityComparer.Default.Equals(shaderFeatureAsset, value)) return; 37 | 38 | if (shaderFeatureAsset != null) 39 | { 40 | shaderFeatureAsset.OnShaderVariablesChanged -= OnShaderVariablesChanged; 41 | } 42 | 43 | if (value == null) 44 | { 45 | shaderFeatureAsset = null; 46 | shaderVariables.Clear(); 47 | } 48 | else 49 | { 50 | shaderFeatureAsset = value; 51 | OnShaderVariablesChanged(); 52 | shaderFeatureAsset.OnShaderVariablesChanged += OnShaderVariablesChanged; 53 | } 54 | } 55 | #endif 56 | } 57 | 58 | #endregion Shader Feature 59 | 60 | #region Shader Variables 61 | 62 | [SerializeField] private List shaderVariables = new List(); 63 | 64 | public List ShaderVariables => shaderVariables; 65 | 66 | public string GetShaderVariableName(int index, SerializableGuid guid) 67 | { 68 | return $"{ShaderVariables[index].GetShaderName(guid)}{postfix}"; 69 | } 70 | 71 | /// 72 | /// Get index of variable from its name. 73 | /// 74 | /// name of shader variable 75 | /// index of shader variable in list. Returns -1 if variable cannot be found 76 | public int PropertyToID(string name) 77 | { 78 | return ShaderVariables.FindIndex(x => x.Name == name); 79 | } 80 | 81 | /// 82 | /// Returns the shader variable at the ID 83 | /// 84 | /// ID of shader variable - use to get ID 85 | /// 86 | public ShaderVariable GetShaderVariable(int id) 87 | { 88 | return ShaderVariables[id]; 89 | } 90 | 91 | /// 92 | /// Returns the shader variable with the given name - this performs no error checking, meaning if the variable 93 | /// cannot be found an exception could be thrown. Use instead. 94 | /// 95 | /// Name of shader variable 96 | public ShaderVariable GetShaderVariable(string name) 97 | { 98 | return ShaderVariables[PropertyToID(name)]; 99 | } 100 | 101 | #if UNITY_EDITOR 102 | private void OnShaderVariablesChanged() 103 | { 104 | int count = ShaderFeatureAsset.ShaderVariables.Count; 105 | 106 | var newVariables = new List(count); 107 | 108 | for (int i = 0; i < count; i++) 109 | { 110 | int index = ShaderVariables.FindIndex(x => 111 | x.Name == ShaderFeatureAsset.ShaderVariables[i].Name); 112 | 113 | if (index < 0) // variable not found 114 | { 115 | newVariables.Add(ShaderFeatureAsset.ShaderVariables[i]); 116 | continue; 117 | } 118 | 119 | newVariables.Add(shaderVariables[index].ShaderType != ShaderFeatureAsset.ShaderVariables[i].ShaderType 120 | ? ShaderFeatureAsset.ShaderVariables[i] 121 | : shaderVariables[index]); 122 | } 123 | 124 | shaderVariables = newVariables; 125 | } 126 | #endif 127 | 128 | #endregion Shader Variables 129 | 130 | #region Shader IDs 131 | 132 | private int[] _shaderIDs; 133 | 134 | #if UNITY_EDITOR 135 | // NOTE(WSWhitehouse): Storing the guid of the object that is initialising the ShaderFeature, just in case 136 | // the variables get updated and the IDs need to be regenerated - this only happens in the editor 137 | private SerializableGuid guid; 138 | #endif 139 | 140 | protected virtual void InitShaderIDs(SerializableGuid guid) 141 | { 142 | #if UNITY_EDITOR 143 | this.guid = guid; 144 | #endif 145 | 146 | _shaderIDs = new int[ShaderVariables.Count]; 147 | for (int i = 0; i < _shaderIDs.Length; i++) 148 | { 149 | _shaderIDs[i] = Shader.PropertyToID(GetShaderVariableName(i, guid)); 150 | } 151 | } 152 | 153 | #endregion Shader IDs 154 | 155 | protected string postfix = string.Empty; 156 | 157 | /// 158 | /// This string will be appended to the names of any shader variables. Used to 159 | /// distinguish between multiple of the same shader feature (i.e. a list/array of shader features) 160 | /// 161 | public void Awake(SerializableGuid guid, string postfix = "") 162 | { 163 | #if UNITY_EDITOR 164 | if (ShaderFeatureAsset != null) 165 | { 166 | ShaderFeatureAsset.OnShaderVariablesChanged += OnShaderVariablesChanged; 167 | } 168 | #endif 169 | 170 | this.postfix = postfix; 171 | 172 | InitShaderIDs(guid); 173 | Raymarch.OnUploadShaderData += UploadShaderData; 174 | } 175 | 176 | public bool IsValid() 177 | { 178 | return ShaderFeatureAsset != null; 179 | } 180 | 181 | public void OnDestroy() 182 | { 183 | #if UNITY_EDITOR 184 | if (ShaderFeatureAsset != null) 185 | { 186 | ShaderFeatureAsset.OnShaderVariablesChanged -= OnShaderVariablesChanged; 187 | } 188 | #endif 189 | 190 | Raymarch.OnUploadShaderData -= UploadShaderData; 191 | } 192 | 193 | protected virtual void UploadShaderData(Material material) 194 | { 195 | if (ShaderFeatureAsset == null) return; 196 | 197 | #if UNITY_EDITOR 198 | // NOTE(WSWhitehouse): This can happen when the scene is reloaded in edit mode 199 | if (ShaderVariables.Count != _shaderIDs.Length) 200 | { 201 | InitShaderIDs(guid); 202 | } 203 | #endif 204 | 205 | for (int i = 0; i < ShaderVariables.Count; i++) 206 | { 207 | ShaderVariables[i].UploadToShader(material, _shaderIDs[i]); 208 | } 209 | } 210 | 211 | #if UNITY_EDITOR 212 | public virtual string GetShaderVariables(SerializableGuid guid) 213 | { 214 | if (ShaderFeatureAsset == null) return string.Empty; 215 | 216 | StringBuilder result = new StringBuilder(); 217 | 218 | for (int i = 0; i < ShaderVariables.Count; i++) 219 | { 220 | result.AppendLine($"uniform {ShaderVariables[i].GetShaderType()} {GetShaderVariableName(i, guid)};"); 221 | } 222 | 223 | return result.ToString(); 224 | } 225 | #endif 226 | 227 | #if UNITY_EDITOR 228 | public static class Editor 229 | { 230 | public static ShaderFeature ShaderVariableField(GUIContent guiContent, ShaderFeature shaderFeature) 231 | { 232 | if (shaderFeature.shaderVariables.Count <= 0) 233 | { 234 | return shaderFeature; 235 | } 236 | 237 | GUIStyle boldStyle = new GUIStyle(GUI.skin.GetStyle("label")) 238 | { 239 | fontStyle = FontStyle.Bold 240 | }; 241 | 242 | if (guiContent != GUIContent.none) 243 | EditorGUILayout.LabelField(guiContent, boldStyle); 244 | 245 | for (int i = 0; i < shaderFeature.ShaderVariables.Count; i++) 246 | { 247 | EditorGUI.BeginChangeCheck(); 248 | 249 | var variable = ShaderVariable.Editor.VariableField(shaderFeature.ShaderVariables[i]); 250 | 251 | if (EditorGUI.EndChangeCheck()) 252 | { 253 | shaderFeature.ShaderVariables[i] = variable; 254 | } 255 | } 256 | 257 | return shaderFeature; 258 | } 259 | } 260 | #endif 261 | } -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/ShaderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e1cd8b3f54149e8b279bd92f1a26f79 3 | timeCreated: 1633946578 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/ShaderFeatureAsset.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.CompilerServices; 4 | using UnityEngine; 5 | 6 | #if UNITY_EDITOR 7 | using UnityEditor; 8 | #endif 9 | 10 | public abstract class ShaderFeatureAsset : ScriptableObject 11 | { 12 | #region GUID 13 | 14 | [SerializeField] private SerializableGuid guid; 15 | public SerializableGuid GUID => guid; 16 | 17 | #endregion GUID 18 | 19 | #region Shader Code 20 | 21 | public string FunctionName => $"{GetFunctionPrefix()}_{name.Replace(' ', '_')}"; 22 | public string FunctionNameWithGuid => $"{FunctionName}_{GUID.ToShaderSafeString()}"; 23 | 24 | public string FunctionParameters 25 | { 26 | get 27 | { 28 | string parameters = String.Empty; 29 | var defaultParams = GetDefaultParameters(); 30 | 31 | for (int i = 0; i < defaultParams.Length; i++) 32 | { 33 | if (i == 0) 34 | { 35 | parameters = $"{defaultParams[i].ToShaderParameter()}"; 36 | continue; 37 | } 38 | 39 | parameters = $"{parameters}, {defaultParams[i].ToShaderParameter()}"; 40 | } 41 | 42 | for (int i = 0; i < shaderVariables.Count; i++) 43 | { 44 | parameters = string.Concat(parameters, ", ", shaderVariables[i].ToShaderParameter()); 45 | } 46 | 47 | return parameters; 48 | } 49 | } 50 | 51 | public string FunctionPrototype => $"{GetReturnType().ToShaderString()} {FunctionName}({FunctionParameters})"; 52 | 53 | public string FunctionPrototypeWithGuid => 54 | $"{GetReturnType().ToShaderString()} {FunctionNameWithGuid}({FunctionParameters})"; 55 | 56 | [SerializeField] private string functionBody = "return 0;"; 57 | 58 | public string FunctionBody 59 | { 60 | get => functionBody; 61 | set => functionBody = value; 62 | } 63 | 64 | /* 65 | * NOTE(WSWhitehouse): 66 | * The following abstract functions are used to set up a shader feature. 67 | * They must all be overwritten but can return nothing - i.e. `string.Empty`, 68 | * `Array.Empty<>()` or `ShaderType.void`. They are abstract to force inheriting 69 | * shader features to implement them. 70 | */ 71 | 72 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 73 | protected abstract string GetFunctionPrefix(); 74 | 75 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 76 | protected abstract ShaderType GetReturnType(); 77 | 78 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 79 | protected abstract ShaderVariable[] GetDefaultParameters(); 80 | 81 | #endregion Shader Code 82 | 83 | [SerializeField] private List shaderVariables = new List(); 84 | 85 | #if UNITY_EDITOR 86 | // NOTE(WSWhitehouse): Only allow access in the editor, the ShaderVariables should not be updated at runtime. 87 | public List ShaderVariables 88 | { 89 | get => shaderVariables; 90 | set => shaderVariables = value; 91 | } 92 | 93 | /* 94 | * NOTE(WSWhitehouse): 95 | * This event is invoked when this shader feature gets changed, it ensures that all implementations of 96 | * a shader feature gets up to date variables and gets notified of a change. The event is only used in 97 | * debug so don't subscribe to it during runtime. 98 | */ 99 | public delegate void ShaderVariablesChanged(); 100 | 101 | public event ShaderVariablesChanged OnShaderVariablesChanged; 102 | 103 | public virtual void SignalShaderFeatureUpdated() 104 | { 105 | OnShaderVariablesChanged?.Invoke(); 106 | EditorUtility.SetDirty(this); 107 | } 108 | #endif 109 | } 110 | 111 | #if UNITY_EDITOR 112 | [CustomEditor(typeof(ShaderFeatureAsset))] 113 | public class ShaderFeatureEditor : Editor 114 | { 115 | private ShaderFeatureAsset Target => target as ShaderFeatureAsset; 116 | 117 | private bool _valuesDropDown = true; 118 | 119 | private string _functionBody; 120 | private List _shaderVariables; 121 | 122 | private bool _changes = false; 123 | 124 | protected virtual void OnEnable() 125 | { 126 | _functionBody = Target.FunctionBody; 127 | _shaderVariables = Target.ShaderVariables; 128 | } 129 | 130 | // NOTE(WSWhitehouse): Do *NOT* override this function as it handles enabling/disabling 131 | // of the GUI while in play mode. Instead, override "DrawInspector()". The function is 132 | // marked sealed to ensure it cannot be overriden. 133 | public sealed override void OnInspectorGUI() 134 | { 135 | if (Application.isPlaying) 136 | EditorGUILayout.HelpBox("You cannot edit Shader Features during play mode.", MessageType.Info, true); 137 | 138 | bool cachedGUIEnabled = GUI.enabled; 139 | GUI.enabled = !Application.isPlaying; 140 | 141 | serializedObject.Update(); 142 | DrawInspector(); 143 | serializedObject.ApplyModifiedProperties(); 144 | 145 | GUI.enabled = cachedGUIEnabled; 146 | } 147 | 148 | protected virtual void DrawInspector() 149 | { 150 | GUIStyle wordWrapStyle = EditorStyles.wordWrappedLabel; 151 | wordWrapStyle.fontStyle = FontStyle.Bold; 152 | 153 | EditorGUILayout.BeginVertical(GUI.skin.box); 154 | EditorGUILayout.LabelField(Target.FunctionPrototype, wordWrapStyle); 155 | EditorGUILayout.LabelField("{"); 156 | 157 | EditorGUI.BeginChangeCheck(); 158 | 159 | EditorGUI.indentLevel++; 160 | _functionBody = EditorGUILayout.TextArea(_functionBody); 161 | EditorGUI.indentLevel--; 162 | 163 | if (EditorGUI.EndChangeCheck()) 164 | { 165 | _changes = true; 166 | } 167 | 168 | EditorGUILayout.LabelField("}"); 169 | 170 | EditorGUILayout.EndVertical(); 171 | 172 | EditorGUILayout.Space(); 173 | 174 | _valuesDropDown = EditorGUILayout.BeginFoldoutHeaderGroup(_valuesDropDown, "Values"); 175 | 176 | if (_valuesDropDown) 177 | { 178 | EditorGUI.indentLevel++; 179 | 180 | for (int i = 0; i < _shaderVariables.Count; i++) 181 | { 182 | EditorGUILayout.BeginVertical(GUI.skin.box); 183 | 184 | EditorGUI.BeginChangeCheck(); 185 | 186 | var value = ShaderVariable.Editor.EditableVariableField(_shaderVariables[i]); 187 | 188 | if (EditorGUI.EndChangeCheck()) 189 | { 190 | _shaderVariables[i] = value; 191 | _changes = true; 192 | // Target.SignalShaderFeatureUpdated(); 193 | } 194 | 195 | if (GUILayout.Button("Remove Value")) 196 | { 197 | RemoveValue(i); 198 | EditorGUILayout.EndVertical(); 199 | break; // leave loop so iterator doesn't get messed up! 200 | } 201 | 202 | EditorGUILayout.EndVertical(); 203 | } 204 | 205 | if (GUILayout.Button("Add New Value")) 206 | { 207 | AddValue(); 208 | } 209 | 210 | EditorGUI.indentLevel--; 211 | } 212 | 213 | EditorGUILayout.EndFoldoutHeaderGroup(); 214 | 215 | EditorGUILayout.Space(); 216 | EditorGUILayout.LabelField("Apply Changes to Shader Feature", wordWrapStyle); 217 | EditorGUILayout.BeginHorizontal(); 218 | 219 | bool guiEnableCache = GUI.enabled; 220 | GUI.enabled = _changes && guiEnableCache; 221 | 222 | if (GUILayout.Button("Apply")) 223 | { 224 | _changes = false; 225 | Target.FunctionBody = _functionBody; 226 | Target.ShaderVariables = _shaderVariables; 227 | Target.SignalShaderFeatureUpdated(); 228 | } 229 | 230 | if (GUILayout.Button("Revert")) 231 | { 232 | _changes = false; 233 | _functionBody = Target.FunctionBody; 234 | _shaderVariables = Target.ShaderVariables; 235 | } 236 | 237 | GUI.enabled = guiEnableCache; 238 | 239 | EditorGUILayout.EndHorizontal(); 240 | } 241 | 242 | private void RemoveValue(int index) 243 | { 244 | _shaderVariables.RemoveAt(index); 245 | _changes = true; 246 | // Target.SignalShaderFeatureUpdated(); 247 | } 248 | 249 | private void AddValue() 250 | { 251 | _shaderVariables.Add( 252 | new ShaderVariable($"Value_{Target.ShaderVariables.Count.ToString()}", ShaderType.Float)); 253 | _changes = true; 254 | // Target.SignalShaderFeatureUpdated(); 255 | } 256 | } 257 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/ShaderFeatureAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e382377e40a64b0a9e9e65eb2df4ce66 3 | timeCreated: 1633525164 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/ToggleableShaderFeature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | #if UNITY_EDITOR 5 | using System.Text; 6 | #endif 7 | 8 | /* 9 | * NOTE(WSWhitehouse): 10 | * This is an extension class of ShaderFeature<> to allow the shader feature to be 11 | * toggled on and off. It generates an enabled boolean that gets sent to the shader. 12 | * The script directly inherits from ShaderFeature<>. 13 | * 14 | * The beautiful few lines of code below me says this script inherits from ShaderFeatureImpl<> 15 | * and 'T' must be of type ShaderFeature. Sometimes C# can be truly disgusting to look at :( 16 | */ 17 | [Serializable] 18 | public sealed class ToggleableShaderFeature : ShaderFeature where T : ShaderFeatureAsset 19 | { 20 | [SerializeField] private bool isEnabled = true; 21 | 22 | public bool IsEnabled 23 | { 24 | get => isEnabled; 25 | set => isEnabled = value; 26 | } 27 | 28 | [SerializeField] public bool hardcodedShaderFeature = false; 29 | 30 | private int isEnabledShaderID; 31 | 32 | protected override void InitShaderIDs(SerializableGuid guid) 33 | { 34 | base.InitShaderIDs(guid); 35 | isEnabledShaderID = Shader.PropertyToID($"_IsEnabled{guid.ToShaderSafeString()}{postfix}"); 36 | } 37 | 38 | protected override void UploadShaderData(Material material) 39 | { 40 | if (ShaderFeatureAsset == null) return; 41 | base.UploadShaderData(material); 42 | material.SetInteger(isEnabledShaderID, IsEnabled ? 1 : 0); 43 | } 44 | 45 | #if UNITY_EDITOR 46 | public string GetIsEnabledShaderName(SerializableGuid guid) 47 | { 48 | return $"_IsEnabled{guid.ToShaderSafeString()}{postfix}"; 49 | } 50 | 51 | public override string GetShaderVariables(SerializableGuid guid) 52 | { 53 | if (ShaderFeatureAsset == null) return string.Empty; 54 | 55 | StringBuilder result = new StringBuilder(); 56 | result.AppendLine($"uniform int _IsEnabled{guid.ToShaderSafeString()}{postfix};"); 57 | 58 | return string.Concat(base.GetShaderVariables(guid), result.ToString()); 59 | } 60 | #endif 61 | } -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/ShaderFeatures/ToggleableShaderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: caa97ece6b73451abc17b2b264beb53a 3 | timeCreated: 1635773796 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Util.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34c4faeafd3a4fd69429402dda98e6f0 3 | timeCreated: 1633081119 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Util/RenderPipelineDefines.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEngine.Rendering; 6 | 7 | [InitializeOnLoad] 8 | public class RenderPipelineDefines 9 | { 10 | // NOTE(WSWhitehouse): This constructor is called when the Unity engine is loaded due to the 'InitializeOnLoad' attribute 11 | static RenderPipelineDefines() 12 | { 13 | UpdateDefines(); 14 | } 15 | 16 | private enum PipelineType 17 | { 18 | Unsupported, 19 | BuiltIn, 20 | URP, 21 | HDRP 22 | } 23 | 24 | private static void UpdateDefines() 25 | { 26 | var pipeline = GetPipeline(); 27 | 28 | if (pipeline == PipelineType.URP) 29 | { 30 | AddDefine("UNITY_PIPELINE_URP"); 31 | } 32 | else 33 | { 34 | RemoveDefine("UNITY_PIPELINE_URP"); 35 | } 36 | 37 | if (pipeline == PipelineType.HDRP) 38 | { 39 | AddDefine("UNITY_PIPELINE_HDRP"); 40 | } 41 | else 42 | { 43 | RemoveDefine("UNITY_PIPELINE_HDRP"); 44 | } 45 | } 46 | 47 | private static PipelineType GetPipeline() 48 | { 49 | // NOTE(WSWhitehouse): Scriptable Render Pipelines didn't exist before 2019.1. 50 | #if UNITY_2019_1_OR_NEWER 51 | if (GraphicsSettings.renderPipelineAsset != null) 52 | { 53 | string renderPipelineType = GraphicsSettings.renderPipelineAsset.GetType().ToString(); 54 | 55 | // NOTE(WSWhitehouse): "Magic" strings below are names of scriptable render pipeline scripts. Cannot use 56 | // nameof() or compare types as they might not exist - resulting in a compile error. Therefore, if the 57 | // scripts get renamed this will stop working! 58 | 59 | if (renderPipelineType.Contains("HDRenderPipelineAsset")) 60 | { 61 | return PipelineType.HDRP; 62 | } 63 | 64 | // NOTE(WSWhitehouse): Check for both versions of URP asset 65 | if (renderPipelineType.Contains("UniversalRenderPipelineAsset") || 66 | renderPipelineType.Contains("LightweightRenderPipelineAsset")) 67 | { 68 | return PipelineType.URP; 69 | } 70 | 71 | return PipelineType.Unsupported; 72 | } 73 | #endif 74 | return PipelineType.BuiltIn; 75 | } 76 | 77 | private static void AddDefine(string define) 78 | { 79 | var definesList = GetDefines(); 80 | if (!definesList.Contains(define)) 81 | { 82 | definesList.Add(define); 83 | SetDefines(definesList); 84 | } 85 | } 86 | 87 | private static void RemoveDefine(string define) 88 | { 89 | var definesList = GetDefines(); 90 | if (definesList.Contains(define)) 91 | { 92 | definesList.Remove(define); 93 | SetDefines(definesList); 94 | } 95 | } 96 | 97 | private static List GetDefines() 98 | { 99 | var target = EditorUserBuildSettings.activeBuildTarget; 100 | var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(target); 101 | var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup); 102 | return defines.Split(';').ToList(); 103 | } 104 | 105 | private static void SetDefines(List definesList) 106 | { 107 | var target = EditorUserBuildSettings.activeBuildTarget; 108 | var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(target); 109 | var defines = string.Join(";", definesList.ToArray()); 110 | PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, defines); 111 | } 112 | } 113 | #endif -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Util/RenderPipelineDefines.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29c68e54aa144a1cbb0dfdd892e7ab51 3 | timeCreated: 1636384812 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Util/SerializableGuid.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | // https://github.com/Unity-Technologies/guid-based-reference/blob/master/Assets/CrossSceneReference/Runtime/GuidComponent.cs 5 | 6 | [Serializable] 7 | public class SerializableGuid 8 | { 9 | private Guid guid = Guid.Empty; 10 | [SerializeField, HideInInspector] private byte[] serializedGuid = Guid.NewGuid().ToByteArray(); 11 | 12 | public Guid GUID 13 | { 14 | get 15 | { 16 | if (guid == Guid.Empty) 17 | { 18 | guid = new Guid(serializedGuid); 19 | } 20 | 21 | return guid; 22 | } 23 | } 24 | 25 | public override string ToString() 26 | { 27 | return GUID.ToString(); 28 | } 29 | 30 | public string ToShaderSafeString() 31 | { 32 | return ToString().Replace("-", ""); 33 | } 34 | 35 | #if UNITY_EDITOR 36 | public void ResetGUID() 37 | { 38 | serializedGuid = Guid.NewGuid().ToByteArray(); 39 | guid = Guid.Empty; 40 | } 41 | #endif 42 | } -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Util/SerializableGuid.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c64270429d742bdbaeb635c92f71e8b 3 | timeCreated: 1633366825 -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Util/Util.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using UnityEngine.SceneManagement; 4 | using UnityEngine; 5 | 6 | #if UNITY_EDITOR 7 | using UnityEditor; 8 | #endif 9 | 10 | namespace Util 11 | { 12 | #if UNITY_EDITOR 13 | public static class Editor 14 | { 15 | /// 16 | /// Gets all children of at 1 level depth 17 | /// 18 | /// to get children 19 | /// Collection of children 20 | public static IEnumerable GetSerializedPropertyChildren(SerializedProperty serializedProperty) 21 | { 22 | SerializedProperty currentProperty = serializedProperty.Copy(); 23 | SerializedProperty nextSiblingProperty = serializedProperty.Copy(); 24 | { 25 | nextSiblingProperty.Next(false); 26 | } 27 | 28 | if (!currentProperty.Next(true)) yield break; 29 | 30 | do 31 | { 32 | if (SerializedProperty.EqualContents(currentProperty, nextSiblingProperty)) break; 33 | 34 | yield return currentProperty.Copy(); 35 | } while (currentProperty.Next(false)); 36 | } 37 | 38 | /// 39 | /// Gets visible children of at 1 level depth 40 | /// 41 | /// to get children 42 | /// Collection of children 43 | public static IEnumerable GetSerializedPropertyVisibleChildren( 44 | SerializedProperty serializedProperty) 45 | { 46 | SerializedProperty currentProperty = serializedProperty.Copy(); 47 | SerializedProperty nextSiblingProperty = serializedProperty.Copy(); 48 | { 49 | nextSiblingProperty.NextVisible(false); 50 | } 51 | 52 | if (!currentProperty.NextVisible(true)) yield break; 53 | 54 | do 55 | { 56 | if (SerializedProperty.EqualContents(currentProperty, nextSiblingProperty)) break; 57 | 58 | yield return currentProperty.Copy(); 59 | } while (currentProperty.NextVisible(false)); 60 | } 61 | 62 | /// 63 | /// Finds all assets of type in the 64 | /// 65 | /// Type of asset to find. Must be of type 66 | /// List of all assets of type 67 | public static List FindAllAssetsOfType() where T : Object 68 | { 69 | string[] guids = AssetDatabase.FindAssets($"t:{typeof(T).Name}", null); 70 | 71 | List assets = new List(guids.Length); 72 | assets.AddRange(guids.Select(guid => 73 | AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid)))); 74 | 75 | return assets; 76 | } 77 | } 78 | #endif 79 | 80 | public static class Runtime 81 | { 82 | 83 | } 84 | } -------------------------------------------------------------------------------- /Assets/Raymarching/Scripts/Util/Util.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5521cccb10b849bc8d0534ce2e900fa5 3 | timeCreated: 1635427832 -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d621ead1bcc42b4fad9662a5e308e5b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Generated.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 095774e89f0d4e4458d94d18e28b6363 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Generated/MaterialFunctions.hlsl: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // This code was generated by a tool. 3 | // 4 | // Changes to this file may cause incorrect behavior and will be 5 | // lost if the code is regenerated. 6 | // 7 | // Time Generated: 10/29/2021 12:23:38 8 | //--------------------------------------------------------------------- 9 | 10 | #ifndef MATERIALFUNCTIONS_HLSL 11 | #define MATERIALFUNCTIONS_HLSL 12 | 13 | // Unity Includes 14 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 15 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" 16 | 17 | float4 Mat_TextureMaterial_c3735437331f4f80a12534d02a465e6a(float3 pos, float4 colour, sampler2D Texture) 18 | { 19 | float3x3 R = float3x3(float3(cos(_Time.y),sin(_Time.y),0),float3(-sin(_Time.y),cos(_Time.y),0),float3(0,0,-1)); 20 | //pos = mul(pos, R / 8); 21 | 22 | 23 | return float4( 24 | float3((tex2D(Texture, pos.xy).rgb 25 | + tex2D(Texture, pos.zy).rgb 26 | + tex2D(Texture, pos.xz).rgb) / 3.0), 1) * colour; 27 | } 28 | 29 | #endif // MATERIALFUNCTIONS_HLSL -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Generated/MaterialFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 494e67a84d600df45b0b958685207124 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Generated/ModifierFunctions.hlsl: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // This code was generated by a tool. 3 | // 4 | // Changes to this file may cause incorrect behavior and will be 5 | // lost if the code is regenerated. 6 | // 7 | // Time Generated: 11/22/2021 18:33:53 8 | //--------------------------------------------------------------------- 9 | 10 | #ifndef MODIFIERFUNCTIONS_HLSL 11 | #define MODIFIERFUNCTIONS_HLSL 12 | 13 | // Unity Includes 14 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 15 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" 16 | 17 | float4 Mod_Bend_4f75e62b05fa4290bc9060a1615db095(float4 pos, float BendAmount) 18 | { 19 | float c = cos(BendAmount*pos.x); 20 | float s = sin(BendAmount*pos.x); 21 | float2x2 m = float2x2(c,-s,s,c); 22 | return float4(mul(m,pos.xy), pos.z, pos.w); 23 | } 24 | 25 | float Mod_Displacement3D_1a61691f0be94ed6b83151f90f2fefb1(float4 pos, float objDistance, float Displacement) 26 | { 27 | float displacement = sin(Displacement*pos.x)*sin(Displacement*pos.y)*sin(Displacement*pos.z); 28 | 29 | return objDistance + displacement; 30 | } 31 | 32 | float Mod_Displacement4D_1a61691f0be94ed6b83151f90f2fefb1(float4 pos, float objDistance, float Displacement) 33 | { 34 | float displacement = sin(Displacement*pos.x)*sin(Displacement*pos.y)*sin(Displacement*pos.z)*sin(Displacement*pos.w); 35 | 36 | return objDistance + displacement; 37 | } 38 | 39 | float4 Mod_InfiniteRepetition_802c270f402c48459b9597d4fb74dba8(float4 pos, float4 RepPeriod) 40 | { 41 | return fmod(pos + 0.5 * RepPeriod, RepPeriod) - 0.5 * RepPeriod; 42 | } 43 | 44 | float Mod_Onion_ecbac56f3862424a8fad6d23b416efe1(float4 pos, float objDistance, float Thickness) 45 | { 46 | return abs(objDistance) - Thickness; 47 | } 48 | 49 | float Mod_SineWave_a6bfc751b1354407833fc4a471b08d44(float4 pos, float objDistance, float Freq, float Amplitude, float Speed, float4 Dir) 50 | { 51 | float direction = 0; 52 | 53 | if (Dir.x >= 1) 54 | { 55 | direction += pos.x; 56 | } 57 | else if (Dir.x <= -1) 58 | { 59 | direction -= pos.x; 60 | } 61 | 62 | if (Dir.y >= 1) 63 | { 64 | direction += pos.y; 65 | } 66 | else if (Dir.y <= -1) 67 | { 68 | direction -= pos.y; 69 | } 70 | 71 | if (Dir.z >= 1) 72 | { 73 | direction += pos.z; 74 | } 75 | else if (Dir.z <= -1) 76 | { 77 | direction -= pos.z; 78 | } 79 | 80 | if(Dir.w >=1) 81 | { 82 | direction += pos.w; 83 | } 84 | else if (Dir.w <= -1) 85 | { 86 | direction -= pos.w; 87 | } 88 | 89 | return objDistance - sin(direction * Freq + (_Time.y * Speed)) * Amplitude; 90 | } 91 | 92 | float4 Mod_TwistX_a2afad70a366443ead7b8bf1ce7c82fc(float4 pos, float TwistAmountX) 93 | { 94 | float c = cos(TwistAmountX*pos.x); 95 | float s = sin(TwistAmountX*pos.x); 96 | float2x2 m = float2x2(c,-s,s,c); 97 | return float4(mul(m,pos.yz), pos.x, pos.w); 98 | } 99 | 100 | float4 Mod_TwistY_84cc6354438645f28030230feaa53e13(float4 pos, float TwistAmountY) 101 | { 102 | float c = cos(TwistAmountY*pos.y); 103 | float s = sin(TwistAmountY*pos.y); 104 | float2x2 m = float2x2(c,-s,s,c); 105 | return float4(mul(m,pos.xz), pos.y, pos.w); 106 | } 107 | 108 | float4 Mod_TwistZ_c1d0359417c14757b9996d01b0db1171(float4 pos, float TwistAmountZ) 109 | { 110 | float c = cos(TwistAmountZ*pos.z); 111 | float s = sin(TwistAmountZ*pos.z); 112 | float2x2 m = float2x2(c,-s,s,c); 113 | return float4( mul(m,pos.xy), pos.z, pos.w); 114 | } 115 | 116 | #endif // MODIFIERFUNCTIONS_HLSL -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Generated/ModifierFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34abd98a5184e0446a632bca194f02c5 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Generated/OperationFunctions.hlsl: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // This code was generated by a tool. 3 | // 4 | // Changes to this file may cause incorrect behavior and will be 5 | // lost if the code is regenerated. 6 | // 7 | // Time Generated: 10/29/2021 12:23:52 8 | //--------------------------------------------------------------------- 9 | 10 | #ifndef OPERATIONFUNCTIONS_HLSL 11 | #define OPERATIONFUNCTIONS_HLSL 12 | 13 | // Unity Includes 14 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 15 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" 16 | 17 | void Oper_Blend_c08c11b6fc54453486aa264d1da70b87(inout float resultDistance, inout float4 resultColour, float objDistance, float4 objColour, float Smooth) 18 | { 19 | float h = clamp(0.5 + 0.5 * (objDistance - resultDistance) / Smooth, 0.0, 1.0); 20 | 21 | resultDistance = lerp(objDistance, resultDistance, h) - Smooth * h * (1.0 - h); 22 | resultColour = lerp(objColour, resultColour, h); 23 | } 24 | 25 | void Oper_Cut_e668285f5b654bfab03360efeb593db7(inout float resultDistance, inout float4 resultColour, float objDistance, float4 objColour) 26 | { 27 | if (-objDistance > resultDistance) 28 | { 29 | resultDistance = -objDistance; 30 | } 31 | } 32 | 33 | void Oper_Mask_062237fd8d9d405e96ab73d8d481bdad(inout float resultDistance, inout float4 resultColour, float objDistance, float4 objColour) 34 | { 35 | if (objDistance > resultDistance) 36 | { 37 | resultDistance = objDistance; 38 | } 39 | } 40 | 41 | void Oper_SmoothCut_e1e49a0edb304f6ba07df634e603543e(inout float resultDistance, inout float4 resultColour, float objDistance, float4 objColour, float Smooth) 42 | { 43 | float h = clamp(0.5 - 0.5 * (resultDistance + objDistance) / Smooth, 0.0, 1.0); 44 | resultDistance = lerp(resultDistance, -objDistance, h) + Smooth * h * (1.0 - h); 45 | } 46 | 47 | void Oper_SmoothMask_f4015abe8c464f9aae1b8dfb6eb494f7(inout float resultDistance, inout float4 resultColour, float objDistance, float4 objColour, float Smooth) 48 | { 49 | float h = clamp(0.5 - 0.5 * (resultDistance - objDistance) / Smooth, 0.0, 1.0); 50 | resultDistance = lerp(resultDistance, objDistance, h) + Smooth * h * (1.0 - h); 51 | } 52 | 53 | #endif // OPERATIONFUNCTIONS_HLSL -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Generated/OperationFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 647f4b7740623684caf9d07099d1900c 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Generated/SDFFunctions.hlsl: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // This code was generated by a tool. 3 | // 4 | // Changes to this file may cause incorrect behavior and will be 5 | // lost if the code is regenerated. 6 | // 7 | // Time Generated: 11/23/2021 08:36:05 8 | //--------------------------------------------------------------------- 9 | 10 | #ifndef SDFFUNCTIONS_HLSL 11 | #define SDFFUNCTIONS_HLSL 12 | 13 | // Unity Includes 14 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 15 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" 16 | 17 | float SDF_Capsule_6dd9ace8ea81468da4fe7ff03e5332bb(float4 pos, float Height, float Radius) 18 | { 19 | //Height = max(0, Height -1); 20 | 21 | float3 pa = pos.xyz - float3(0, abs(Height) * 0.5, 0); 22 | float3 ba = float3(0, -abs(Height) * 0.5, 0) - float3(0, abs(Height) * 0.5, 0); 23 | 24 | float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0); 25 | return length( pa - ba*h ) - Radius; 26 | } 27 | 28 | float SDF_Cube_05845aac9d55425c8e1f8d191d017e1e(float4 pos, float4 Dimensions) 29 | { 30 | float4 o = abs(pos) - Dimensions; 31 | return length(max(o, 0.0)) + min(max(o.x, max(o.y, o.z)), 0.0); 32 | } 33 | 34 | float SDF_Hypercube_78b7fc6cdf924ebf90ce9825f126d7f5(float4 pos, float4 Dimensions) 35 | { 36 | float4 d = abs(pos) - Dimensions; 37 | return min(max(d.x, max(d.y, max(d.z, d.w))), 0.0) + length(max(d, 0.0)); 38 | } 39 | 40 | float SDF_Sphere_5a5c930dec9347e2970ec043d92e6116(float4 pos, float Radius) 41 | { 42 | return length(pos) - Radius; 43 | } 44 | 45 | #endif // SDFFUNCTIONS_HLSL -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Generated/SDFFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8eec6a1e6b9b8848a51551c7f6a3bfb 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Light.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef RAYMARCHING_LIGHT_HLSL 2 | #define RAYMARCHING_LIGHT_HLSL 3 | 4 | float4 GetDirectionalLight(float3 objPos, float3 normal, float4 lightCol, float3 lightDir, float lightIntensity) 5 | { 6 | return max(0.0, dot(-normal, lightDir)) * lightCol * lightIntensity; 7 | } 8 | 9 | float4 GetPointLight(float3 objPos, float3 normal, float3 lightPos, float4 lightCol, float lightRange, 10 | float lightIntensity) 11 | { 12 | // http://forum.unity3d.com/threads/light-attentuation-equation.16006/ 13 | float3 toLight = objPos - lightPos; 14 | float range = clamp(length(toLight) / lightRange, 0.0, 1.0); 15 | float attenuation = 1.0 / (1.0 + 256.0 * range * range); 16 | 17 | return max(0.0, dot(-normal, normalize(toLight.xyz))) * lightCol * lightIntensity * attenuation; 18 | } 19 | 20 | float4 GetSpotLight(float3 objPos, float3 normal, float3 lightPos, float4 lightCol, float3 lightDir, float lightRange, 21 | float lightIntensity, float spotAngle, float innerSpotAngle) 22 | { 23 | // http://forum.unity3d.com/threads/light-attentuation-equation.16006/ 24 | float3 toLight = objPos - lightPos; 25 | float range = clamp(length(toLight) / lightRange, 0.0, 1.0); 26 | float attenuation = 1.0 / (1.0 + 256.0 * range * range); 27 | 28 | // https://developer.download.nvidia.com/CgTutorial/cg_tutorial_chapter05.html 29 | float innerCos = cos(innerSpotAngle); 30 | float outerCos = cos(spotAngle); 31 | float dirCos = dot(normalize(toLight), normalize(lightDir)); 32 | float spotEffect = smoothstep(outerCos, innerCos, dirCos); 33 | 34 | return max(0.0, dot(-normal, normalize(toLight.xyz))) * lightCol * lightIntensity * attenuation * spotEffect; 35 | } 36 | 37 | #endif // RAYMARCHING_LIGHT_HLSL 38 | -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Light.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e323d8e69ecb43c59e085a14929e00ba 3 | timeCreated: 1635268089 -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/RaymarchTemplateShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6c888053f2af174fb0c96159bd003cd 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Structs.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef RAYMARCHING_STRUCTS_HLSL 2 | #define RAYMARCHING_STRUCTS_HLSL 3 | 4 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 5 | 6 | 7 | // RAY 8 | struct Ray 9 | { 10 | float3 Origin; 11 | float3 Direction; 12 | float Length; 13 | }; 14 | 15 | inline Ray CreateRay(float3 origin, float3 direction, float dirLength) 16 | { 17 | Ray ray; 18 | ray.Origin = origin; 19 | ray.Direction = direction; 20 | ray.Length = dirLength; 21 | return ray; 22 | } 23 | 24 | inline Ray CreateCameraRay(float2 uv, float4x4 camToWorld) 25 | { 26 | float3 origin = GetCameraPositionWS(); 27 | float3 direction = mul(unity_CameraInvProjection, float4(uv * 2 - 1, 0, 1)).xyz; 28 | direction = mul(camToWorld, float4(direction, 0)).xyz; 29 | float dirLength = length(direction); 30 | direction = normalize(direction); 31 | 32 | return CreateRay(origin, direction, dirLength); 33 | } 34 | 35 | // OBJECT DISTANCE RESULT 36 | struct RaymarchMapResult 37 | { 38 | float Distance; 39 | float4 Colour; 40 | }; 41 | 42 | inline RaymarchMapResult CreateRaymarchMapResult(float distance, float4 colour) 43 | { 44 | RaymarchMapResult objData; 45 | objData.Distance = distance; 46 | objData.Colour = colour; 47 | return objData; 48 | } 49 | 50 | // RAYMARCH RESULT 51 | struct RaymarchResult 52 | { 53 | int Succeeded; // NOTE(WSWhitehouse): Succeeded if greater than 0 54 | half4 Colour; 55 | }; 56 | 57 | inline RaymarchResult CreateRaymarchResult(int succeeded, half4 colour) 58 | { 59 | RaymarchResult raymarchResult; 60 | raymarchResult.Succeeded = succeeded; 61 | raymarchResult.Colour = colour; 62 | return raymarchResult; 63 | } 64 | 65 | #endif // RAYMARCHING_STRUCTS_HLSL 66 | -------------------------------------------------------------------------------- /Assets/Raymarching/Shaders/Structs.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd9c8d91f9c641908b194c22fdc509b2 3 | timeCreated: 1630951025 -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04ed40ccbfa1d414fbb6d6b6f123bc06 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/RayMarching.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5858d2e241c0da40b2756fdf74a92ad 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scenes/Raymarching.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8d07152709d313458e37d34cc50324d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/Raymarching/Global Volume Profile.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-9203433256221818662 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 3 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3} 13 | m_Name: Bloom 14 | m_EditorClassIdentifier: 15 | active: 0 16 | threshold: 17 | m_OverrideState: 1 18 | m_Value: 1 19 | intensity: 20 | m_OverrideState: 1 21 | m_Value: 16.6 22 | scatter: 23 | m_OverrideState: 1 24 | m_Value: 0.7 25 | clamp: 26 | m_OverrideState: 1 27 | m_Value: 65472 28 | tint: 29 | m_OverrideState: 1 30 | m_Value: {r: 1, g: 1, b: 1, a: 1} 31 | highQualityFiltering: 32 | m_OverrideState: 1 33 | m_Value: 0 34 | skipIterations: 35 | m_OverrideState: 1 36 | m_Value: 1 37 | dirtTexture: 38 | m_OverrideState: 1 39 | m_Value: {fileID: 0} 40 | dirtIntensity: 41 | m_OverrideState: 1 42 | m_Value: 0 43 | --- !u!114 &11400000 44 | MonoBehaviour: 45 | m_ObjectHideFlags: 0 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInstance: {fileID: 0} 48 | m_PrefabAsset: {fileID: 0} 49 | m_GameObject: {fileID: 0} 50 | m_Enabled: 1 51 | m_EditorHideFlags: 0 52 | m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3} 53 | m_Name: Global Volume Profile 54 | m_EditorClassIdentifier: 55 | components: 56 | - {fileID: -9203433256221818662} 57 | -------------------------------------------------------------------------------- /Assets/Scenes/Raymarching/Global Volume Profile.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5284e34bb45fcf49bde0dd9bcd5af74 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/Raymarching/RayMarching_RaymarchShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db974a8866b6f0b4d8efca1152c14ccf 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Scenes/Raymarching/Raymarching Skybox.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-677125457590623375 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 11 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | version: 5 16 | --- !u!21 &2100000 17 | Material: 18 | serializedVersion: 6 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_Name: Raymarching Skybox 24 | m_Shader: {fileID: 106, guid: 0000000000000000f000000000000000, type: 0} 25 | m_ShaderKeywords: _SUNDISK_NONE 26 | m_LightmapFlags: 4 27 | m_EnableInstancingVariants: 0 28 | m_DoubleSidedGI: 0 29 | m_CustomRenderQueue: -1 30 | stringTagMap: {} 31 | disabledShaderPasses: [] 32 | m_SavedProperties: 33 | serializedVersion: 3 34 | m_TexEnvs: 35 | - _BackTex: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | - _BaseMap: 40 | m_Texture: {fileID: 0} 41 | m_Scale: {x: 1, y: 1} 42 | m_Offset: {x: 0, y: 0} 43 | - _BumpMap: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | - _DetailAlbedoMap: 48 | m_Texture: {fileID: 0} 49 | m_Scale: {x: 1, y: 1} 50 | m_Offset: {x: 0, y: 0} 51 | - _DetailMask: 52 | m_Texture: {fileID: 0} 53 | m_Scale: {x: 1, y: 1} 54 | m_Offset: {x: 0, y: 0} 55 | - _DetailNormalMap: 56 | m_Texture: {fileID: 0} 57 | m_Scale: {x: 1, y: 1} 58 | m_Offset: {x: 0, y: 0} 59 | - _DownTex: 60 | m_Texture: {fileID: 0} 61 | m_Scale: {x: 1, y: 1} 62 | m_Offset: {x: 0, y: 0} 63 | - _EmissionMap: 64 | m_Texture: {fileID: 0} 65 | m_Scale: {x: 1, y: 1} 66 | m_Offset: {x: 0, y: 0} 67 | - _FrontTex: 68 | m_Texture: {fileID: 0} 69 | m_Scale: {x: 1, y: 1} 70 | m_Offset: {x: 0, y: 0} 71 | - _LeftTex: 72 | m_Texture: {fileID: 0} 73 | m_Scale: {x: 1, y: 1} 74 | m_Offset: {x: 0, y: 0} 75 | - _MainTex: 76 | m_Texture: {fileID: 0} 77 | m_Scale: {x: 1, y: 1} 78 | m_Offset: {x: 0, y: 0} 79 | - _MetallicGlossMap: 80 | m_Texture: {fileID: 0} 81 | m_Scale: {x: 1, y: 1} 82 | m_Offset: {x: 0, y: 0} 83 | - _OcclusionMap: 84 | m_Texture: {fileID: 0} 85 | m_Scale: {x: 1, y: 1} 86 | m_Offset: {x: 0, y: 0} 87 | - _ParallaxMap: 88 | m_Texture: {fileID: 0} 89 | m_Scale: {x: 1, y: 1} 90 | m_Offset: {x: 0, y: 0} 91 | - _RightTex: 92 | m_Texture: {fileID: 0} 93 | m_Scale: {x: 1, y: 1} 94 | m_Offset: {x: 0, y: 0} 95 | - _SpecGlossMap: 96 | m_Texture: {fileID: 0} 97 | m_Scale: {x: 1, y: 1} 98 | m_Offset: {x: 0, y: 0} 99 | - _UpTex: 100 | m_Texture: {fileID: 0} 101 | m_Scale: {x: 1, y: 1} 102 | m_Offset: {x: 0, y: 0} 103 | - unity_Lightmaps: 104 | m_Texture: {fileID: 0} 105 | m_Scale: {x: 1, y: 1} 106 | m_Offset: {x: 0, y: 0} 107 | - unity_LightmapsInd: 108 | m_Texture: {fileID: 0} 109 | m_Scale: {x: 1, y: 1} 110 | m_Offset: {x: 0, y: 0} 111 | - unity_ShadowMasks: 112 | m_Texture: {fileID: 0} 113 | m_Scale: {x: 1, y: 1} 114 | m_Offset: {x: 0, y: 0} 115 | m_Ints: [] 116 | m_Floats: 117 | - _AlphaClip: 0 118 | - _AtmosphereThickness: 1 119 | - _Blend: 0 120 | - _BumpScale: 1 121 | - _ClearCoatMask: 0 122 | - _ClearCoatSmoothness: 0 123 | - _Cull: 2 124 | - _Cutoff: 0.5 125 | - _DetailAlbedoMapScale: 1 126 | - _DetailNormalMapScale: 1 127 | - _DstBlend: 0 128 | - _EnvironmentReflections: 1 129 | - _Exposure: 1.3 130 | - _GlossMapScale: 0 131 | - _Glossiness: 0 132 | - _GlossyReflections: 0 133 | - _ImageType: 0 134 | - _Layout: 0 135 | - _Mapping: 1 136 | - _Metallic: 0 137 | - _MirrorOnBack: 0 138 | - _OcclusionStrength: 1 139 | - _Parallax: 0.005 140 | - _QueueOffset: 0 141 | - _ReceiveShadows: 1 142 | - _Rotation: 0 143 | - _Smoothness: 0.5 144 | - _SmoothnessTextureChannel: 0 145 | - _SpecularHighlights: 1 146 | - _SrcBlend: 1 147 | - _SunDisk: 0 148 | - _SunSize: 0 149 | - _SunSizeConvergence: 5 150 | - _Surface: 0 151 | - _WorkflowMode: 1 152 | - _ZWrite: 1 153 | m_Colors: 154 | - _BaseColor: {r: 1, g: 1, b: 1, a: 1} 155 | - _Color: {r: 1, g: 1, b: 1, a: 1} 156 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 157 | - _GroundColor: {r: 0.062745094, g: 0.023529412, b: 0.1098, a: 1} 158 | - _SkyTint: {r: 1, g: 0, b: 0.35416698, a: 1} 159 | - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} 160 | - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} 161 | m_BuildTextureStacks: [] 162 | -------------------------------------------------------------------------------- /Assets/Scenes/Raymarching/Raymarching Skybox.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38757f4619292a8439c1a1022c8e11ec 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02a3527b6b33a924e8ec66aa805ea717 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts/DirtyFlag.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | public class DirtyFlag 5 | { 6 | public DirtyFlag(Transform transform) 7 | { 8 | _transform = transform; 9 | _objDirty = true; 10 | } 11 | 12 | private readonly Transform _transform; 13 | private bool _objDirty; 14 | 15 | public bool IsDirty => _objDirty || _transform.hasChanged; 16 | 17 | public void SetDirty() 18 | { 19 | _objDirty = true; 20 | } 21 | 22 | public void ResetDirtyFlag() 23 | { 24 | _objDirty = false; 25 | _transform.hasChanged = false; 26 | } 27 | 28 | public void SetField(ref T field, T value) 29 | { 30 | if (EqualityComparer.Default.Equals(field, value)) return; 31 | 32 | field = value; 33 | SetDirty(); 34 | } 35 | } -------------------------------------------------------------------------------- /Assets/Scripts/DirtyFlag.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9559359bddf5457abdd74253e14be7fb 3 | timeCreated: 1633081126 -------------------------------------------------------------------------------- /Assets/Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07379806987c47df84e2fdefcc2f3af1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts/ScreenCanvasFPS.cs: -------------------------------------------------------------------------------- 1 | using TMPro; 2 | using UnityEngine; 3 | 4 | [RequireComponent(typeof(TMP_Text))] 5 | public class ScreenCanvasFPS : MonoBehaviour 6 | { 7 | private TMP_Text tmp; 8 | 9 | // NOTE(WSWhitehouse): This array is to prevent creating new strings each frame (to reduce garbage) 10 | // NOTE(WSWhitehouse): The FPS counter will only go to the max number in this array (currently: 99) 11 | private readonly string[] fpsAsStrings = new string[] 12 | { 13 | "00 fps", "01 fps", "02 fps", "03 fps", "04 fps", "05 fps", "06 fps", "07 fps", "08 fps", "09 fps", 14 | "10 fps", "11 fps", "12 fps", "13 fps", "14 fps", "15 fps", "16 fps", "17 fps", "18 fps", "19 fps", 15 | "20 fps", "21 fps", "22 fps", "23 fps", "24 fps", "25 fps", "26 fps", "27 fps", "28 fps", "29 fps", 16 | "30 fps", "31 fps", "32 fps", "33 fps", "34 fps", "35 fps", "36 fps", "37 fps", "38 fps", "39 fps", 17 | "40 fps", "41 fps", "42 fps", "43 fps", "44 fps", "45 fps", "46 fps", "47 fps", "48 fps", "49 fps", 18 | "50 fps", "51 fps", "52 fps", "53 fps", "54 fps", "55 fps", "56 fps", "57 fps", "58 fps", "59 fps", 19 | "60 fps", "61 fps", "62 fps", "63 fps", "64 fps", "65 fps", "66 fps", "67 fps", "68 fps", "69 fps", 20 | "70 fps", "71 fps", "72 fps", "73 fps", "74 fps", "75 fps", "76 fps", "77 fps", "78 fps", "79 fps", 21 | "80 fps", "81 fps", "82 fps", "83 fps", "84 fps", "85 fps", "86 fps", "87 fps", "88 fps", "89 fps", 22 | "90 fps", "91 fps", "92 fps", "93 fps", "94 fps", "95 fps", "96 fps", "97 fps", "98 fps", "99 fps" 23 | }; 24 | 25 | private void Awake() 26 | { 27 | tmp = GetComponent(); 28 | } 29 | 30 | private void Update() 31 | { 32 | int fps = Mathf.RoundToInt((1 / Time.smoothDeltaTime) * Time.timeScale); 33 | tmp.text = fpsAsStrings[Mathf.Clamp(fps, 0, fpsAsStrings.Length - 1)]; 34 | } 35 | } -------------------------------------------------------------------------------- /Assets/Scripts/ScreenCanvasFPS.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c29b653e90a1df04f8b2dcfc2f0815c4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/ScreenCanvasNameAndVersionText.cs: -------------------------------------------------------------------------------- 1 | using TMPro; 2 | using UnityEngine; 3 | 4 | [RequireComponent(typeof(TMP_Text))] 5 | public class ScreenCanvasNameAndVersionText : MonoBehaviour 6 | { 7 | private void Awake() 8 | { 9 | var tmp = GetComponent(); 10 | tmp.text = $"{Application.productName} {Application.version} - {Application.companyName}"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Assets/Scripts/ScreenCanvasNameAndVersionText.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6629b4dd25bf0ac4ab23e4fe961fe728 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts/SimpleCameraController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be76e5f14cfee674cb30b491fb72b09b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TextMesh Pro.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f54d1bd14bd3ca042bd867b519fee8cc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/URP.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0735c275001a2c84dafdb30deced5d8d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRP-HighQuality.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3} 13 | m_Name: UniversalRP-HighQuality 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 9 16 | k_AssetPreviousVersion: 9 17 | m_RendererType: 1 18 | m_RendererData: {fileID: 0} 19 | m_RendererDataList: 20 | - {fileID: 11400000, guid: 4a8e21d5c33334b11b34a596161b9360, type: 2} 21 | m_DefaultRendererIndex: 0 22 | m_RequireDepthTexture: 1 23 | m_RequireOpaqueTexture: 1 24 | m_OpaqueDownsampling: 1 25 | m_SupportsTerrainHoles: 1 26 | m_StoreActionsOptimization: 0 27 | m_SupportsHDR: 1 28 | m_MSAA: 2 29 | m_RenderScale: 1 30 | m_MainLightRenderingMode: 1 31 | m_MainLightShadowsSupported: 1 32 | m_MainLightShadowmapResolution: 2048 33 | m_AdditionalLightsRenderingMode: 1 34 | m_AdditionalLightsPerObjectLimit: 4 35 | m_AdditionalLightShadowsSupported: 1 36 | m_AdditionalLightsShadowmapResolution: 2048 37 | m_AdditionalLightsShadowResolutionTierLow: 512 38 | m_AdditionalLightsShadowResolutionTierMedium: 1024 39 | m_AdditionalLightsShadowResolutionTierHigh: 2048 40 | m_ReflectionProbeBlending: 1 41 | m_ReflectionProbeBoxProjection: 0 42 | m_ShadowDistance: 50 43 | m_ShadowCascadeCount: 2 44 | m_Cascade2Split: 0.25 45 | m_Cascade3Split: {x: 0.1, y: 0.3} 46 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467} 47 | m_CascadeBorder: 0.1 48 | m_ShadowDepthBias: 1 49 | m_ShadowNormalBias: 1 50 | m_SoftShadowsSupported: 1 51 | m_ConservativeEnclosingSphere: 0 52 | m_NumIterationsEnclosingSphere: 64 53 | m_AdditionalLightsCookieResolution: 2048 54 | m_AdditionalLightsCookieFormat: 3 55 | m_UseSRPBatcher: 1 56 | m_SupportsDynamicBatching: 0 57 | m_MixedLightingSupported: 1 58 | m_SupportsLightLayers: 0 59 | m_DebugLevel: 0 60 | m_UseAdaptivePerformance: 1 61 | m_ColorGradingMode: 0 62 | m_ColorGradingLutSize: 32 63 | m_UseFastSRGBLinearConversion: 0 64 | m_ShadowType: 1 65 | m_LocalShadowsSupported: 0 66 | m_LocalShadowsAtlasResolution: 256 67 | m_MaxPixelLights: 0 68 | m_ShadowAtlasResolution: 256 69 | m_ShaderVariantLogLevel: 0 70 | m_VolumeFrameworkUpdateMode: 0 71 | m_ShadowCascades: 1 72 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRP-HighQuality.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19ba41d7c0026c3459d37c2fe90c55a0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRP-LowQuality.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3} 13 | m_Name: UniversalRP-LowQuality 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 9 16 | k_AssetPreviousVersion: 9 17 | m_RendererType: 1 18 | m_RendererData: {fileID: 0} 19 | m_RendererDataList: 20 | - {fileID: 11400000, guid: 4a8e21d5c33334b11b34a596161b9360, type: 2} 21 | m_DefaultRendererIndex: 0 22 | m_RequireDepthTexture: 1 23 | m_RequireOpaqueTexture: 1 24 | m_OpaqueDownsampling: 1 25 | m_SupportsTerrainHoles: 1 26 | m_StoreActionsOptimization: 0 27 | m_SupportsHDR: 0 28 | m_MSAA: 1 29 | m_RenderScale: 1 30 | m_MainLightRenderingMode: 1 31 | m_MainLightShadowsSupported: 0 32 | m_MainLightShadowmapResolution: 2048 33 | m_AdditionalLightsRenderingMode: 0 34 | m_AdditionalLightsPerObjectLimit: 4 35 | m_AdditionalLightShadowsSupported: 0 36 | m_AdditionalLightsShadowmapResolution: 2048 37 | m_AdditionalLightsShadowResolutionTierLow: 512 38 | m_AdditionalLightsShadowResolutionTierMedium: 1024 39 | m_AdditionalLightsShadowResolutionTierHigh: 2048 40 | m_ReflectionProbeBlending: 0 41 | m_ReflectionProbeBoxProjection: 0 42 | m_ShadowDistance: 50 43 | m_ShadowCascadeCount: 1 44 | m_Cascade2Split: 0.25 45 | m_Cascade3Split: {x: 0.1, y: 0.3} 46 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467} 47 | m_CascadeBorder: 0.1 48 | m_ShadowDepthBias: 1 49 | m_ShadowNormalBias: 1 50 | m_SoftShadowsSupported: 0 51 | m_ConservativeEnclosingSphere: 0 52 | m_NumIterationsEnclosingSphere: 64 53 | m_AdditionalLightsCookieResolution: 2048 54 | m_AdditionalLightsCookieFormat: 3 55 | m_UseSRPBatcher: 1 56 | m_SupportsDynamicBatching: 0 57 | m_MixedLightingSupported: 1 58 | m_SupportsLightLayers: 0 59 | m_DebugLevel: 0 60 | m_UseAdaptivePerformance: 1 61 | m_ColorGradingMode: 0 62 | m_ColorGradingLutSize: 16 63 | m_UseFastSRGBLinearConversion: 0 64 | m_ShadowType: 1 65 | m_LocalShadowsSupported: 0 66 | m_LocalShadowsAtlasResolution: 256 67 | m_MaxPixelLights: 0 68 | m_ShadowAtlasResolution: 256 69 | m_ShaderVariantLogLevel: 0 70 | m_VolumeFrameworkUpdateMode: 0 71 | m_ShadowCascades: 0 72 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRP-LowQuality.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a31e9f9f9c9d4b9429ed0d1234e22103 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRP-MediumQuality.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3} 13 | m_Name: UniversalRP-MediumQuality 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 9 16 | k_AssetPreviousVersion: 9 17 | m_RendererType: 1 18 | m_RendererData: {fileID: 0} 19 | m_RendererDataList: 20 | - {fileID: 11400000, guid: 4a8e21d5c33334b11b34a596161b9360, type: 2} 21 | m_DefaultRendererIndex: 0 22 | m_RequireDepthTexture: 1 23 | m_RequireOpaqueTexture: 1 24 | m_OpaqueDownsampling: 1 25 | m_SupportsTerrainHoles: 1 26 | m_StoreActionsOptimization: 0 27 | m_SupportsHDR: 0 28 | m_MSAA: 1 29 | m_RenderScale: 1 30 | m_MainLightRenderingMode: 1 31 | m_MainLightShadowsSupported: 1 32 | m_MainLightShadowmapResolution: 2048 33 | m_AdditionalLightsRenderingMode: 1 34 | m_AdditionalLightsPerObjectLimit: 4 35 | m_AdditionalLightShadowsSupported: 0 36 | m_AdditionalLightsShadowmapResolution: 2048 37 | m_AdditionalLightsShadowResolutionTierLow: 512 38 | m_AdditionalLightsShadowResolutionTierMedium: 1024 39 | m_AdditionalLightsShadowResolutionTierHigh: 2048 40 | m_ReflectionProbeBlending: 0 41 | m_ReflectionProbeBoxProjection: 0 42 | m_ShadowDistance: 50 43 | m_ShadowCascadeCount: 1 44 | m_Cascade2Split: 0.25 45 | m_Cascade3Split: {x: 0.1, y: 0.3} 46 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467} 47 | m_CascadeBorder: 0.1 48 | m_ShadowDepthBias: 1 49 | m_ShadowNormalBias: 1 50 | m_SoftShadowsSupported: 0 51 | m_ConservativeEnclosingSphere: 0 52 | m_NumIterationsEnclosingSphere: 64 53 | m_AdditionalLightsCookieResolution: 2048 54 | m_AdditionalLightsCookieFormat: 3 55 | m_UseSRPBatcher: 1 56 | m_SupportsDynamicBatching: 0 57 | m_MixedLightingSupported: 1 58 | m_SupportsLightLayers: 0 59 | m_DebugLevel: 0 60 | m_UseAdaptivePerformance: 1 61 | m_ColorGradingMode: 0 62 | m_ColorGradingLutSize: 32 63 | m_UseFastSRGBLinearConversion: 0 64 | m_ShadowType: 1 65 | m_LocalShadowsSupported: 0 66 | m_LocalShadowsAtlasResolution: 256 67 | m_MaxPixelLights: 0 68 | m_ShadowAtlasResolution: 256 69 | m_ShaderVariantLogLevel: 0 70 | m_VolumeFrameworkUpdateMode: 0 71 | m_ShadowCascades: 0 72 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRP-MediumQuality.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d847b876476d3d6468f5dfcd34266f96 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRenderPipelineGlobalSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 2ec995e51a6e251468d2a3fd8a686257, type: 3} 13 | m_Name: UniversalRenderPipelineGlobalSettings 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 2 16 | lightLayerName0: Light Layer default 17 | lightLayerName1: Light Layer 1 18 | lightLayerName2: Light Layer 2 19 | lightLayerName3: Light Layer 3 20 | lightLayerName4: Light Layer 4 21 | lightLayerName5: Light Layer 5 22 | lightLayerName6: Light Layer 6 23 | lightLayerName7: Light Layer 7 24 | m_StripDebugVariants: 1 25 | m_StripUnusedPostProcessingVariants: 1 26 | m_StripUnusedVariants: 1 27 | supportRuntimeDebugDisplay: 0 28 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRenderPipelineGlobalSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38b35347542e5af4c9b140950c5b18db 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRenderer.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-5551366795030641574 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 30153d48daea4b7187628866f8221c68, type: 3} 13 | m_Name: RaymarchRenderFeature 14 | m_EditorClassIdentifier: 15 | m_Active: 1 16 | passEvent: 400 17 | --- !u!114 &11400000 18 | MonoBehaviour: 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_GameObject: {fileID: 0} 24 | m_Enabled: 1 25 | m_EditorHideFlags: 0 26 | m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3} 27 | m_Name: UniversalRenderer 28 | m_EditorClassIdentifier: 29 | debugShaders: 30 | debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, type: 3} 31 | m_RendererFeatures: 32 | - {fileID: -5551366795030641574} 33 | m_RendererFeatureMap: 5ac44cf44f95f5b2 34 | m_UseNativeRenderPass: 0 35 | postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} 36 | xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2} 37 | shaders: 38 | blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} 39 | copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3} 40 | screenSpaceShadowPS: {fileID: 4800000, guid: 0f854b35a0cf61a429bd5dcfea30eddd, type: 3} 41 | samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3} 42 | stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3} 43 | fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3} 44 | materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3} 45 | coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3} 46 | coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b, type: 3} 47 | cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf, type: 3} 48 | objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486, type: 3} 49 | m_AssetVersion: 1 50 | m_OpaqueLayerMask: 51 | serializedVersion: 2 52 | m_Bits: 2147483647 53 | m_TransparentLayerMask: 54 | serializedVersion: 2 55 | m_Bits: 2147483647 56 | m_DefaultStencilState: 57 | overrideStencilState: 0 58 | stencilReference: 0 59 | stencilCompareFunction: 8 60 | passOperation: 2 61 | failOperation: 0 62 | zFailOperation: 0 63 | m_ShadowTransparentReceive: 1 64 | m_RenderingMode: 1 65 | m_DepthPrimingMode: 1 66 | m_AccurateGbufferNormals: 0 67 | m_ClusteredRendering: 0 68 | m_TileSize: 32 69 | m_IntermediateTextureMode: 1 70 | -------------------------------------------------------------------------------- /Assets/URP/UniversalRenderer.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a8e21d5c33334b11b34a596161b9360 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/XR.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69251545c3284d54d8f8c24ea11a7b90 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/XR/Loaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5e7b42bb3354274bb0945cf536f92cb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/XR/Loaders/Mock HMD Loader.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 0660e8fc444734757ae6f6c40c2d33a0, type: 3} 13 | m_Name: Mock HMD Loader 14 | m_EditorClassIdentifier: 15 | -------------------------------------------------------------------------------- /Assets/XR/Loaders/Mock HMD Loader.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a16904afe366334dba9b8847bab7dd1 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/XR/Loaders/Open XR Loader No Pre Init.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: ee62ffd6c7e6f3545899783b1fbdd9d4, type: 3} 13 | m_Name: Open XR Loader No Pre Init 14 | m_EditorClassIdentifier: 15 | -------------------------------------------------------------------------------- /Assets/XR/Loaders/Open XR Loader No Pre Init.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2bcb45c6bdb009844bf6e6753a0dc374 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/XR/Loaders/Open XR Loader.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d3552e428dc7646a88de3ed3650f87da, type: 3} 13 | m_Name: Open XR Loader 14 | m_EditorClassIdentifier: 15 | -------------------------------------------------------------------------------- /Assets/XR/Loaders/Open XR Loader.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8042817b1550c5d4aad5f59e1837776d 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/XR/Settings.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd835522287d3224f93f1666a93b484a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/XR/Settings/Mock HMD Build Settings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: c8bf066bf8a4947a1be502d267edb82f, type: 3} 13 | m_Name: Mock HMD Build Settings 14 | m_EditorClassIdentifier: 15 | renderMode: 0 16 | -------------------------------------------------------------------------------- /Assets/XR/Settings/Mock HMD Build Settings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1df3ee01f1ec5fd4184aed905c0f95c6 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/XR/Settings/Open XR Package Settings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-4892255786714302573 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: b5a1f07dc5afe854f9f12a4194aca3fb, type: 3} 13 | m_Name: Standalone 14 | m_EditorClassIdentifier: 15 | features: 16 | - {fileID: -866006100749143756} 17 | - {fileID: 6695591180412862407} 18 | - {fileID: 7542162071659167035} 19 | - {fileID: 2468392233793733894} 20 | - {fileID: -4098692320568011648} 21 | - {fileID: 6665833215375820123} 22 | - {fileID: 245740508753752171} 23 | - {fileID: -3342284193427041978} 24 | - {fileID: 6844422124006727208} 25 | - {fileID: 6685066400180842916} 26 | - {fileID: -69311725234413459} 27 | m_renderMode: 0 28 | m_depthSubmissionMode: 0 29 | --- !u!114 &-4098692320568011648 30 | MonoBehaviour: 31 | m_ObjectHideFlags: 0 32 | m_CorrespondingSourceObject: {fileID: 0} 33 | m_PrefabInstance: {fileID: 0} 34 | m_PrefabAsset: {fileID: 0} 35 | m_GameObject: {fileID: 0} 36 | m_Enabled: 1 37 | m_EditorHideFlags: 0 38 | m_Script: {fileID: 11500000, guid: f928d0d73a35f294fbe357ca17aa3547, type: 3} 39 | m_Name: MicrosoftHandInteraction Standalone 40 | m_EditorClassIdentifier: 41 | m_enabled: 0 42 | nameUi: Microsoft Hand Interaction Profile 43 | version: 0.0.1 44 | featureIdInternal: com.unity.openxr.feature.input.handtracking 45 | openxrExtensionStrings: XR_MSFT_hand_interaction 46 | company: Unity 47 | priority: 0 48 | required: 0 49 | --- !u!114 &-3342284193427041978 50 | MonoBehaviour: 51 | m_ObjectHideFlags: 0 52 | m_CorrespondingSourceObject: {fileID: 0} 53 | m_PrefabInstance: {fileID: 0} 54 | m_PrefabAsset: {fileID: 0} 55 | m_GameObject: {fileID: 0} 56 | m_Enabled: 1 57 | m_EditorHideFlags: 0 58 | m_Script: {fileID: 11500000, guid: 7de993716e042c6499d0c18eed3a773c, type: 3} 59 | m_Name: MockRuntime Standalone 60 | m_EditorClassIdentifier: 61 | m_enabled: 0 62 | nameUi: Mock Runtime 63 | version: 0.0.2 64 | featureIdInternal: com.unity.openxr.feature.mockruntime 65 | openxrExtensionStrings: XR_UNITY_null_gfx 66 | company: Unity 67 | priority: 0 68 | required: 0 69 | ignoreValidationErrors: 0 70 | --- !u!114 &-866006100749143756 71 | MonoBehaviour: 72 | m_ObjectHideFlags: 0 73 | m_CorrespondingSourceObject: {fileID: 0} 74 | m_PrefabInstance: {fileID: 0} 75 | m_PrefabAsset: {fileID: 0} 76 | m_GameObject: {fileID: 0} 77 | m_Enabled: 1 78 | m_EditorHideFlags: 0 79 | m_Script: {fileID: 11500000, guid: 486b5e28864f9a94b979b9620ce5006d, type: 3} 80 | m_Name: ConformanceAutomationFeature Standalone 81 | m_EditorClassIdentifier: 82 | m_enabled: 0 83 | nameUi: Conformance Automation 84 | version: 0.0.1 85 | featureIdInternal: com.unity.openxr.feature.conformance 86 | openxrExtensionStrings: XR_EXT_conformance_automation 87 | company: Unity 88 | priority: 0 89 | required: 0 90 | --- !u!114 &-69311725234413459 91 | MonoBehaviour: 92 | m_ObjectHideFlags: 0 93 | m_CorrespondingSourceObject: {fileID: 0} 94 | m_PrefabInstance: {fileID: 0} 95 | m_PrefabAsset: {fileID: 0} 96 | m_GameObject: {fileID: 0} 97 | m_Enabled: 1 98 | m_EditorHideFlags: 0 99 | m_Script: {fileID: 11500000, guid: 0d6ccd3d0ef0f1d458e69421dccbdae1, type: 3} 100 | m_Name: ValveIndexControllerProfile Standalone 101 | m_EditorClassIdentifier: 102 | m_enabled: 0 103 | nameUi: Valve Index Controller Profile 104 | version: 0.0.1 105 | featureIdInternal: com.unity.openxr.feature.input.valveindex 106 | openxrExtensionStrings: 107 | company: Unity 108 | priority: 0 109 | required: 0 110 | --- !u!114 &11400000 111 | MonoBehaviour: 112 | m_ObjectHideFlags: 0 113 | m_CorrespondingSourceObject: {fileID: 0} 114 | m_PrefabInstance: {fileID: 0} 115 | m_PrefabAsset: {fileID: 0} 116 | m_GameObject: {fileID: 0} 117 | m_Enabled: 1 118 | m_EditorHideFlags: 0 119 | m_Script: {fileID: 11500000, guid: 9f0ebc320a151d3408ea1e9fce54d40e, type: 3} 120 | m_Name: Open XR Package Settings 121 | m_EditorClassIdentifier: 122 | Keys: 01000000 123 | Values: 124 | - {fileID: -4892255786714302573} 125 | --- !u!114 &245740508753752171 126 | MonoBehaviour: 127 | m_ObjectHideFlags: 0 128 | m_CorrespondingSourceObject: {fileID: 0} 129 | m_PrefabInstance: {fileID: 0} 130 | m_PrefabAsset: {fileID: 0} 131 | m_GameObject: {fileID: 0} 132 | m_Enabled: 1 133 | m_EditorHideFlags: 0 134 | m_Script: {fileID: 11500000, guid: 96efa89124dda0941802f28ad8249b87, type: 3} 135 | m_Name: MockDriver Standalone 136 | m_EditorClassIdentifier: 137 | m_enabled: 0 138 | nameUi: Mock Driver 139 | version: 0.0.1 140 | featureIdInternal: com.unity.openxr.feature.mockdriver 141 | openxrExtensionStrings: XR_UNITY_mock_driver 142 | company: Unity 143 | priority: 0 144 | required: 0 145 | --- !u!114 &2468392233793733894 146 | MonoBehaviour: 147 | m_ObjectHideFlags: 0 148 | m_CorrespondingSourceObject: {fileID: 0} 149 | m_PrefabInstance: {fileID: 0} 150 | m_PrefabAsset: {fileID: 0} 151 | m_GameObject: {fileID: 0} 152 | m_Enabled: 1 153 | m_EditorHideFlags: 0 154 | m_Script: {fileID: 11500000, guid: 0f6bfdbcb316ed242b30a8798c9eb853, type: 3} 155 | m_Name: KHRSimpleControllerProfile Standalone 156 | m_EditorClassIdentifier: 157 | m_enabled: 0 158 | nameUi: Khronos Simple Controller Profile 159 | version: 0.0.1 160 | featureIdInternal: com.unity.openxr.feature.input.khrsimpleprofile 161 | openxrExtensionStrings: 162 | company: Unity 163 | priority: 0 164 | required: 0 165 | --- !u!114 &6665833215375820123 166 | MonoBehaviour: 167 | m_ObjectHideFlags: 0 168 | m_CorrespondingSourceObject: {fileID: 0} 169 | m_PrefabInstance: {fileID: 0} 170 | m_PrefabAsset: {fileID: 0} 171 | m_GameObject: {fileID: 0} 172 | m_Enabled: 1 173 | m_EditorHideFlags: 0 174 | m_Script: {fileID: 11500000, guid: 761fdd4502cb7a84e9ec7a2b24f33f37, type: 3} 175 | m_Name: MicrosoftMotionControllerProfile Standalone 176 | m_EditorClassIdentifier: 177 | m_enabled: 0 178 | nameUi: Microsoft Motion Controller Profile 179 | version: 0.0.1 180 | featureIdInternal: com.unity.openxr.feature.input.microsoftmotioncontroller 181 | openxrExtensionStrings: 182 | company: Unity 183 | priority: 0 184 | required: 0 185 | --- !u!114 &6685066400180842916 186 | MonoBehaviour: 187 | m_ObjectHideFlags: 0 188 | m_CorrespondingSourceObject: {fileID: 0} 189 | m_PrefabInstance: {fileID: 0} 190 | m_PrefabAsset: {fileID: 0} 191 | m_GameObject: {fileID: 0} 192 | m_Enabled: 1 193 | m_EditorHideFlags: 0 194 | m_Script: {fileID: 11500000, guid: 056125dd64c0ed540b40a4af74f7b495, type: 3} 195 | m_Name: RuntimeDebuggerOpenXRFeature Standalone 196 | m_EditorClassIdentifier: 197 | m_enabled: 0 198 | nameUi: Runtime Debugger 199 | version: 1 200 | featureIdInternal: com.unity.openxr.features.runtimedebugger 201 | openxrExtensionStrings: 202 | company: Unity 203 | priority: 0 204 | required: 0 205 | cacheSize: 1048576 206 | perThreadCacheSize: 51200 207 | --- !u!114 &6695591180412862407 208 | MonoBehaviour: 209 | m_ObjectHideFlags: 0 210 | m_CorrespondingSourceObject: {fileID: 0} 211 | m_PrefabInstance: {fileID: 0} 212 | m_PrefabAsset: {fileID: 0} 213 | m_GameObject: {fileID: 0} 214 | m_Enabled: 1 215 | m_EditorHideFlags: 0 216 | m_Script: {fileID: 11500000, guid: b3cf79659a011bd419c7a2a30eb74e9a, type: 3} 217 | m_Name: EyeGazeInteraction Standalone 218 | m_EditorClassIdentifier: 219 | m_enabled: 0 220 | nameUi: Eye Gaze Interaction Profile 221 | version: 0.0.1 222 | featureIdInternal: com.unity.openxr.feature.input.eyetracking 223 | openxrExtensionStrings: XR_EXT_eye_gaze_interaction 224 | company: Unity 225 | priority: 0 226 | required: 0 227 | --- !u!114 &6844422124006727208 228 | MonoBehaviour: 229 | m_ObjectHideFlags: 0 230 | m_CorrespondingSourceObject: {fileID: 0} 231 | m_PrefabInstance: {fileID: 0} 232 | m_PrefabAsset: {fileID: 0} 233 | m_GameObject: {fileID: 0} 234 | m_Enabled: 1 235 | m_EditorHideFlags: 0 236 | m_Script: {fileID: 11500000, guid: feeef8d85de8db242bdda70cc7ff5acd, type: 3} 237 | m_Name: OculusTouchControllerProfile Standalone 238 | m_EditorClassIdentifier: 239 | m_enabled: 1 240 | nameUi: Oculus Touch Controller Profile 241 | version: 0.0.1 242 | featureIdInternal: com.unity.openxr.feature.input.oculustouch 243 | openxrExtensionStrings: 244 | company: Unity 245 | priority: 0 246 | required: 0 247 | --- !u!114 &7542162071659167035 248 | MonoBehaviour: 249 | m_ObjectHideFlags: 0 250 | m_CorrespondingSourceObject: {fileID: 0} 251 | m_PrefabInstance: {fileID: 0} 252 | m_PrefabAsset: {fileID: 0} 253 | m_GameObject: {fileID: 0} 254 | m_Enabled: 1 255 | m_EditorHideFlags: 0 256 | m_Script: {fileID: 11500000, guid: 274c02963f889a64e90bc2e596e21d13, type: 3} 257 | m_Name: HTCViveControllerProfile Standalone 258 | m_EditorClassIdentifier: 259 | m_enabled: 0 260 | nameUi: HTC Vive Controller Profile 261 | version: 0.0.1 262 | featureIdInternal: com.unity.openxr.feature.input.htcvive 263 | openxrExtensionStrings: 264 | company: Unity 265 | priority: 0 266 | required: 0 267 | -------------------------------------------------------------------------------- /Assets/XR/Settings/Open XR Package Settings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15ad7b8000ff1d84eaa6e28e5a5d61b2 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/XR/Settings/OpenXR Editor Settings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 975057b4fdcfb8142b3080d19a5cc712, type: 3} 13 | m_Name: OpenXR Editor Settings 14 | m_EditorClassIdentifier: 15 | Keys: 16 | Values: [] 17 | -------------------------------------------------------------------------------- /Assets/XR/Settings/OpenXR Editor Settings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b05eb04979eb584bb0b27d398ead54b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/XR/XRGeneralSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-5081302363269483883 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d236b7d11115f2143951f1e14045df39, type: 3} 13 | m_Name: Standalone Settings 14 | m_EditorClassIdentifier: 15 | m_LoaderManagerInstance: {fileID: -359022754640419011} 16 | m_InitManagerOnStart: 1 17 | --- !u!114 &-359022754640419011 18 | MonoBehaviour: 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_GameObject: {fileID: 0} 24 | m_Enabled: 1 25 | m_EditorHideFlags: 0 26 | m_Script: {fileID: 11500000, guid: f4c3631f5e58749a59194e0cf6baf6d5, type: 3} 27 | m_Name: Standalone Providers 28 | m_EditorClassIdentifier: 29 | m_RequiresSettingsUpdate: 0 30 | m_AutomaticLoading: 0 31 | m_AutomaticRunning: 0 32 | m_Loaders: [] 33 | --- !u!114 &11400000 34 | MonoBehaviour: 35 | m_ObjectHideFlags: 0 36 | m_CorrespondingSourceObject: {fileID: 0} 37 | m_PrefabInstance: {fileID: 0} 38 | m_PrefabAsset: {fileID: 0} 39 | m_GameObject: {fileID: 0} 40 | m_Enabled: 1 41 | m_EditorHideFlags: 0 42 | m_Script: {fileID: 11500000, guid: d2dc886499c26824283350fa532d087d, type: 3} 43 | m_Name: XRGeneralSettings 44 | m_EditorClassIdentifier: 45 | Keys: 01000000 46 | Values: 47 | - {fileID: -5081302363269483883} 48 | -------------------------------------------------------------------------------- /Assets/XR/XRGeneralSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dea6c7fe565b16a448e879494869ded6 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Docs/GettingStarted.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | ## URP Renderer Setup 3 | Firstly, the URP [Universal Renderer](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.0/manual/urp-universal-renderer.html) will need some settings updated for the Raymarching to be supported. 4 | 5 | Change the URP renderer to use the [Deferred Rendering Path](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.0/manual/rendering/deferred-rendering-path.html) - Raymarching is not supported on the Forward renderer. 6 | 7 | The [[RaymarchRenderFeature]] needs to be added to the renderer (this is at the bottom of the Universal Renderer Asset, click 'Add Renderer Feature'). For more information on adding Render Features click [here](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.0/manual/urp-renderer-feature-how-to-add.html) to go to the docs. The [[RaymarchRenderFeature]] includes any settings that are used for setting up the custom render pass. 8 | 9 | ## Scene Setup 10 | Each scene that will render any Raymarched objects needs to include a [[RaymarchScene]]. Right click in the hierarchy -> Raymarching -> Create Scene. There can only be one Raymarch Scene per Unity scene. 11 | 12 | Add [[RaymarchObjects]] to the scene. Right click in the hierarchy -> Raymarching -> Create Object. This will create an empty Raymarch object in the scene, for the object to render assign an [[SDFShaderFeature]] (there are some common objects already included in the project). 13 | 14 | To update the shader that renders all the objects in the scene click the "Regenerate Shader" button on the [[RaymarchScene]]. 15 | 16 | You should now have a basic scene with Raymarched Objects. -------------------------------------------------------------------------------- /Docs/README.md: -------------------------------------------------------------------------------- 1 | # Raymarching 2 | Render procedual 3D & 4D objects through Signed Distance Fields (SDFs) using the Raymarching rendering technique in Unity's Universal Render Pipeline (URP). 3 | 4 | See the [[GettingStarted]] page for more information on getting set up in Untiy. These docs are designed to be read using Obsidian - see [[README#Software]] below. 5 | 6 | # Software 7 | ##### Unity Engine 8 | Minimum version: [2021.2.0](https://unity3d.com/unity/whats-new/2021.2.0) or above (other versions are untested) 9 | 10 | Requires the Universal Render Pipeline package - version: 12.0.0 or above. Any links to external Unity documentation will link to that version of the docs. 11 | 12 | ##### Obsidian 13 | This is used to read the docs, it is not a requirement. Download available on their website: https://obsidian.md/ 14 | 15 | # Contributors 16 | - [William Whitehouse](https://williamwhitehouse.dev/) - Main Development 17 | - [Zack Collins]() - 3D Object Rotations, 4D Camera & Objects 18 | 19 | # Sources & Useful Resources 20 | Here is a list of sources and projects that were used to aid the development of this project. 21 | 22 | - [Inigo Quilez:](https://www.youtube.com/c/InigoQuilez) 23 | - [3D Signed Distance Functions](https://iquilezles.org/www/articles/distfunctions/distfunctions.htm) 24 | - [iq's Shader Toy](https://www.shadertoy.com/user/iq) - there's some really cool stuff on there! 25 | 26 | - Other GitHub Projects: 27 | - https://github.com/SebLague/Ray-Marching 28 | - https://github.com/IRCSS/UnityRaymarching/tree/master/Assets 29 | - https://github.com/electricsquare/raymarching-workshop 30 | - https://github.com/hecomi/uRaymarchingExamples 31 | - https://github.com/hdlx/RMVR 32 | 33 | - [The Art of Code:](https://www.youtube.com/c/TheArtofCodeIsCool/featured) 34 | - [The Art of Code's Shader Toy](https://www.shadertoy.com/user/BigWIngs) 35 | - [Writing a Ray Marcher in Unity - YouTube](https://www.youtube.com/watch?v=S8AWd66hoCo) 36 | - [RayMarching: Basic Operators - YouTube](https://www.youtube.com/watch?v=AfKGMUDWfuE) 37 | - [Shader Coding: Ray Marching Tips & Tricks - YouTube](https://www.youtube.com/watch?feature=youtu.be&v=Vmb7VGBVZJA) 38 | 39 | - 4D Raymarching 40 | - https://marctenbosch.com/ndphysics/ 41 | - https://4dtoys.com/ 42 | - [Making a 4D Game - 4D Explorer - YouTube](https://www.youtube.com/watch?v=nUExziADzjc) 43 | - https://github.com/Jellevermandere/4D-Raymarching 44 | 45 | - Other Sources: 46 | - https://adrianb.io/2016/10/01/raymarching.html 47 | - [Coding Adventure: Ray Marching - YouTube](https://www.youtube.com/watch?v=Cp5WWtMoeKg&feature=youtu.be) 48 | - [Making of Fractal Collector: A Unity Fractal Game - YouTube](https://www.youtube.com/watch?v=0jwkZKDOzfc) 49 | - https://medium.com/@shahriyarshahrabi/raymarching-in-unity-59c72664252a 50 | - http://i-saint.hatenablog.com/entry/2015/08/24/225254 51 | - http://blog.hvidtfeldts.net/index.php/2011/06/distance-estimated-3d-fractals-part-i/ 52 | - https://www.alanzucconi.com/2016/07/01/raymarching/ 53 | - https://www.alanzucconi.com/2016/07/01/signed-distance-functions/ 54 | - https://mercury.sexy/hg_sdf/ 55 | - https://www.pouet.net/topic.php?which=7931&page=1 56 | - https://web.archive.org/web/20140722124350/http://www.pouet.net/topic.php?which=7909&page=1 57 | 58 | - Unrelated, But Worth Reading: 59 | - https://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToMatrix/index.htm 60 | - https://gist.github.com/mattatz/86fff4b32d198d0928d0fa4ff32cf6fa 61 | - https://catlikecoding.com/unity/tutorials/rendering/part-1/ 62 | - https://ntrs.nasa.gov/citations/19770019231 63 | - https://catlikecoding.com/unity/tutorials/rendering/ 64 | - http://www.shaderslab.com/shaders.html 65 | - https://www.cyanilux.com/tutorials/intro-to-shaders/ 66 | - https://www.cyanilux.com/tutorials/urp-shader-code/ 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /Docs/RaymarchObjects.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WSWhitehouse/Unity-Raymarching/0518eaf9969eed62eed5d32dee60ba74599398ab/Docs/RaymarchObjects.md -------------------------------------------------------------------------------- /Docs/RaymarchRenderFeature.md: -------------------------------------------------------------------------------- 1 | # Raymarch Render Feature -------------------------------------------------------------------------------- /Docs/RaymarchScene.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WSWhitehouse/Unity-Raymarching/0518eaf9969eed62eed5d32dee60ba74599398ab/Docs/RaymarchScene.md -------------------------------------------------------------------------------- /Docs/SDFShaderFeature.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WSWhitehouse/Unity-Raymarching/0518eaf9969eed62eed5d32dee60ba74599398ab/Docs/SDFShaderFeature.md -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2020 WSWhitehouse 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": "1.15.1", 4 | "com.unity.ide.rider": "3.0.7", 5 | "com.unity.ide.visualstudio": "2.0.11", 6 | "com.unity.ide.vscode": "1.2.4", 7 | "com.unity.inputsystem": "1.1.1", 8 | "com.unity.render-pipelines.universal": "12.1.1", 9 | "com.unity.test-framework": "1.1.29", 10 | "com.unity.textmeshpro": "3.0.6", 11 | "com.unity.timeline": "1.6.2", 12 | "com.unity.ugui": "1.0.0", 13 | "com.unity.xr.management": "4.1.0", 14 | "com.unity.xr.mock-hmd": "1.3.0-preview.1", 15 | "com.unity.xr.openxr": "1.2.8", 16 | "com.unity.modules.ai": "1.0.0", 17 | "com.unity.modules.androidjni": "1.0.0", 18 | "com.unity.modules.animation": "1.0.0", 19 | "com.unity.modules.assetbundle": "1.0.0", 20 | "com.unity.modules.audio": "1.0.0", 21 | "com.unity.modules.cloth": "1.0.0", 22 | "com.unity.modules.director": "1.0.0", 23 | "com.unity.modules.imageconversion": "1.0.0", 24 | "com.unity.modules.imgui": "1.0.0", 25 | "com.unity.modules.jsonserialize": "1.0.0", 26 | "com.unity.modules.particlesystem": "1.0.0", 27 | "com.unity.modules.physics": "1.0.0", 28 | "com.unity.modules.physics2d": "1.0.0", 29 | "com.unity.modules.screencapture": "1.0.0", 30 | "com.unity.modules.terrain": "1.0.0", 31 | "com.unity.modules.terrainphysics": "1.0.0", 32 | "com.unity.modules.tilemap": "1.0.0", 33 | "com.unity.modules.ui": "1.0.0", 34 | "com.unity.modules.uielements": "1.0.0", 35 | "com.unity.modules.umbra": "1.0.0", 36 | "com.unity.modules.unityanalytics": "1.0.0", 37 | "com.unity.modules.unitywebrequest": "1.0.0", 38 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 39 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 40 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 41 | "com.unity.modules.unitywebrequestwww": "1.0.0", 42 | "com.unity.modules.vehicles": "1.0.0", 43 | "com.unity.modules.video": "1.0.0", 44 | "com.unity.modules.vr": "1.0.0", 45 | "com.unity.modules.wind": "1.0.0", 46 | "com.unity.modules.xr": "1.0.0" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 0 20 | -------------------------------------------------------------------------------- /ProjectSettings/BurstAotSettings_StandaloneWindows.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "Version": 3, 4 | "EnableBurstCompilation": true, 5 | "EnableOptimisations": true, 6 | "EnableSafetyChecks": false, 7 | "EnableDebugInAllBuilds": false, 8 | "UsePlatformSDKLinker": false, 9 | "CpuMinTargetX32": 0, 10 | "CpuMaxTargetX32": 0, 11 | "CpuMinTargetX64": 0, 12 | "CpuMaxTargetX64": 0, 13 | "CpuTargetsX32": 6, 14 | "CpuTargetsX64": 72 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/CommonBurstAotSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "Version": 3, 4 | "DisabledWarnings": "" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0.1 18 | m_ClothInterCollisionStiffness: 0.2 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ClothGravity: {x: 0, y: -9.81, z: 0} 26 | m_ContactPairsMode: 0 27 | m_BroadphaseType: 0 28 | m_WorldBounds: 29 | m_Center: {x: 0, y: 0, z: 0} 30 | m_Extent: {x: 250, y: 250, z: 250} 31 | m_WorldSubdivisions: 8 32 | m_FrictionType: 0 33 | m_EnableEnhancedDeterminism: 0 34 | m_EnableUnifiedHeightmaps: 1 35 | m_SolverType: 0 36 | m_DefaultMaxAngularSpeed: 7 37 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Scenes/Raymarching.unity 10 | guid: d5858d2e241c0da40b2756fdf74a92ad 11 | m_configObjects: 12 | com.unity.xr.management.loader_settings: {fileID: 11400000, guid: dea6c7fe565b16a448e879494869ded6, type: 2} 13 | com.unity.xr.openxr.settings4: {fileID: 11400000, guid: 15ad7b8000ff1d84eaa6e28e5a5d61b2, type: 2} 14 | xr.sdk.mock-hmd.settings: {fileID: 11400000, guid: 1df3ee01f1ec5fd4184aed905c0f95c6, type: 2} 15 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_AssetPipelineMode: 1 6 | m_ObjectHideFlags: 0 7 | serializedVersion: 10 8 | m_ExternalVersionControlSupport: Visible Meta Files 9 | m_SerializationMode: 2 10 | m_LineEndingsForNewScripts: 0 11 | m_DefaultBehaviorMode: 0 12 | m_PrefabRegularEnvironment: {fileID: 0} 13 | m_PrefabUIEnvironment: {fileID: 0} 14 | m_SpritePackerMode: 0 15 | m_SpritePackerPaddingPower: 1 16 | m_EtcTextureCompressorBehavior: 1 17 | m_EtcTextureFastCompressor: 1 18 | m_EtcTextureNormalCompressor: 2 19 | m_EtcTextureBestCompressor: 4 20 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;asmref;rsp 21 | m_ProjectGenerationRootNamespace: 22 | m_CollabEditorSettings: 23 | inProgressEnabled: 1 24 | m_EnableTextureStreamingInEditMode: 1 25 | m_EnableTextureStreamingInPlayMode: 1 26 | m_AsyncShaderCompilation: 1 27 | m_EnterPlayModeOptionsEnabled: 0 28 | m_EnterPlayModeOptions: 3 29 | m_ShowLightmapResolutionOverlay: 1 30 | m_UseLegacyProbeSampleCount: 0 31 | m_SerializeInlineMappingsOnOneLine: 1 32 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 14 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_VideoShadersIncludeMode: 2 32 | m_AlwaysIncludedShaders: 33 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 39 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 40 | - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} 41 | - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} 42 | - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} 43 | m_PreloadedShaders: [] 44 | m_PreloadShadersBatchTimeLimit: -1 45 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} 46 | m_CustomRenderPipeline: {fileID: 11400000, guid: 19ba41d7c0026c3459d37c2fe90c55a0, type: 2} 47 | m_TransparencySortMode: 0 48 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 49 | m_DefaultRenderingPath: 1 50 | m_DefaultMobileRenderingPath: 1 51 | m_TierSettings: [] 52 | m_LightmapStripping: 0 53 | m_FogStripping: 0 54 | m_InstancingStripping: 0 55 | m_LightmapKeepPlain: 1 56 | m_LightmapKeepDirCombined: 1 57 | m_LightmapKeepDynamicPlain: 1 58 | m_LightmapKeepDynamicDirCombined: 1 59 | m_LightmapKeepShadowMask: 1 60 | m_LightmapKeepSubtractive: 1 61 | m_FogKeepLinear: 1 62 | m_FogKeepExp: 1 63 | m_FogKeepExp2: 1 64 | m_AlbedoSwatchInfos: [] 65 | m_LightsUseLinearIntensity: 1 66 | m_LightsUseColorTemperature: 1 67 | m_DefaultRenderingLayerMask: 1 68 | m_LogWhenShaderIsCompiled: 0 69 | m_SRPDefaultSettings: 70 | UnityEngine.Rendering.Universal.UniversalRenderPipeline: {fileID: 11400000, guid: 38b35347542e5af4c9b140950c5b18db, type: 2} 71 | -------------------------------------------------------------------------------- /ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreReleasePackages: 0 16 | m_EnablePackageDependencies: 1 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | m_SeeAllPackageVersions: 0 20 | oneTimeWarningShown: 0 21 | m_Registries: 22 | - m_Id: main 23 | m_Name: 24 | m_Url: https://packages.unity.com 25 | m_Scopes: [] 26 | m_IsDefault: 1 27 | m_Capabilities: 7 28 | m_UserSelectedRegistryName: 29 | m_UserAddingNewScopedRegistry: 0 30 | m_RegistryInfoDraft: 31 | m_Modified: 0 32 | m_ErrorMessage: 33 | m_UserModificationsInstanceId: -822 34 | m_OriginalInstanceId: -824 35 | m_LoadAssets: 0 36 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: 7 | - type: 8 | m_NativeTypeID: 108 9 | m_ManagedTypePPtr: {fileID: 0} 10 | m_ManagedTypeFallback: 11 | defaultPresets: 12 | - m_Preset: {fileID: 2655988077585873504, guid: 463065d4f17d1d94d848aa127b94dd43, 13 | type: 2} 14 | - type: 15 | m_NativeTypeID: 1020 16 | m_ManagedTypePPtr: {fileID: 0} 17 | m_ManagedTypeFallback: 18 | defaultPresets: 19 | - m_Preset: {fileID: 2655988077585873504, guid: e7689051185d12f4298e1ebb2693a29f, 20 | type: 2} 21 | - type: 22 | m_NativeTypeID: 1006 23 | m_ManagedTypePPtr: {fileID: 0} 24 | m_ManagedTypeFallback: 25 | defaultPresets: 26 | - m_Preset: {fileID: 2655988077585873504, guid: e8537455c6c08bd4e8bf0be3707da685, 27 | type: 2} 28 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2021.2.3f1 2 | m_EditorVersionWithRevision: 2021.2.3f1 (32358a8527b4) 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 2 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 20 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | skinWeights: 4 22 | textureQuality: 0 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.4 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 16 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | customRenderPipeline: {fileID: 11400000, guid: a31e9f9f9c9d4b9429ed0d1234e22103, type: 2} 44 | excludedTargetPlatforms: [] 45 | - serializedVersion: 2 46 | name: Medium 47 | pixelLightCount: 1 48 | shadows: 1 49 | shadowResolution: 0 50 | shadowProjection: 1 51 | shadowCascades: 1 52 | shadowDistance: 20 53 | shadowNearPlaneOffset: 3 54 | shadowCascade2Split: 0.33333334 55 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 56 | shadowmaskMode: 0 57 | skinWeights: 4 58 | textureQuality: 0 59 | anisotropicTextures: 1 60 | antiAliasing: 0 61 | softParticles: 0 62 | softVegetation: 0 63 | realtimeReflectionProbes: 0 64 | billboardsFaceCameraPosition: 0 65 | vSyncCount: 1 66 | lodBias: 0.7 67 | maximumLODLevel: 0 68 | streamingMipmapsActive: 0 69 | streamingMipmapsAddAllCameras: 1 70 | streamingMipmapsMemoryBudget: 512 71 | streamingMipmapsRenderersPerFrame: 512 72 | streamingMipmapsMaxLevelReduction: 2 73 | streamingMipmapsMaxFileIORequests: 1024 74 | particleRaycastBudget: 64 75 | asyncUploadTimeSlice: 2 76 | asyncUploadBufferSize: 16 77 | asyncUploadPersistentBuffer: 1 78 | resolutionScalingFixedDPIFactor: 1 79 | customRenderPipeline: {fileID: 11400000, guid: d847b876476d3d6468f5dfcd34266f96, type: 2} 80 | excludedTargetPlatforms: [] 81 | - serializedVersion: 2 82 | name: High 83 | pixelLightCount: 2 84 | shadows: 2 85 | shadowResolution: 1 86 | shadowProjection: 1 87 | shadowCascades: 2 88 | shadowDistance: 40 89 | shadowNearPlaneOffset: 3 90 | shadowCascade2Split: 0.33333334 91 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 92 | shadowmaskMode: 1 93 | skinWeights: 255 94 | textureQuality: 0 95 | anisotropicTextures: 1 96 | antiAliasing: 2 97 | softParticles: 0 98 | softVegetation: 1 99 | realtimeReflectionProbes: 1 100 | billboardsFaceCameraPosition: 1 101 | vSyncCount: 1 102 | lodBias: 1 103 | maximumLODLevel: 0 104 | streamingMipmapsActive: 0 105 | streamingMipmapsAddAllCameras: 1 106 | streamingMipmapsMemoryBudget: 512 107 | streamingMipmapsRenderersPerFrame: 512 108 | streamingMipmapsMaxLevelReduction: 2 109 | streamingMipmapsMaxFileIORequests: 1024 110 | particleRaycastBudget: 256 111 | asyncUploadTimeSlice: 2 112 | asyncUploadBufferSize: 16 113 | asyncUploadPersistentBuffer: 1 114 | resolutionScalingFixedDPIFactor: 1 115 | customRenderPipeline: {fileID: 11400000, guid: 19ba41d7c0026c3459d37c2fe90c55a0, type: 2} 116 | excludedTargetPlatforms: [] 117 | m_PerPlatformDefaultQuality: 118 | Android: 1 119 | Lumin: 2 120 | Nintendo Switch: 2 121 | PS4: 2 122 | Stadia: 2 123 | Standalone: 2 124 | WebGL: 1 125 | Windows Store Apps: 2 126 | XboxOne: 2 127 | iPhone: 1 128 | tvOS: 1 129 | -------------------------------------------------------------------------------- /ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "ignore": false, 8 | "defaultInstantiationMode": 0, 9 | "supportsModification": true 10 | }, 11 | { 12 | "userAdded": false, 13 | "type": "UnityEditor.Animations.AnimatorController", 14 | "ignore": false, 15 | "defaultInstantiationMode": 0, 16 | "supportsModification": true 17 | }, 18 | { 19 | "userAdded": false, 20 | "type": "UnityEngine.AnimatorOverrideController", 21 | "ignore": false, 22 | "defaultInstantiationMode": 0, 23 | "supportsModification": true 24 | }, 25 | { 26 | "userAdded": false, 27 | "type": "UnityEditor.Audio.AudioMixerController", 28 | "ignore": false, 29 | "defaultInstantiationMode": 0, 30 | "supportsModification": true 31 | }, 32 | { 33 | "userAdded": false, 34 | "type": "UnityEngine.ComputeShader", 35 | "ignore": true, 36 | "defaultInstantiationMode": 1, 37 | "supportsModification": true 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEngine.Cubemap", 42 | "ignore": false, 43 | "defaultInstantiationMode": 0, 44 | "supportsModification": true 45 | }, 46 | { 47 | "userAdded": false, 48 | "type": "UnityEngine.GameObject", 49 | "ignore": false, 50 | "defaultInstantiationMode": 0, 51 | "supportsModification": true 52 | }, 53 | { 54 | "userAdded": false, 55 | "type": "UnityEditor.LightingDataAsset", 56 | "ignore": false, 57 | "defaultInstantiationMode": 0, 58 | "supportsModification": false 59 | }, 60 | { 61 | "userAdded": false, 62 | "type": "UnityEngine.LightingSettings", 63 | "ignore": false, 64 | "defaultInstantiationMode": 0, 65 | "supportsModification": true 66 | }, 67 | { 68 | "userAdded": false, 69 | "type": "UnityEngine.Material", 70 | "ignore": false, 71 | "defaultInstantiationMode": 0, 72 | "supportsModification": true 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEditor.MonoScript", 77 | "ignore": true, 78 | "defaultInstantiationMode": 1, 79 | "supportsModification": true 80 | }, 81 | { 82 | "userAdded": false, 83 | "type": "UnityEngine.PhysicMaterial", 84 | "ignore": false, 85 | "defaultInstantiationMode": 0, 86 | "supportsModification": true 87 | }, 88 | { 89 | "userAdded": false, 90 | "type": "UnityEngine.PhysicsMaterial2D", 91 | "ignore": false, 92 | "defaultInstantiationMode": 0, 93 | "supportsModification": true 94 | }, 95 | { 96 | "userAdded": false, 97 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 98 | "ignore": false, 99 | "defaultInstantiationMode": 0, 100 | "supportsModification": true 101 | }, 102 | { 103 | "userAdded": false, 104 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 105 | "ignore": false, 106 | "defaultInstantiationMode": 0, 107 | "supportsModification": true 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Rendering.VolumeProfile", 112 | "ignore": false, 113 | "defaultInstantiationMode": 0, 114 | "supportsModification": true 115 | }, 116 | { 117 | "userAdded": false, 118 | "type": "UnityEditor.SceneAsset", 119 | "ignore": false, 120 | "defaultInstantiationMode": 0, 121 | "supportsModification": false 122 | }, 123 | { 124 | "userAdded": false, 125 | "type": "UnityEngine.Shader", 126 | "ignore": true, 127 | "defaultInstantiationMode": 1, 128 | "supportsModification": true 129 | }, 130 | { 131 | "userAdded": false, 132 | "type": "UnityEngine.ShaderVariantCollection", 133 | "ignore": true, 134 | "defaultInstantiationMode": 1, 135 | "supportsModification": true 136 | }, 137 | { 138 | "userAdded": false, 139 | "type": "UnityEngine.Texture", 140 | "ignore": false, 141 | "defaultInstantiationMode": 0, 142 | "supportsModification": true 143 | }, 144 | { 145 | "userAdded": false, 146 | "type": "UnityEngine.Texture2D", 147 | "ignore": false, 148 | "defaultInstantiationMode": 0, 149 | "supportsModification": true 150 | }, 151 | { 152 | "userAdded": false, 153 | "type": "UnityEngine.Timeline.TimelineAsset", 154 | "ignore": false, 155 | "defaultInstantiationMode": 0, 156 | "supportsModification": true 157 | } 158 | ], 159 | "defaultDependencyTypeInfo": { 160 | "userAdded": false, 161 | "type": "", 162 | "ignore": false, 163 | "defaultInstantiationMode": 1, 164 | "supportsModification": true 165 | }, 166 | "newSceneOverride": 0 167 | } -------------------------------------------------------------------------------- /ProjectSettings/ShaderGraphSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: de02f9e1d18f588468e474319d09a723, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | customInterpolatorErrorThreshold: 32 16 | customInterpolatorWarningThreshold: 16 17 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/TimelineSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | assetDefaultFramerate: 60 16 | m_DefaultFrameRate: 60 17 | -------------------------------------------------------------------------------- /ProjectSettings/URPProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 247994e1f5a72c2419c26a37e9334c01, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_LastMaterialVersion: 5 16 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | UnityAdsSettings: 27 | m_Enabled: 0 28 | m_InitializeOnStartup: 1 29 | m_TestMode: 0 30 | m_IosGameId: 31 | m_AndroidGameId: 32 | m_GameIds: {} 33 | m_GameId: 34 | PerformanceReportingSettings: 35 | m_Enabled: 0 36 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_RenderPipeSettingsPath: 10 | m_FixedTimeStep: 0.016666668 11 | m_MaxDeltaTime: 0.05 12 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRPackageSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_Settings": [ 3 | "RemoveLegacyInputHelpersForReload" 4 | ] 5 | } -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /ProjectSettings/boot.config: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WSWhitehouse/Unity-Raymarching/0518eaf9969eed62eed5d32dee60ba74599398ab/ProjectSettings/boot.config -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity Raymarching 2 | ## Software 3 | 4 | This project was developed using the following software: 5 | - Unity 2020.3 6 | 7 | ## Sources & Useful Resources 8 | 9 | Here is a list of sources I used when developing this project: 10 | 11 | - [Inigo Quilez:](https://www.youtube.com/c/InigoQuilez) 12 | - https://iquilezles.org/www/articles/distfunctions/distfunctions.htm 13 | - https://www.shadertoy.com/user/iq 14 | 15 | - Other GitHub Projects: 16 | - https://github.com/SebLague/Ray-Marching 17 | - https://github.com/IRCSS/UnityRaymarching/tree/master/Assets 18 | - https://github.com/electricsquare/raymarching-workshop 19 | - https://github.com/hecomi/uRaymarchingExamples 20 | 21 | - [The Art of Code:](https://www.youtube.com/c/TheArtofCodeIsCool/featured) 22 | - https://www.shadertoy.com/user/BigWIngs 23 | - [Writing a Ray Marcher in Unity - YouTube](https://www.youtube.com/watch?v=S8AWd66hoCo) 24 | - [RayMarching: Basic Operators - YouTube](https://www.youtube.com/watch?v=AfKGMUDWfuE) 25 | - [Shader Coding: Ray Marching Tips & Tricks - YouTube](https://www.youtube.com/watch?feature=youtu.be&v=Vmb7VGBVZJA) 26 | 27 | - Other Sources: 28 | - [Coding Adventure: Ray Marching - YouTube](https://www.youtube.com/watch?v=Cp5WWtMoeKg&feature=youtu.be) 29 | - [Making of Fractal Collector: A Unity Fractal Game - YouTube](https://www.youtube.com/watch?v=0jwkZKDOzfc) 30 | - https://medium.com/@shahriyarshahrabi/raymarching-in-unity-59c72664252a 31 | - http://i-saint.hatenablog.com/entry/2015/08/24/225254 32 | - http://blog.hvidtfeldts.net/index.php/2011/06/distance-estimated-3d-fractals-part-i/ 33 | - https://www.alanzucconi.com/2016/07/01/raymarching/ 34 | - https://www.alanzucconi.com/2016/07/01/signed-distance-functions/ 35 | 36 | - Unrelated, But Worth Reading: 37 | - https://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToMatrix/index.htm 38 | - https://gist.github.com/mattatz/86fff4b32d198d0928d0fa4ff32cf6fa 39 | - https://catlikecoding.com/unity/tutorials/rendering/part-1/ 40 | - https://ntrs.nasa.gov/citations/19770019231 41 | - https://catlikecoding.com/unity/tutorials/rendering/ 42 | - http://www.shaderslab.com/shaders.html 43 | 44 | - 4D Rendering - This is something I want to develop into the RayMarching project, but currently I dont have the time to do so. 45 | - https://marctenbosch.com/ndphysics/ 46 | - https://4dtoys.com/ 47 | - [Making a 4D Game - 4D Explorer - YouTube](https://www.youtube.com/watch?v=nUExziADzjc) 48 | - https://github.com/Jellevermandere/4D-Raymarching 49 | 50 | ## License 51 | 52 | This project is under the MIT License. Read the [LICENSE.md](./LICENSE.md) file for more information. 53 | -------------------------------------------------------------------------------- /UserSettings/EditorUserSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!162 &1 4 | EditorUserSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_ConfigSettings: 8 | RecentlyUsedSceneGuid-0: 9 | value: 0700575554055059090c597611270a44154f19782e7a7e63757c4f6be7b66068 10 | flags: 0 11 | RecentlyUsedSceneGuid-1: 12 | value: 51550103520c500a5c0c5f2641210e44464e1b287c70743274794c62b0e1603b 13 | flags: 0 14 | RecentlyUsedSceneGuid-2: 15 | value: 5009075e5401505f550a5b7614740c44144f412f2d7927647e711c63b2b76d39 16 | flags: 0 17 | RecentlyUsedSceneGuid-3: 18 | value: 07040c535d515b5e5f5a5d2140275e4446154a7d797e20342b7e4932bbb2353c 19 | flags: 0 20 | UnityEditor.ShaderGraph.Blackboard: 21 | value: 18135939215a0a5004000b0e15254b524c030a3f2964643d120d1230e9e93a3fd6e826abbd2e2d293c4ead313b08042de6030a0afa240c0d020be94c4ba75e435d8715fa32c70d15d11612dacc11fee5d3c5d1fe9ab1bf968e93e2ffcbc3e7e2f0b3ffe0e8b0be9af8ffaeffff8e85dd8390e3949c8899daa7 22 | flags: 0 23 | UnityEditor.ShaderGraph.FloatingWindowsLayout2: 24 | value: 181344140043005e1a220d3b1f364b524c0c5a27130c293326201334cee5322ca0bd30e8eb293a707b0fd0180b3d0a36fc0d3d04e649500d1002ee0b5dbd1d2c27c00ad113cb1e10e41f1addc80993b9859884a69ae6d8f0d1cda9e8fbfefaf9f9dea3fdb9ade882f0ffb0e1e380cafbf2c3adc18e9cd285a2908b82ec869c8395949c9483d68a8e97ddbd90bf 25 | flags: 0 26 | UnityEditor.ShaderGraph.InspectorWindow: 27 | value: 18135939215a0a5004000b0e15254b524c1119263f2d6a722016393ce1eb3d36e5d339f9a5602b2e2c07a37e0901373ae01e0008f707250d171df81a53a5485d41895ac825e0100ec20313c0d91cddccd3d0c7efcca9bd80908fecb0f9cfddf1eff4e7a1b1eae482f0fcaee1e1928b86d888ed969b938797a7cf 28 | flags: 0 29 | vcSharedLogLevel: 30 | value: 0d5e400f0650 31 | flags: 0 32 | m_VCAutomaticAdd: 1 33 | m_VCDebugCom: 0 34 | m_VCDebugCmd: 0 35 | m_VCDebugOut: 0 36 | m_SemanticMergeMode: 2 37 | m_DesiredImportWorkerCount: 1 38 | m_StandbyImportWorkerCount: 1 39 | m_IdleImportWorkerShutdownDelay: 60000 40 | m_VCShowFailedCheckout: 1 41 | m_VCOverwriteFailedCheckoutAssets: 1 42 | m_VCProjectOverlayIcons: 1 43 | m_VCHierarchyOverlayIcons: 1 44 | m_VCOtherOverlayIcons: 1 45 | m_VCAllowAsyncUpdate: 1 46 | m_ArtifactGarbageCollection: 1 47 | -------------------------------------------------------------------------------- /UserSettings/Search.settings: -------------------------------------------------------------------------------- 1 | {} --------------------------------------------------------------------------------