├── .gitignore ├── Assets ├── UnityRayMarchingFramework.meta └── UnityRayMarchingFramework │ ├── Materials.meta │ ├── Materials │ ├── FishManShaderTutorial_2DCloudSea.mat │ ├── FishManShaderTutorial_2DCloudSea.mat.meta │ ├── FishManShaderTutorial_BaseMath.mat │ ├── FishManShaderTutorial_BaseMath.mat.meta │ ├── FishManShaderTutorial_Fog.mat │ ├── FishManShaderTutorial_Fog.mat.meta │ ├── FishManShaderTutorial_GameHPUI.mat │ ├── FishManShaderTutorial_GameHPUI.mat.meta │ ├── FishManShaderTutorial_HighlandLake.mat │ ├── FishManShaderTutorial_HighlandLake.mat.meta │ ├── FishManShaderTutorial_RaymarchMergeExample.mat │ ├── FishManShaderTutorial_RaymarchMergeExample.mat.meta │ ├── FishManShaderTutorial_RaymarchMergeRaster.mat │ ├── FishManShaderTutorial_RaymarchMergeRaster.mat.meta │ ├── FishManShaderTutorial_SDF.mat │ ├── FishManShaderTutorial_SDF.mat.meta │ ├── FishManShaderTutorial_SDFBounceBall.mat │ ├── FishManShaderTutorial_SDFBounceBall.mat.meta │ ├── FishManShaderTutorial_Sky.mat │ ├── FishManShaderTutorial_Sky.mat.meta │ ├── FishManShaderTutorial_Stars.mat │ └── FishManShaderTutorial_Stars.mat.meta │ ├── Models.meta │ ├── Models │ ├── Long.controller │ ├── Long.controller.meta │ ├── Long.mat │ ├── Long.mat.meta │ ├── long@FBX.fbx │ ├── long@FBX.fbx.meta │ ├── zuoqi_2NRM.png │ ├── zuoqi_2NRM.png.meta │ ├── zuoqi_2_3.png │ └── zuoqi_2_3.png.meta │ ├── Prefabs.meta │ ├── Prefabs │ ├── Long.prefab │ └── Long.prefab.meta │ ├── Scene.meta │ ├── Scene │ ├── 2DCloudSea.unity │ ├── 2DCloudSea.unity.meta │ ├── BaseMath.unity │ ├── BaseMath.unity.meta │ ├── Fog.unity │ ├── Fog.unity.meta │ ├── GameHPUI.unity │ ├── GameHPUI.unity.meta │ ├── HighlandLake.unity │ ├── HighlandLake.unity.meta │ ├── RaymarchMergeExample.unity │ ├── RaymarchMergeExample.unity.meta │ ├── RaymarchMergeRaster.unity │ ├── RaymarchMergeRaster.unity.meta │ ├── SDF BounceBall.unity │ ├── SDF BounceBall.unity.meta │ ├── SDF.unity │ ├── SDF.unity.meta │ ├── Sky.unity │ ├── Sky.unity.meta │ ├── Stars.unity │ └── Stars.unity.meta │ ├── Scripts.meta │ ├── Scripts │ ├── CameraControler.cs │ ├── CameraControler.cs.meta │ ├── MergeRayMarch.cs │ ├── MergeRayMarch.cs.meta │ ├── ThirdPersonUserControl.cs │ └── ThirdPersonUserControl.cs.meta │ ├── Shaders.meta │ ├── Shaders │ ├── 2DCloudSea.shader │ ├── 2DCloudSea.shader.meta │ ├── BaseMath.shader │ ├── BaseMath.shader.meta │ ├── Fog.shader │ ├── Fog.shader.meta │ ├── GameHPUI.shader │ ├── GameHPUI.shader.meta │ ├── HighlandLake.shader │ ├── HighlandLake.shader.meta │ ├── Mountain.shader │ ├── Mountain.shader.meta │ ├── RaymarchExample.shader │ ├── RaymarchExample.shader.meta │ ├── RaymarchMergeRaster.shader │ ├── RaymarchMergeRaster.shader.meta │ ├── SDF.shader │ ├── SDF.shader.meta │ ├── SDFBounceBall.shader │ ├── SDFBounceBall.shader.meta │ ├── SDFBouncedBall.shader │ ├── SDFBouncedBall.shader.meta │ ├── Sea.shader │ ├── Sea.shader.meta │ ├── ShaderLibs.meta │ ├── ShaderLibs │ │ ├── Common.cginc │ │ ├── Common.cginc.meta │ │ ├── FBM.cginc │ │ ├── FBM.cginc.meta │ │ ├── Feature.cginc │ │ ├── Feature.cginc.meta │ │ ├── Framework2D.cginc │ │ ├── Framework2D.cginc.meta │ │ ├── Framework3D.cginc │ │ ├── Framework3D.cginc.meta │ │ ├── Framework3D_DefaultRender.cginc │ │ ├── Framework3D_DefaultRender.cginc.meta │ │ ├── Framework3D_Terrain.cginc │ │ ├── Framework3D_Terrain.cginc.meta │ │ ├── Hash.cginc │ │ ├── Hash.cginc.meta │ │ ├── Math.cginc │ │ ├── Math.cginc.meta │ │ ├── Noise.cginc │ │ ├── Noise.cginc.meta │ │ ├── SDF.cginc │ │ └── SDF.cginc.meta │ ├── Sky.shader │ ├── Sky.shader.meta │ ├── Stars.shader │ └── Stars.shader.meta │ ├── Textures.meta │ └── Textures │ ├── NoiseTex.png │ └── NoiseTex.png.meta ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityConnectSettings.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Visual Studio 2015 cache directory 9 | /.vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | 26 | # Unity3D generated meta files 27 | *.pidb.meta 28 | 29 | # Unity3D Generated File On Crash Reports 30 | sysinfo.txt 31 | 32 | # Builds 33 | *.apk 34 | *.unitypackage 35 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1ad08095cd15ba4dbebd3d4ad348b84 3 | folderAsset: yes 4 | timeCreated: 1520328502 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acafbb7fb1623294dacad49b4deaa817 3 | folderAsset: yes 4 | timeCreated: 1523757495 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_2DCloudSea.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_2DCloudSea.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_2DCloudSea.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e124c2711cb7974ab67689e81528285 3 | timeCreated: 1523791726 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_BaseMath.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_BaseMath.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_BaseMath.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e5fb7bcc1e369b4bb86bd91cbfc7b42 3 | timeCreated: 1524382577 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_Fog.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_Fog.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_Fog.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 03e67eca059155e44bdc3454d348b553 3 | timeCreated: 1524460725 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: -1 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_GameHPUI.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_GameHPUI.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_GameHPUI.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51eae5f9cbb25554bb80a19dca72c4fd 3 | timeCreated: 1523880574 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_HighlandLake.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_HighlandLake.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_HighlandLake.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c5f5f84547aa7f4e8b5833d18e0ed5d 3 | timeCreated: 1524041574 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_RaymarchMergeExample.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_RaymarchMergeExample.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_RaymarchMergeExample.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c08d65cb66aa6b4b8de10008b8492ef 3 | timeCreated: 1524469464 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_RaymarchMergeRaster.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_RaymarchMergeRaster.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_RaymarchMergeRaster.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 333eac15f8cf3e748bdff12621887455 3 | timeCreated: 1524363990 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_SDF.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_SDF.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_SDF.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c0abc4142e65f34bbf7a61eb2b7c54d 3 | timeCreated: 1524659452 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_SDFBounceBall.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_SDFBounceBall.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_SDFBounceBall.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33b29d32142ee2c4abfec3068e138559 3 | timeCreated: 1524666768 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_Sky.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_Sky.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_Sky.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aac117acda553574cb5e49fef634b2fd 3 | timeCreated: 1523956992 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_Stars.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_Stars.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Materials/FishManShaderTutorial_Stars.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a94f7c973bc9e6f4989414181ccbd52d 3 | timeCreated: 1523969107 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d60ff863bd94f1143beaf5450ae9edf5 3 | folderAsset: yes 4 | timeCreated: 1523760628 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models/Long.controller: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Models/Long.controller -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models/Long.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91f231428b36cc24496cf453e6d35214 3 | timeCreated: 1523762313 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 9100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models/Long.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Models/Long.mat -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models/Long.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b4cfd31454ab284f936ee652a104e5a 3 | timeCreated: 1523761054 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models/long@FBX.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Models/long@FBX.fbx -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models/long@FBX.fbx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b177e30357cf154a8de7783e5bec538 3 | ModelImporter: 4 | serializedVersion: 19 5 | fileIDToRecycleName: 6 | 100000: dragon_bone_41 7 | 100002: dragon_bone_30 8 | 100004: dragon_bone_27 9 | 100006: dragon_bone_94 10 | 100008: //RootNode 11 | 100010: dragon_bone_69 12 | 100012: dragon_bone_108 13 | 100014: dragon_bone_90 14 | 100016: dragon_bone_65 15 | 100018: dragon_bone_47 16 | 100020: dragon_bone_34 17 | 100022: dragon_bone_26 18 | 100024: dragon_bone_88 19 | 100026: dragon_bone_62 20 | 100028: dragon_bone_104 21 | 100030: dragon_bone_84 22 | 100032: dragon_bone_58 23 | 100034: dragon_bone_46 24 | 100036: dragon_bone_33 25 | 100038: dragon_bone_25 26 | 100040: dragon_bone_57 27 | 100042: dragon_bone_45 28 | 100044: dragon_bone_32 29 | 100046: dragon_bone_56 30 | 100048: dragon_bone_44 31 | 100050: dragon_bone_31 32 | 100052: dragon_bone_24 33 | 100054: dragon_bone_21 34 | 100056: dragon_bone_15 35 | 100058: zuo 36 | 100060: dragon_bone_29 37 | 100062: dragon_bone_23 38 | 100064: dragon_bone_20 39 | 100066: dragon_bone_14 40 | 100068: dragon_bone_12 41 | 100070: dragon_bone_9 42 | 100072: dragon_bone_6 43 | 100074: dragon_bone_3 44 | 100076: dragon_bone_28 45 | 100078: dragon_bone_22 46 | 100080: dragon_bone_19 47 | 100082: dragon_bone_4 48 | 100084: group1 49 | 100086: dragon_bone_Head 50 | 100088: joint3 51 | 100090: joint1 52 | 100092: dragon_bone_Jaw 53 | 100094: zuoqi_2 54 | 100096: joint2 55 | 400000: dragon_bone_41 56 | 400002: dragon_bone_30 57 | 400004: dragon_bone_27 58 | 400006: dragon_bone_94 59 | 400008: //RootNode 60 | 400010: dragon_bone_69 61 | 400012: dragon_bone_108 62 | 400014: dragon_bone_90 63 | 400016: dragon_bone_65 64 | 400018: dragon_bone_47 65 | 400020: dragon_bone_34 66 | 400022: dragon_bone_26 67 | 400024: dragon_bone_88 68 | 400026: dragon_bone_62 69 | 400028: dragon_bone_104 70 | 400030: dragon_bone_84 71 | 400032: dragon_bone_58 72 | 400034: dragon_bone_46 73 | 400036: dragon_bone_33 74 | 400038: dragon_bone_25 75 | 400040: dragon_bone_57 76 | 400042: dragon_bone_45 77 | 400044: dragon_bone_32 78 | 400046: dragon_bone_56 79 | 400048: dragon_bone_44 80 | 400050: dragon_bone_31 81 | 400052: dragon_bone_24 82 | 400054: dragon_bone_21 83 | 400056: dragon_bone_15 84 | 400058: zuo 85 | 400060: dragon_bone_29 86 | 400062: dragon_bone_23 87 | 400064: dragon_bone_20 88 | 400066: dragon_bone_14 89 | 400068: dragon_bone_12 90 | 400070: dragon_bone_9 91 | 400072: dragon_bone_6 92 | 400074: dragon_bone_3 93 | 400076: dragon_bone_28 94 | 400078: dragon_bone_22 95 | 400080: dragon_bone_19 96 | 400082: dragon_bone_4 97 | 400084: group1 98 | 400086: dragon_bone_Head 99 | 400088: joint3 100 | 400090: joint1 101 | 400092: dragon_bone_Jaw 102 | 400094: zuoqi_2 103 | 400096: joint2 104 | 4300000: zuoqi_2 105 | 7400000: Take 001 106 | 7400002: walk 107 | 7400004: run 108 | 7400006: jumpstart 109 | 7400008: jump 110 | 7400010: jumpend 111 | 7400012: idle 112 | 7400014: idle0 113 | 9500000: //RootNode 114 | 11100000: //RootNode 115 | 13700000: joint1 116 | 13700002: zuoqi_2 117 | materials: 118 | importMaterials: 0 119 | materialName: 0 120 | materialSearch: 1 121 | animations: 122 | legacyGenerateAnimations: 3 123 | bakeSimulation: 0 124 | resampleCurves: 1 125 | optimizeGameObjects: 0 126 | motionNodeName: 127 | rigImportErrors: 128 | rigImportWarnings: 129 | animationImportErrors: 130 | animationImportWarnings: 131 | animationRetargetingWarnings: 132 | animationDoRetargetingWarnings: 0 133 | animationCompression: 1 134 | animationRotationError: 0.5 135 | animationPositionError: 0.5 136 | animationScaleError: 0.5 137 | animationWrapMode: 0 138 | extraExposedTransformPaths: [] 139 | clipAnimations: 140 | - serializedVersion: 16 141 | name: walk 142 | takeName: 143 | firstFrame: 536 144 | lastFrame: 581 145 | wrapMode: 2 146 | orientationOffsetY: 0 147 | level: 0 148 | cycleOffset: 0 149 | loop: 0 150 | hasAdditiveReferencePose: 0 151 | loopTime: 0 152 | loopBlend: 0 153 | loopBlendOrientation: 0 154 | loopBlendPositionY: 0 155 | loopBlendPositionXZ: 0 156 | keepOriginalOrientation: 0 157 | keepOriginalPositionY: 1 158 | keepOriginalPositionXZ: 0 159 | heightFromFeet: 0 160 | mirror: 0 161 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 162 | curves: [] 163 | events: [] 164 | transformMask: [] 165 | maskType: 0 166 | maskSource: {instanceID: 0} 167 | additiveReferencePoseFrame: 0 168 | - serializedVersion: 16 169 | name: run 170 | takeName: 171 | firstFrame: 633 172 | lastFrame: 673 173 | wrapMode: 2 174 | orientationOffsetY: 0 175 | level: 0 176 | cycleOffset: 0 177 | loop: 0 178 | hasAdditiveReferencePose: 0 179 | loopTime: 0 180 | loopBlend: 0 181 | loopBlendOrientation: 0 182 | loopBlendPositionY: 0 183 | loopBlendPositionXZ: 0 184 | keepOriginalOrientation: 0 185 | keepOriginalPositionY: 1 186 | keepOriginalPositionXZ: 0 187 | heightFromFeet: 0 188 | mirror: 0 189 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 190 | curves: [] 191 | events: [] 192 | transformMask: [] 193 | maskType: 0 194 | maskSource: {instanceID: 0} 195 | additiveReferencePoseFrame: 0 196 | - serializedVersion: 16 197 | name: jumpstart 198 | takeName: 199 | firstFrame: 147 200 | lastFrame: 162 201 | wrapMode: 0 202 | orientationOffsetY: 0 203 | level: 0 204 | cycleOffset: 0 205 | loop: 0 206 | hasAdditiveReferencePose: 0 207 | loopTime: 0 208 | loopBlend: 0 209 | loopBlendOrientation: 0 210 | loopBlendPositionY: 0 211 | loopBlendPositionXZ: 0 212 | keepOriginalOrientation: 0 213 | keepOriginalPositionY: 1 214 | keepOriginalPositionXZ: 0 215 | heightFromFeet: 0 216 | mirror: 0 217 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 218 | curves: [] 219 | events: [] 220 | transformMask: [] 221 | maskType: 0 222 | maskSource: {instanceID: 0} 223 | additiveReferencePoseFrame: 0 224 | - serializedVersion: 16 225 | name: jump 226 | takeName: 227 | firstFrame: 584 228 | lastFrame: 629 229 | wrapMode: 0 230 | orientationOffsetY: 0 231 | level: 0 232 | cycleOffset: 0 233 | loop: 0 234 | hasAdditiveReferencePose: 0 235 | loopTime: 0 236 | loopBlend: 0 237 | loopBlendOrientation: 0 238 | loopBlendPositionY: 0 239 | loopBlendPositionXZ: 0 240 | keepOriginalOrientation: 0 241 | keepOriginalPositionY: 1 242 | keepOriginalPositionXZ: 0 243 | heightFromFeet: 0 244 | mirror: 0 245 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 246 | curves: [] 247 | events: [] 248 | transformMask: [] 249 | maskType: 0 250 | maskSource: {instanceID: 0} 251 | additiveReferencePoseFrame: 0 252 | - serializedVersion: 16 253 | name: jumpend 254 | takeName: 255 | firstFrame: 194 256 | lastFrame: 195 257 | wrapMode: 0 258 | orientationOffsetY: 0 259 | level: 0 260 | cycleOffset: 0 261 | loop: 0 262 | hasAdditiveReferencePose: 0 263 | loopTime: 0 264 | loopBlend: 0 265 | loopBlendOrientation: 0 266 | loopBlendPositionY: 0 267 | loopBlendPositionXZ: 0 268 | keepOriginalOrientation: 0 269 | keepOriginalPositionY: 1 270 | keepOriginalPositionXZ: 0 271 | heightFromFeet: 0 272 | mirror: 0 273 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 274 | curves: [] 275 | events: [] 276 | transformMask: [] 277 | maskType: 0 278 | maskSource: {instanceID: 0} 279 | additiveReferencePoseFrame: 0 280 | - serializedVersion: 16 281 | name: idle 282 | takeName: 283 | firstFrame: 242 284 | lastFrame: 402 285 | wrapMode: 2 286 | orientationOffsetY: 0 287 | level: 0 288 | cycleOffset: 0 289 | loop: 0 290 | hasAdditiveReferencePose: 0 291 | loopTime: 0 292 | loopBlend: 0 293 | loopBlendOrientation: 0 294 | loopBlendPositionY: 0 295 | loopBlendPositionXZ: 0 296 | keepOriginalOrientation: 0 297 | keepOriginalPositionY: 1 298 | keepOriginalPositionXZ: 0 299 | heightFromFeet: 0 300 | mirror: 0 301 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 302 | curves: [] 303 | events: [] 304 | transformMask: [] 305 | maskType: 0 306 | maskSource: {instanceID: 0} 307 | additiveReferencePoseFrame: 0 308 | - serializedVersion: 16 309 | name: idle0 310 | takeName: 311 | firstFrame: 405 312 | lastFrame: 485 313 | wrapMode: 2 314 | orientationOffsetY: 0 315 | level: 0 316 | cycleOffset: 0 317 | loop: 0 318 | hasAdditiveReferencePose: 0 319 | loopTime: 0 320 | loopBlend: 0 321 | loopBlendOrientation: 0 322 | loopBlendPositionY: 0 323 | loopBlendPositionXZ: 0 324 | keepOriginalOrientation: 0 325 | keepOriginalPositionY: 1 326 | keepOriginalPositionXZ: 0 327 | heightFromFeet: 0 328 | mirror: 0 329 | bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000 330 | curves: [] 331 | events: [] 332 | transformMask: [] 333 | maskType: 0 334 | maskSource: {instanceID: 0} 335 | additiveReferencePoseFrame: 0 336 | isReadable: 1 337 | meshes: 338 | lODScreenPercentages: [] 339 | globalScale: 0.2 340 | meshCompression: 3 341 | addColliders: 0 342 | importBlendShapes: 1 343 | swapUVChannels: 0 344 | generateSecondaryUV: 0 345 | useFileUnits: 1 346 | optimizeMeshForGPU: 1 347 | keepQuads: 0 348 | weldVertices: 1 349 | secondaryUVAngleDistortion: 8 350 | secondaryUVAreaDistortion: 15.000001 351 | secondaryUVHardAngle: 88 352 | secondaryUVPackMargin: 4 353 | useFileScale: 0 354 | tangentSpace: 355 | normalSmoothAngle: 60 356 | normalImportMode: 0 357 | tangentImportMode: 4 358 | importAnimation: 1 359 | copyAvatar: 0 360 | humanDescription: 361 | serializedVersion: 2 362 | human: [] 363 | skeleton: [] 364 | armTwist: 0.5 365 | foreArmTwist: 0.5 366 | upperLegTwist: 0.5 367 | legTwist: 0.5 368 | armStretch: 0.05 369 | legStretch: 0.05 370 | feetSpacing: 0 371 | rootMotionBoneName: 372 | rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} 373 | hasTranslationDoF: 0 374 | hasExtraRoot: 1 375 | skeletonHasParents: 0 376 | lastHumanDescriptionAvatarSource: {instanceID: 0} 377 | animationType: 1 378 | humanoidOversampling: 1 379 | additionalBone: 0 380 | userData: 381 | assetBundleName: 382 | assetBundleVariant: 383 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models/zuoqi_2NRM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Models/zuoqi_2NRM.png -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models/zuoqi_2NRM.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 134a8b2dc886ec0439abba29466e991f 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 1 7 | enableMipMap: 1 8 | linearTexture: 1 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 1 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | seamlessCubemap: 0 23 | textureFormat: 30 24 | maxTextureSize: 256 25 | textureSettings: 26 | filterMode: -1 27 | aniso: -1 28 | mipBias: -1 29 | wrapMode: -1 30 | nPOTScale: 1 31 | lightmap: 0 32 | compressionQuality: 50 33 | spriteMode: 0 34 | spriteExtrude: 1 35 | spriteMeshType: 1 36 | alignment: 0 37 | spritePivot: {x: .5, y: .5} 38 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 39 | spritePixelsToUnits: 100 40 | alphaIsTransparency: 0 41 | textureType: 5 42 | buildTargetSettings: [] 43 | spriteSheet: 44 | sprites: [] 45 | spritePackingTag: 46 | userData: 47 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models/zuoqi_2_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Models/zuoqi_2_3.png -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Models/zuoqi_2_3.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18c781ed13cb3b14c9843f85d527ce2d 3 | TextureImporter: 4 | serializedVersion: 2 5 | mipmaps: 6 | mipMapMode: 1 7 | enableMipMap: 1 8 | linearTexture: 0 9 | correctGamma: 0 10 | fadeOut: 0 11 | borderMipMap: 0 12 | mipMapFadeDistanceStart: 1 13 | mipMapFadeDistanceEnd: 3 14 | bumpmap: 15 | convertToNormalMap: 0 16 | externalNormalMap: 0 17 | heightScale: .25 18 | normalMapFilter: 0 19 | isReadable: 0 20 | grayScaleToAlpha: 0 21 | generateCubemap: 0 22 | textureFormat: 32 23 | maxTextureSize: 256 24 | textureSettings: 25 | filterMode: -1 26 | aniso: -1 27 | mipBias: -1 28 | wrapMode: -1 29 | nPOTScale: 1 30 | lightmap: 0 31 | compressionQuality: 50 32 | textureType: 5 33 | buildTargetSettings: [] 34 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5145468e56ce1af4d9deb9c8a59f59a0 3 | folderAsset: yes 4 | timeCreated: 1523761502 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Prefabs/Long.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Prefabs/Long.prefab -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Prefabs/Long.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8f8d5f97c7fa68469aa61036d1b1b5d 3 | timeCreated: 1523761421 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 100100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7e026b109728ed46a70c048abe74c57 3 | folderAsset: yes 4 | timeCreated: 1520647240 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/2DCloudSea.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/2DCloudSea.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/2DCloudSea.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc026a34274d1024abf5e0343bfb72a8 3 | timeCreated: 1521287146 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/BaseMath.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/BaseMath.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/BaseMath.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b0ebcd2f2c404548bf12baef43d9e83 3 | timeCreated: 1521287146 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/Fog.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/Fog.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/Fog.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dbbc460b77da09f42acdcb7f012ad47f 3 | timeCreated: 1520648796 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/GameHPUI.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/GameHPUI.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/GameHPUI.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1d504b6c90b99e45a784562a73d0521 3 | timeCreated: 1521287146 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/HighlandLake.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/HighlandLake.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/HighlandLake.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97961746ea16a6c43bad8f2a669a4835 3 | timeCreated: 1523957177 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/RaymarchMergeExample.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/RaymarchMergeExample.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/RaymarchMergeExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45ccf1a02290fe049be9e957cd252245 3 | timeCreated: 1520648796 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/RaymarchMergeRaster.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/RaymarchMergeRaster.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/RaymarchMergeRaster.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dbfefe4a4aecc44dab1b59ef694741d 3 | timeCreated: 1520648796 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/SDF BounceBall.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/SDF BounceBall.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/SDF BounceBall.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a22d1a8aab3e4a44486adb1a96f81b5a 3 | timeCreated: 1523957177 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/SDF.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/SDF.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/SDF.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3222f8dcf4d71e74692ce71516c323b4 3 | timeCreated: 1523957177 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/Sky.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/Sky.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/Sky.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad19a61865b0e1245a6d2b0454f7d52d 3 | timeCreated: 1523957177 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/Stars.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Scene/Stars.unity -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scene/Stars.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0508449572129a142b8e5a17b0a8f882 3 | timeCreated: 1520648796 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5f792ad1e4de6a47b7c841c17350944 3 | folderAsset: yes 4 | timeCreated: 1520669940 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scripts/CameraControler.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | 5 | public class CameraControler : MonoBehaviour { 6 | 7 | public float moveSpd = 10f; 8 | public float rotateSpd = 1f; 9 | //旋转变量; 10 | private float m_deltX = 0f; 11 | private float m_deltY = 0f; 12 | //缩放变量; 13 | private float m_distance = 10f; 14 | private float m_mSpeed = 5f; 15 | //移动变量; 16 | private Vector3 m_mouseMovePos = Vector3.zero; 17 | Camera camera; 18 | void Start() { 19 | camera = GetComponent(); 20 | if (camera == null) { 21 | enabled = false; 22 | return; 23 | } 24 | } 25 | 26 | void Update() { 27 | //鼠标右键点下控制相机旋转; 28 | if (Input.GetMouseButton(1)) { 29 | m_deltX += Input.GetAxis("Mouse X") * m_mSpeed * rotateSpd; 30 | m_deltY -= Input.GetAxis("Mouse Y") * m_mSpeed * rotateSpd; 31 | m_deltX = ClampAngle(m_deltX, -360, 360); 32 | m_deltY = ClampAngle(m_deltY, -70, 70); 33 | camera.transform.rotation = Quaternion.Euler(m_deltY, m_deltX, 0); 34 | } 35 | if (Input.GetMouseButton(2)) { 36 | transform.Translate(Vector3.left * Input.GetAxis("Mouse X")); 37 | transform.Translate(Vector3.down * Input.GetAxis("Mouse Y")); 38 | } 39 | //鼠标中键点下场景缩放; 40 | if (Input.GetAxis("Mouse ScrollWheel") != 0) { 41 | //自由缩放方式; 42 | m_distance = Input.GetAxis("Mouse ScrollWheel") * 10f; 43 | camera.transform.localPosition = camera.transform.position + camera.transform.forward * m_distance * moveSpd; 44 | } 45 | 46 | //相机复位远点; 47 | if (Input.GetKey(KeyCode.Space)) { 48 | m_distance = 10.0f; 49 | camera.transform.localPosition = new Vector3(0, m_distance, 0); 50 | } 51 | } 52 | 53 | //规划角度; 54 | float ClampAngle(float angle, float minAngle, float maxAgnle) { 55 | if (angle <= -360) 56 | angle += 360; 57 | if (angle >= 360) 58 | angle -= 360; 59 | 60 | return Mathf.Clamp(angle, minAngle, maxAgnle); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scripts/CameraControler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5c33bd84c1d0fc4983c913e31842279 3 | timeCreated: 1520658904 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scripts/MergeRayMarch.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [ExecuteInEditMode] 5 | [RequireComponent(typeof(Camera))] 6 | public class MergeRayMarch : MonoBehaviour { 7 | public Material material; 8 | public Texture2D _NoiseTex; 9 | public Vector4 _LoopNum; 10 | 11 | private Camera myCamera; 12 | public new Camera camera { 13 | get { 14 | if (myCamera == null) { 15 | myCamera = GetComponent(); 16 | } 17 | return myCamera; 18 | } 19 | } 20 | 21 | private Transform myCameraTransform; 22 | public Transform cameraTransform { 23 | get { 24 | if (myCameraTransform == null) { 25 | myCameraTransform = camera.transform; 26 | } 27 | 28 | return myCameraTransform; 29 | } 30 | } 31 | 32 | 33 | private void Start() { 34 | if (material == null || material.shader == null || !material.shader.isSupported) { 35 | this.enabled = false; 36 | return; 37 | } 38 | } 39 | void OnEnable() { 40 | camera.depthTextureMode |= DepthTextureMode.Depth; 41 | } 42 | 43 | [ImageEffectOpaque] 44 | void OnRenderImage (RenderTexture src, RenderTexture dest) { 45 | if (material != null) { 46 | SetRay(); 47 | material.SetTexture("_NoiseTex", _NoiseTex); 48 | material.SetVector("_LoopNum", _LoopNum); 49 | Graphics.Blit(src, dest, material); 50 | } else { 51 | Graphics.Blit(src, dest); 52 | } 53 | } 54 | 55 | private void SetRay() { 56 | Matrix4x4 frustumCorners = Matrix4x4.identity; 57 | 58 | float fov = camera.fieldOfView; 59 | float near = camera.nearClipPlane; 60 | float aspect = camera.aspect; 61 | 62 | float halfHeight = near * Mathf.Tan(fov * 0.5f * Mathf.Deg2Rad); 63 | Vector3 toRight = cameraTransform.right * halfHeight * aspect; 64 | Vector3 toTop = cameraTransform.up * halfHeight; 65 | 66 | Vector3 topLeft = cameraTransform.forward * near + toTop - toRight; 67 | float scale = topLeft.magnitude / near; 68 | 69 | topLeft.Normalize(); 70 | topLeft *= scale; 71 | 72 | Vector3 topRight = cameraTransform.forward * near + toRight + toTop; 73 | topRight.Normalize(); 74 | topRight *= scale; 75 | 76 | Vector3 bottomLeft = cameraTransform.forward * near - toTop - toRight; 77 | bottomLeft.Normalize(); 78 | bottomLeft *= scale; 79 | 80 | Vector3 bottomRight = cameraTransform.forward * near + toRight - toTop; 81 | bottomRight.Normalize(); 82 | bottomRight *= scale; 83 | 84 | frustumCorners.SetRow(0, bottomLeft); 85 | frustumCorners.SetRow(1, bottomRight); 86 | frustumCorners.SetRow(2, topRight); 87 | frustumCorners.SetRow(3, topLeft); 88 | 89 | material.SetMatrix("_FrustumCornersRay", frustumCorners); 90 | material.SetMatrix("_UnityMatVP", frustumCorners); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scripts/MergeRayMarch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1b153d5efa56c345846b260e3817c5d 3 | timeCreated: 1444465351 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - fogShader: {fileID: 4800000, guid: 6ca587aa357114cf6ab123394e4de910, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scripts/ThirdPersonUserControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | public class ThirdPersonUserControl : MonoBehaviour { 5 | public float moveSpd = 5; 6 | public float turnSpeed = 180; 7 | public float lerpSpd = 2f; 8 | public Camera cam; 9 | public Vector3 relSrcPos = new Vector3(0,7,-7); 10 | public Vector3 relTargetPos = new Vector3(0, 0, 7); 11 | float up; 12 | private void Update() { 13 | float h = Input.GetAxis("Horizontal"); 14 | float v = Input.GetAxis("Vertical"); 15 | bool crouch = Input.GetKey(KeyCode.C); 16 | up = 0; 17 | if (Input.GetKey(KeyCode.F)) { 18 | up = -1; 19 | } 20 | if (Input.GetKey(KeyCode.G)) { 21 | up = 1; 22 | } 23 | 24 | transform.Rotate(0, h * turnSpeed * Time.deltaTime, 0); 25 | Vector3 forward = transform.forward; 26 | forward.y = 0; 27 | transform.position += (v * forward + up * transform.up) * moveSpd * Time.deltaTime; 28 | if (cam != null) { 29 | var camTran = cam.transform; 30 | var srcRot = camTran.rotation; 31 | var srcPos = camTran.position; 32 | var dstPos = transform.TransformPoint(relSrcPos); 33 | var targetPos = transform.TransformPoint(relTargetPos); 34 | camTran.position = dstPos; 35 | camTran.LookAt(targetPos); 36 | var dstRot = camTran.rotation; 37 | 38 | camTran.position = Vector3.Slerp(srcPos, dstPos, Time.deltaTime* lerpSpd); 39 | camTran.rotation = Quaternion.Slerp(srcRot, dstRot, Time.deltaTime* lerpSpd); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Scripts/ThirdPersonUserControl.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 521b611700410be45810047f0a74e899 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa71dfdf06e848d47b08ebdec1e357b6 3 | folderAsset: yes 4 | timeCreated: 1520648389 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/2DCloudSea.shader: -------------------------------------------------------------------------------- 1 | // create by JiepengTan 2 | // date: 2018-03-27 3 | // email: jiepengtan@gmail.com 4 | Shader "FishManShaderTutorial/2DCloudSea"{ 5 | Properties{ 6 | _MainTex ("MainTex", 2D) = "white" {} 7 | } 8 | 9 | SubShader 10 | { 11 | Tags { "RenderType" = "Transparent" "Queue" = "Transparent" } 12 | 13 | Pass 14 | { 15 | ZWrite Off 16 | Blend SrcAlpha OneMinusSrcAlpha 17 | 18 | CGPROGRAM 19 | #pragma vertex vert 20 | #pragma fragment frag 21 | #include "ShaderLibs/Framework2D.cginc" 22 | 23 | #define LAYER 22.0 24 | fixed Wave(float layer,fixed2 uv,fixed val){ 25 | float amplitude = layer*layer*0.00004; 26 | float frequency = val*200*uv.x/layer; 27 | float phase = 9.*layer+ _Time.z/val; 28 | return amplitude*sin(frequency+phase); 29 | } 30 | float Circle(fixed2 uv,fixed2 center,float size,float blur){ 31 | uv = uv - center; 32 | uv /= size; 33 | float len = length(uv); 34 | return smoothstep(1.,1.-blur,len); 35 | } 36 | float AngleCircle(fixed2 uv,fixed2 center,float size,float blur){ 37 | uv = uv - center; 38 | uv /= size; 39 | float deg = atan2(uv.y,uv.x) + _Time.y * -0.1; 40 | float len = length(uv); 41 | float offs =( sin(deg*9)*3.+sin(deg*11+sin(_Time.y*6)*.5))*0.05; 42 | return smoothstep(1.+offs,1.-blur+offs,len); 43 | } 44 | 45 | float DrawCloud(fixed2 uv,fixed2 center,float size){ 46 | uv = uv - center; 47 | uv /= size; 48 | float col = Circle(uv,fixed2(0.,0.),0.2,0.05); 49 | col =col * smoothstep(-0.1,-0.1+0.01,uv.y); 50 | col += Circle(uv,fixed2(0.15,-0.05),0.1,0.05); 51 | col += Circle(uv,fixed2(0.,-0.1),0.11,0.05); 52 | col += Circle(uv,fixed2(-0.15,-0.1),0.1,0.05); 53 | col += Circle(uv,fixed2(-0.3,-0.08),0.1,0.05); 54 | col += Circle(uv,fixed2(-0.2,0.),0.15,0.05); 55 | return col; 56 | } 57 | float DrawClouds(fixed2 uv){ 58 | uv.x += 0.03*_Time.y; 59 | uv.x = frac(uv.x+0.5) - 0.5; 60 | float col = DrawCloud( uv,fixed2(-0.4,0.3),0.2); 61 | col += DrawCloud( uv,fixed2(-0.2,0.42),0.2); 62 | col += DrawCloud( uv,fixed2(0.0,0.4),0.2); 63 | col += DrawCloud( uv,fixed2(0.15,0.3),0.2); 64 | col += DrawCloud( uv,fixed2(0.45,0.45),0.2); 65 | return col; 66 | } 67 | float3 ProcessFrag(float2 uv) { 68 | float3 col = float3(0.0,0.0,0.0); 69 | float num = 0.; 70 | for (float i=1.; i < LAYER; i++) { 71 | float wave = 2.*Wave(i,uv,1.)+Wave(i,uv,1.8)+.5*Wave(i,uv,3.); 72 | float layerVal = 0.7-0.03*i + wave; 73 | if(uv.y >layerVal){ 74 | break; 75 | } 76 | num = i;//计算所在层的ID 77 | } 78 | col = num*fixed3(0,.03,1);//计算每一层的基本颜色 79 | col += (LAYER - num) * fixed3(.04,.04,.04);//颜色叠亮 80 | if(num ==0){ 81 | //添加海平面泛光 82 | float ry = Remap(0.7,1.0,1.0,0.0,uv.y); 83 | col = lerp(fixed3(0.1,0.6,0.9),fixed3(0.1,0.7,0.9),ry); 84 | col += pow(ry,10.)*fixed3(0.9,0.2,0.1)*0.2; 85 | } 86 | //调整UV为(-0.5,-0.5,0.5,0.5)方便绘图 87 | uv = uv - fixed2(0.5,0.5); 88 | //添加太阳 89 | fixed2 sunPos = fixed2(0.3,0.35); 90 | fixed sun = Circle(uv,sunPos,0.06,0.05); 91 | fixed sunCircle = AngleCircle(uv,sunPos,0.08,0.05); 92 | col = lerp( col ,fixed3(0.9,0.6,0.15),sunCircle); 93 | col = lerp( col ,fixed3(0.98,0.9,0.1),sun); 94 | //云 95 | col += DrawClouds(uv); 96 | return col; 97 | } 98 | ENDCG 99 | }//end pass 100 | }//end SubShader 101 | }//end Shader 102 | 103 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/2DCloudSea.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06087962bb9cd6d4c880680963886e27 3 | timeCreated: 1520670040 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/BaseMath.shader: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Shaders/BaseMath.shader -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/BaseMath.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f3ec4d0b17d64641952277f954380ba 3 | timeCreated: 1520670040 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/Fog.shader: -------------------------------------------------------------------------------- 1 | // create by JiepengTan 2018-04-13 2 | // email: jiepengtan@gmail.com 3 | Shader "FishManShaderTutorial/Fog" { 4 | Properties{ 5 | _MainTex("Base (RGB)", 2D) = "white" {} 6 | _LoopNum ("_LoopNum", Vector) = (40.,128., 1, 1) 7 | _FogSpd ("_FogSpd", Vector) = (1.,0.,0.,0.5) 8 | _FogHighRange ("_FogHighRange", Vector) = (-5,10,0.,0.5) 9 | _FogCol ("_FogCol", COLOR) = (.025, .2, .125,0.) 10 | 11 | } 12 | SubShader{ 13 | Pass { 14 | ZTest Always Cull Off ZWrite Off 15 | CGPROGRAM 16 | float4 _LoopNum = float4(40.,128.,0.,0.); 17 | float3 _FogSpd ; 18 | float2 _FogHighRange; 19 | fixed3 _FogCol; 20 | 21 | #pragma vertex vert 22 | #pragma fragment frag 23 | #include "ShaderLibs/Framework3D.cginc" 24 | #define ITR 100 25 | #define FAR 50. 26 | 27 | 28 | fixed3 Normal(in fixed3 p) 29 | { 30 | return float3(0.,1.0,0.); 31 | } 32 | 33 | fixed RayCast(in fixed3 ro, in fixed3 rd) 34 | { 35 | if (rd.y>=0.0) { 36 | return 100000; 37 | } 38 | float d = -(ro.y - 0.)/rd.y; 39 | d = min(100000.0, d); 40 | return d; 41 | } 42 | float4 ProcessRayMarch(float2 uv,float3 ro,float3 rd,inout float sceneDep,float4 sceneCol){ 43 | fixed3 ligt = normalize( fixed3(.5, .05, -.2) ); 44 | fixed3 ligt2 = normalize( fixed3(.5, -.1, -.2) ); 45 | 46 | fixed rz = RayCast(ro,rd); 47 | 48 | fixed3 fogb = lerp(fixed3(.7,.8,.8 )*0.3, fixed3(1.,1.,.77)*.95, pow(dot(rd,ligt2)+1.2, 2.5)*.25); 49 | fogb *= clamp(rd.y*.5+.6, 0., 1.); 50 | fixed3 col = fogb; 51 | 52 | if ( rz < FAR ) 53 | { 54 | fixed3 pos = ro+rz*rd; 55 | fixed3 nor= Normal( pos ); 56 | fixed dif = clamp( dot( nor, ligt ), 0.0, 1.0 ); 57 | fixed spe = pow(clamp( dot( reflect(rd,nor), ligt ), 0.0, 1.0 ),50.); 58 | col = lerp(fixed3(0.1,0.2,1),fixed3(.3,.5,1),pos.y*.5)*0.2+.1; 59 | col = col*dif + col*spe*.5 ; 60 | } 61 | 62 | MergeRayMarchingIntoUnity(rz,col,sceneDep,sceneCol); 63 | 64 | col = lerp(col, fogb, smoothstep(FAR-7.,FAR,rz)); 65 | //then volumetric fog 66 | col = Fog(col, ro, rd, rz,_FogCol,_FogSpd,_FogHighRange); 67 | //post 68 | col = pow(col,float3(0.8,0.8,0.8)); 69 | sceneCol.xyz = col; 70 | return sceneCol; 71 | } 72 | ENDCG 73 | }//end pass 74 | }//end SubShader 75 | FallBack Off 76 | } 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/Fog.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39b3f08c8eb2ec448a3570d17b8b75e2 3 | timeCreated: 1523596991 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/GameHPUI.shader: -------------------------------------------------------------------------------- 1 | // create by JiepengTan 2018-03-25 email: jiepengtan@gmail.com 2 | 3 | Shader "FishManShaderTutorial/GameHPUI" { 4 | Properties{ 5 | _MainTex("Base (RGB)", 2D) = "white" {} 6 | _LoopNum ("_LoopNum", Vector) = (314.,1., 1, 1) 7 | 8 | } 9 | SubShader 10 | { 11 | Tags { "RenderType"="Opaque" } 12 | LOD 100 13 | 14 | Pass 15 | { 16 | CGPROGRAM 17 | #pragma vertex vert 18 | #pragma fragment frag 19 | #include "UnityCG.cginc" 20 | #include "ShaderLibs/Math.cginc" 21 | 22 | #define SIZE 0.5 23 | #define WATER_DEEP 0.6 24 | struct appdata 25 | { 26 | float4 vertex : POSITION; 27 | float2 uv : TEXCOORD0; 28 | }; 29 | 30 | struct v2f 31 | { 32 | float2 uv : TEXCOORD0; 33 | float4 vertex : SV_POSITION; 34 | }; 35 | 36 | float Rand(float x) 37 | { 38 | return frac(sin(x*866353.13)*613.73); 39 | } 40 | 41 | float2x2 Rotate2D(float deg){ 42 | deg = deg * Deg2Radius; 43 | return float2x2(cos(deg),sin(deg),-sin(deg),cos(deg)); 44 | } 45 | float2 Within(float2 uv, float4 rect) { 46 | return (uv-rect.xy)/(rect.zw-rect.xy); 47 | } 48 | float Circle(float2 uv,float2 center,float size,float blur){ 49 | uv = uv - center; 50 | uv /= size; 51 | float len = length(uv); 52 | return smoothstep(1.,1.-blur,len); 53 | } 54 | 55 | float PureCircle(float2 uv,float2 center,float size,float blur,float powVal){ 56 | uv = uv - center; 57 | uv /= size; 58 | float len = 1.-length(uv); 59 | float val = clamp(Remap(0.,blur,0.,1.,len),0.,1.); 60 | return pow(val,powVal);//* pow(1.+len * 3.,0.1); 61 | } 62 | float Ellipse(float2 uv,float2 center,float2 size,float blur){ 63 | uv = uv - center; 64 | uv /= size; 65 | float len = length(uv); 66 | return smoothstep(1.,1.-blur,len); 67 | } 68 | 69 | 70 | float3 Draw3DFrame(float2 uv){ 71 | //cameraPos 72 | float3 camPos = float3(0.,0.,-3); 73 | //Torus 74 | float3 frameCol = float3(0.9,0.75,0.6); 75 | float frameMask = Circle(uv,float2(0.,0.),SIZE*1.1,0.01) - 76 | Circle(uv,float2(0.,0.),SIZE,0.01); 77 | return float3(0.,0.,0.); 78 | 79 | } 80 | float Torus2D(float2 uv,float2 center,float2 size,float blur){ 81 | uv = uv - center; 82 | float len = length(uv); 83 | if(lensize.x) 84 | return 0.; 85 | float radio = (len-size.y)/(size.x-size.y); 86 | float val = 1.-abs((radio-0.5)*2.); 87 | return pow(val,blur); 88 | } 89 | 90 | float3 DrawFrame(float2 uv){ 91 | float3 frameCol = float3(0.9,0.75,0.6); 92 | float frameMask = Circle(uv,float2(0.,0.),SIZE*1.1,0.01) - 93 | Circle(uv,float2(0.,0.),SIZE,0.01); 94 | //return frameCol * frameMask; 95 | return Torus2D(uv,float2(0.,0.),float2(SIZE * 1.1,SIZE),0.2) *frameCol; 96 | } 97 | float3 DrawHightLight(float2 uv){ 98 | //up 99 | float3 hlCol = float3(0.95,0.95,0.95); 100 | float upMask = Ellipse(uv,float2(0.,0.8)*SIZE,float2(0.9,0.7)*SIZE,0.6)*0.9; 101 | upMask = upMask * Circle(uv,float2(0.,0.)*SIZE,SIZE*0.95,0.02) ; 102 | upMask = upMask * Circle(uv,float2(0.,-0.9)*SIZE,SIZE*1.1,-0.8) ; 103 | //bottom 104 | uv =mul(Rotate2D(30.),uv) ; 105 | float btMask =1.; 106 | btMask *= Circle(uv,float2(0.,0.)*SIZE,SIZE*0.95,0.02); 107 | float scale = 0.9; 108 | btMask *= 1.- Circle(uv,float2(0.,-0.17+scale)*SIZE,SIZE*(1.+scale),0.2) ; 109 | return (upMask + btMask) * hlCol; 110 | 111 | } 112 | 113 | 114 | float GetWaveHeight(float2 uv){ 115 | uv =mul(Rotate2D(-30.),uv) ; 116 | float wave = 0.12*sin(-2.*uv.x+_Time.y*4.); 117 | uv =mul(Rotate2D(-50.),uv) ; 118 | wave += 0.05*sin(-2.*uv.x+_Time.y*4.); 119 | return wave; 120 | } 121 | 122 | float RayMarchWater(float3 camera, float3 dir,float startT,float maxT){ 123 | float3 pos = camera + dir * startT; 124 | float t = startT; 125 | for(int i=0;i<150;i++){ 126 | if(t > maxT){ 127 | return -1.; 128 | } 129 | float h = GetWaveHeight(pos.xz) * WATER_DEEP; 130 | if(h + 0.01 > pos.y ) {//+ 0.01 acc intersect speed 131 | // get the intersect point 132 | return t; 133 | } 134 | t += pos.y - h; 135 | pos = camera + dir * t; 136 | } 137 | return -1.0; 138 | } 139 | 140 | float4 SimpleWave3D(float2 uv,float3 col){ 141 | float3 camPos =float3(0.23,0.13,-2.28); 142 | float3 targetPos = float3(0.,0.,0.); 143 | 144 | float3 f = normalize(targetPos-camPos); 145 | float3 r = cross(normalize(float3(0.01, 1., 0.)), f); 146 | float3 u = cross(f, r); 147 | 148 | float3 ray = normalize(uv.x*r+uv.y*u+1.0*f); 149 | 150 | float startT = 0.1; 151 | float maxT = 20.; 152 | float dist = RayMarchWater(camPos, ray,startT,maxT); 153 | float3 pos = camPos + ray * dist; 154 | //only need a small circle 155 | float circleSize = 2.; 156 | if(dist < 0.){ 157 | return float4(0.,0.,0.,0.); 158 | } 159 | float2 offsetPos = pos.xz; 160 | if(length(offsetPos)>circleSize){ 161 | return float4(0.,0.,0.,0.); 162 | } 163 | float colVal = 1.-((pos.z+0.)/circleSize +1.0) *.5;//0~1 164 | return float4(col*smoothstep(0.,1.4,colVal),1.); 165 | } 166 | float SmoothCircle(float2 uv,float2 offset,float size){ 167 | uv -= offset; 168 | uv/=size; 169 | float temp = clamp(1.-length(uv),0.,1.); 170 | return smoothstep(0.,1.,temp); 171 | } 172 | float DrawBubble(float2 uv,float2 offset,float size){ 173 | uv = (uv - offset)/size; 174 | float val = 0.; 175 | val = length(uv); 176 | val = smoothstep(0.5,2.,val)*step(val,1.); 177 | 178 | val +=SmoothCircle(uv,float2(-0.2,0.3),0.6)*0.4; 179 | val +=SmoothCircle(uv,float2(0.4,-0.5),0.2)*0.2; 180 | return val; 181 | } 182 | float DrawBubbles(float2 uv){ 183 | uv = Within(uv, float4(-SIZE,-SIZE,SIZE,SIZE)); 184 | uv.x-=0.5; 185 | float val = 0.; 186 | const float count = 2.;// bubble num per second 187 | const float maxVY = 0.1; 188 | const float ay = -.3; 189 | const float ax = -.5; 190 | const float maxDeg = 80.; 191 | const float loopT = maxVY/ay + (1.- 0.5*maxVY*maxVY/ay)/maxVY; 192 | const float num = loopT*count; 193 | for(float i=1.;i=0.0001 ) sh = SoftShadow(pos+_LightDir*SC*0.05,_LightDir,SC*200.0); 94 | 95 | // 96 | float3 lin = float3(0.0,0.0,0.0); 97 | lin += dif*float3(7.00,5.00,3.00)*1.3*float3( sh, sh*sh*0.5+0.5*sh, sh*sh*0.8+0.2*sh ); 98 | lin += amb*float3(0.40,0.60,1.00)*1.2; 99 | lin += bac*float3(0.40,0.50,0.60); 100 | col *= lin; 101 | 102 | // fog 103 | float fo = 1.0-exp(-pow(0.001*rz/SC,1.5)); 104 | float3 fco = 0.65*float3(0.4,0.65,1.0);// + 0.1*float3(1.0,0.8,0.5)*pow( sundot, 4.0 ); 105 | col = lerp( col, fco, fo ); 106 | return col; 107 | } 108 | float4 ProcessRayMarch(float2 uv,float3 ro,float3 rd,inout float sceneDep,float4 sceneCol){ 109 | float maxT = 10000; 110 | float minT = 0.1; 111 | float3 col = float3 (0.,0.,0.); 112 | float waterT = maxT; 113 | if(rd.y <-0.01){ 114 | float t = -(ro.y - waterHeight)/rd.y; 115 | waterT = min(waterT,t); 116 | } 117 | float sundot = clamp(dot(rd,_LightDir),0.0,1.0); 118 | float rz = RaycastTerrain(ro,rd); 119 | float firstInsertRZ = min(rz,waterT); 120 | float fresnel = 0; 121 | float3 refractCol = float3(0.,0.,0.); 122 | bool reflected = false; 123 | // hit the water 124 | if(rz >= waterT && rd.y < -0.01){ 125 | float3 waterPos = ro + rd * waterT; 126 | float3 nor = WaterNormal(waterPos,waterT); 127 | float ndotr = dot(nor,-rd); 128 | fresnel = pow(1.0-abs(ndotr),6.);//计算 129 | float3 diff = pow(dot(nor,_LightDir) * 0.4 + 0.6,3.); 130 | // get the water col 131 | float3 waterCol = _BaseWaterColor + diff * _LightWaterColor * 0.12; 132 | float transPer = pow(1.0-clamp( rz - waterT,0,waterTranDeep)/waterTranDeep,3.); 133 | // get refract bg col 134 | float3 bgCol = RenderMountain(ro,rd + nor* clamp(1.-dot(rd,-nor),0.,1.),rz); 135 | refractCol = lerp(waterCol,bgCol,transPer); 136 | 137 | ro = waterPos; 138 | rd = reflect( rd, nor); 139 | rz = RaycastTerrain(ro,rd); 140 | reflected = true; 141 | col = refractCol; 142 | } 143 | if(rz >= maxT){ 144 | col = Sky( ro, rd,_LightDir); 145 | }else{ 146 | col = RenderMountain(ro,rd,rz); 147 | } 148 | if( reflected == true ) { 149 | col = lerp(refractCol,col,fresnel); 150 | float spec= pow(max(dot(rd,_LightDir),0.0),128.) * 3.; 151 | col += float3(spec,spec,spec); 152 | } 153 | 154 | MergeUnityIntoRayMarching(firstInsertRZ,col,sceneDep,sceneCol); 155 | sceneCol.xyz = col; 156 | 157 | return sceneCol; 158 | } 159 | ENDCG 160 | }//end pass 161 | }//end SubShader 162 | FallBack Off 163 | } 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/HighlandLake.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3556c3d25c426ac47b04c270fd5e7ae2 3 | timeCreated: 1523956884 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/Mountain.shader: -------------------------------------------------------------------------------- 1 | Shader "FishManShaderTutorial/Mountain" { 2 | Properties{ 3 | _MainTex("Base (RGB)", 2D) = "white" {} 4 | _LoopNum ("_LoopNum", Vector) = (314.,1., 1, 1) 5 | _MaxTerrianH ("_MaxTerrianH", float) = 500. // color 6 | } 7 | SubShader{ 8 | Pass { 9 | ZTest Always Cull Off ZWrite Off 10 | CGPROGRAM 11 | 12 | #pragma vertex vert 13 | #pragma fragment frag 14 | #include "ShaderLibs/Framework3D_Terrain.cginc" 15 | float _MaxTerrianH; 16 | 17 | #define Terrain(pos,NUM)\ 18 | float2 p = pos.xz*.9/_MaxTerrianH;\ 19 | float a = 0.0;\ 20 | float b = 0.491;\ 21 | float2 d = float2(0.0,0.);\ 22 | for( int i=0; itmax ){ 76 | col= Sky(pos,rd,_LightDir); 77 | }else{ 78 | col = RenderMountain(pos,rd,rz,nor,_LightDir); 79 | } 80 | //gamma 81 | col = pow( col, float3(0.4545,0.4545,0.4545) ); 82 | sceneCol.xyz = col; 83 | return sceneCol; 84 | } 85 | ENDCG 86 | }//end pass 87 | }//end SubShader 88 | FallBack Off 89 | } 90 | 91 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/Mountain.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e170df9da753e7428c8bc566e05f248 3 | timeCreated: 1524839096 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/RaymarchExample.shader: -------------------------------------------------------------------------------- 1 | //// create by JiepengTan 2 | //// date:2018-04-12 3 | //// email: jiepengtan@gmail.com 4 | Shader "FishManShaderTutorial/RaymarchMergeExample" { 5 | Properties{ 6 | _MainTex("Base (RGB)", 2D) = "white" {} 7 | } 8 | SubShader{ 9 | Pass { 10 | ZTest Always Cull Off ZWrite Off 11 | CGPROGRAM 12 | 13 | #pragma vertex vert 14 | #pragma fragment frag 15 | #include "ShaderLibs/Framework3D.cginc" 16 | 17 | float4 ProcessRayMarch(float2 uv,float3 ro,float3 rd,inout float sceneDep,float4 sceneCol) { 18 | float3 col = float3(0.,0.,0.); 19 | float3 n = float3(0.,1.0,0.); 20 | float t = sceneDep + 10; 21 | float occ = 0.; 22 | float3 sc = float3(0.,1.0+0.5*sin(ftime*PI2),0.); 23 | float3 sr = 0.5; 24 | float3 ce = sc - ro; 25 | float b = dot( rd, ce ); 26 | float tt = sr*sr - (dot( ce, ce )- b*b ); 27 | if( tt > 0.0 ){ 28 | t = b - sqrt(tt); 29 | float3 p = ro+t*rd; 30 | col = 0.5+0.5*cos(2.*PI*(float3(1.,1.,1.)*p.y*0.2+float3(0.,0.33,0.67))); 31 | } 32 | MergeRayMarchingIntoUnity(t,col, sceneDep,sceneCol); 33 | return float4(col,1.0); 34 | } 35 | ENDCG 36 | }//end pass 37 | }//end SubShader 38 | FallBack Off 39 | } 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/RaymarchExample.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 138a02917ee810841944e96e55eb1706 3 | timeCreated: 1520651574 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/RaymarchMergeRaster.shader: -------------------------------------------------------------------------------- 1 | //// create by JiepengTan 2 | //// date:2018-04-12 3 | //// email: jiepengtan@gmail.com 4 | Shader "FishManShaderTutorial/RaymarchMergeRaster" { 5 | Properties{ 6 | _MainTex("Base (RGB)", 2D) = "white" {} 7 | } 8 | SubShader{ 9 | Pass { 10 | ZTest Always Cull Off ZWrite Off 11 | CGPROGRAM 12 | 13 | #pragma vertex vert 14 | #pragma fragment frag 15 | #include "ShaderLibs/Feature.cginc" 16 | #include "ShaderLibs/Framework3D.cginc" 17 | 18 | #define SPHERE_ID (1.0) 19 | #define FLOOR_ID (2.0) 20 | #define lightDir (normalize(float3(5.,3.0,-1.0))) 21 | 22 | 23 | float MapSphere(float3 pos){ 24 | // center at float3(0.,0.,0.); 25 | float radius = 0.5; 26 | float3 centerPos = float3(0.,1.0+ sin(_Time.y*1.)*0.5,0.); 27 | return length(pos-centerPos) - radius; 28 | } 29 | float MapFloor(float3 pos ){ 30 | float3 n= float3(0.,1.,0.); 31 | float3 d = 0; 32 | return dot(n,pos)-d; 33 | } 34 | float2 Map(float3 pos){ 35 | float dist2Sphere = MapSphere(pos);// ID 1 36 | float dist2Plane = MapFloor(pos); // ID 2 37 | if(dist2Plane < dist2Sphere) { 38 | return float2(dist2Plane,FLOOR_ID); 39 | }else{ 40 | return float2(dist2Sphere,SPHERE_ID); 41 | } 42 | } 43 | 44 | 45 | #define MARCH_NUM 256 //最多光线检测次数 46 | float2 RayCast(float3 ro,float3 rd){ 47 | float tmin = 0.1; 48 | float tmax = 20.0; 49 | 50 | float t = tmin; 51 | float2 res = float2(0.,-1.0); 52 | for( int i=0; i tmax ) break; 58 | t += 0.5*res.x;// 加速检测速度 这里可以有不同的策略 59 | } 60 | if( t>tmax ) return float2(t,-1.0); 61 | return float2( t, res.y ); 62 | } 63 | float SoftShadow(float3 ro, float3 rd ) 64 | { 65 | float res = 1.0; 66 | float t = 0.001; 67 | for( int i=0; i<80; i++ ) 68 | { 69 | float3 p = ro + t*rd; 70 | float h = Map(p); 71 | res = min( res, 16.0*h/t ); 72 | t += h; 73 | if( res<0.001 ||p.y>(200.0) ) break; 74 | } 75 | return clamp( res, 0.0, 1.0 ); 76 | } 77 | 78 | float3 ShadingShpere(float3 rd,float3 pos, float3 n,float3 sd){ 79 | float3 col = float3(1.,0.,0.); 80 | float diff = clamp(dot(n,lightDir),0.,1.); 81 | float bklig = clamp(dot(n,-lightDir),0.,1.)*0.05;//加点背光 82 | return col *(diff+bklig); 83 | } 84 | float3 ShadingFloor(float3 rd,float3 pos, float3 n,float3 sd ){ 85 | float3 col = float3(0.,1.,0.); 86 | float diff = clamp(dot(n,lightDir),0.,1.); 87 | return col *diff*sd; 88 | } 89 | float3 ShadingBG(float3 rd,float3 pos, float3 n ){ 90 | float val = pow(rd.y,2.0); 91 | float3 bCol =float3(0.,0.,0.); 92 | float3 uCol =float3(0.1,0.2,0.9); 93 | return lerp(bCol,uCol,val); 94 | } 95 | float3 Shading(float3 rd,float3 pos, float3 n ,float matID){ 96 | float sd = SoftShadow(pos,lightDir); 97 | if(matID >= (FLOOR_ID-0.5)){ 98 | return ShadingFloor(rd,pos,n,sd); 99 | }else{ 100 | return ShadingShpere(rd,pos,n,sd); 101 | } 102 | } 103 | float3 Normal(float3 pos, float t){ 104 | float val = 0.0001 * t*t; 105 | float3 eps = float3(val,0.,0.); 106 | float3 nor = float3( 107 | Map(pos+eps.xyy).x - Map(pos-eps.xyy).x, 108 | Map(pos+eps.yxy).x - Map(pos-eps.yxy).x, 109 | Map(pos+eps.yyx).x - Map(pos-eps.yyx).x ); 110 | return normalize(nor); 111 | } 112 | 113 | float4 ProcessRayMarch(float2 uv,float3 ro,float3 rd,inout float sceneDep,float4 sceneCol) { 114 | float2 ret = RayCast(ro,rd); 115 | float3 pos = ro+ret.x*rd; 116 | float matID = ret.y; 117 | float rz = ret.x; 118 | //4.计算碰撞点的法线信息 119 | float3 nor= Normal( pos, ret.x ); 120 | 121 | //5.使用步骤4获得的信息计算当前像素的的颜色值 122 | float3 col = Shading(rd, pos,nor,matID); 123 | if(ret.y < -0.5){ 124 | col = ShadingBG(rd,pos,nor); 125 | } 126 | //检测Unity中场景的z值时候小于raymarch场景中的t值,类似于ztest 127 | if(rz>sceneDep){ 128 | col = sceneCol; 129 | rz = sceneDep; 130 | } 131 | return float4(col,1.0); 132 | } 133 | ENDCG 134 | }//end pass 135 | }//end SubShader 136 | FallBack Off 137 | } 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/RaymarchMergeRaster.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52fd39b013bf2f74eab37570ca8b26e8 3 | timeCreated: 1520651574 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/SDF.shader: -------------------------------------------------------------------------------- 1 | // create by JiepengTan 2018-04-13 2 | // email: jiepengtan@gmail.com 3 | Shader "FishManShaderTutorial/SDF" { 4 | Properties{ 5 | _MainTex("Base (RGB)", 2D) = "white" {} 6 | } 7 | SubShader{ 8 | Pass { 9 | ZTest Always Cull Off ZWrite Off 10 | CGPROGRAM 11 | 12 | #define DEFAULT_MAT_COL 13 | #define DEFAULT_PROCESS_FRAG 14 | #define DEFAULT_RENDER 15 | 16 | #pragma vertex vert 17 | #pragma fragment frag 18 | #include "ShaderLibs/Framework3D_DefaultRender.cginc" 19 | 20 | 21 | 22 | float3 rX(const in float3 v, const in float cs, const in float sn) {return mul(v,float3x3(1.0,0.0,0.0,0.0,cs,sn,0.0,-sn,cs));} 23 | float3 rY(const in float3 v, const in float cs, const in float sn) {return mul(v,float3x3(cs,0.0,-sn,0.0,1.0,0.0,sn,0.0,cs));} 24 | float3 rZ(const in float3 v, const in float cs, const in float sn) {return mul(v,float3x3(cs,sn,0.0,-sn,cs,0.0,0.0,0.0,1.0));} 25 | 26 | 27 | // implicitly specifies shading rules 28 | #define WOOD_MAT 0. 29 | #define STRAW_MAT 1. 30 | #define VILLAGE_MAT 2. 31 | 32 | #define BridgeL 40. 33 | #define BridgeW 2. 34 | #define BridgeH 4. 35 | 36 | #define BridgeL1 50. 37 | 38 | 39 | #define LegGap (BridgeW*0.45) 40 | #define LegWid 0.1 41 | #define LegLenGap LegGap * 4. 42 | 43 | #define BoardLen 0.2 44 | 45 | float SdCappedCone( in float3 p, in float3 c ) // c=float3(bottom radius, angle , height) 46 | { 47 | float2 q = float2( length(p.xz), p.y ); 48 | float2 v = float2( c.z*c.y/c.x, -c.z ); 49 | float2 w = v - q; 50 | float2 vv = float2( dot(v,v), v.x*v.x ); 51 | float2 qv = float2( dot(v,w), v.x*w.x ); 52 | float2 d = max(qv,0.0)*qv/vv; 53 | return sqrt( dot(w,w) - max(d.x,d.y) )* sign(max(q.y*v.x-q.x*v.y,w.y)); 54 | } 55 | 56 | 57 | float SdBoatHull( float3 vPos ) 58 | { 59 | vPos.y-=0.4; 60 | float3 vBoatDomain = vPos; 61 | vBoatDomain.x = abs(vBoatDomain.x); 62 | 63 | float boatDist = length( vBoatDomain.xyz - float3(-3.9,3.2,0.)) - 5.6; 64 | 65 | float bs = 14.5; 66 | float gap = 0.3; 67 | float2 offset=float2(0.3,bs+gap); 68 | float cylinder= length(vBoatDomain.xy-offset)-bs; 69 | boatDist=OpS(boatDist,cylinder); 70 | float sSize = 15.0; 71 | float sOff = 0.05; 72 | float sphere = length( vBoatDomain.xyz - float3(0,sSize+sOff,0)) - sSize; 73 | boatDist=OpS(boatDist,sphere); 74 | 75 | float bx = vPos.y+0.4; 76 | boatDist=OpS(boatDist,bx); 77 | 78 | return boatDist; 79 | } 80 | 81 | 82 | float SdHalfCylinder(float3 pos , float3 h){ 83 | float cy=OpS( 84 | SdCylinder(pos.yzx,h.xy + float2(0.03,-0.03)), 85 | SdCylinder(pos.yzx,h.xy) 86 | ); 87 | float bx = SdBox(pos-float3(0.,-h.x*h.z*2.,0.),float3(h.x+0.3,h.x,h.y+0.3)); 88 | return OpS(cy,bx); 89 | } 90 | 91 | 92 | 93 | float SdQuant(float3 pos){ 94 | pos -= float3(-0.,.3,0.); 95 | float barLen = 0.3; 96 | float quantLen = 0.2; 97 | float cy = SdCylinder(pos-float3(0.,0.,0.),float2(0.008,barLen)); 98 | float bx = SdRoundBox(pos-float3(0.,barLen+quantLen,0.),float3(0.025,quantLen,0.002),0.003); 99 | return min(cy,bx); 100 | } 101 | 102 | float SdBoat(float3 pos){ 103 | float ret = 10000.; 104 | //body 105 | float vb = SdBoatHull(pos); 106 | pos.y -=0.07; 107 | float vs = SdBoatHull(pos); 108 | float boatBody = OpS(vb,vs); 109 | 110 | ret = min(ret , boatBody); 111 | //quant 112 | float3 quantPos = pos ; 113 | quantPos.x = abs(pos.x); 114 | quantPos = quantPos- float3(0.05,.72,1.5); 115 | 116 | float degZ= PI*-0.15; 117 | quantPos = rZ(quantPos,sin(degZ),cos(degZ)); 118 | float degX= PI*0.65; 119 | quantPos = rX(quantPos,sin(degX),cos(degX)); 120 | float quant = SdQuant(quantPos*0.5); 121 | ret = min(ret , quant); 122 | 123 | //quant Ring 124 | 125 | float3 ringPos = pos ; 126 | ringPos.x = abs(pos.x); 127 | ringPos = ringPos- float3(0.44,.49,1.72); 128 | 129 | degZ= PI*-0.05; 130 | ringPos = rZ(ringPos,sin(degZ),cos(degZ)); 131 | degZ= PI*-0.45; 132 | ringPos = rX(ringPos,sin(degZ),cos(degZ)); 133 | float ringd = SdTorus(ringPos,float2(0.05,0.005)); 134 | ret = min(ret , ringd); 135 | //bar 136 | float3 bpos = pos; 137 | bpos.z = abs(bpos.z); 138 | float bar1 = SdRoundBox(bpos-float3(0.,0.4,1.5),float3(.46,0.01,0.04),0.01); 139 | ret = min(ret , bar1); 140 | 141 | // roof 142 | float3 q1=pos-float3(0.,0.65,0.); 143 | float3 roofSize = float3(0.65,1.0,0.7); 144 | float roof = SdHalfCylinder(q1,roofSize); 145 | ret = min(ret , roof); 146 | 147 | //pos.x= abs(pos.x);//!! it is strange that i cann't use pos.x= abs(pos.x) to simplify the code 148 | float3 padPos = pos; 149 | //padPos.x = abs(pos.x); 150 | float paddingT = SdClipCylinder( padPos - float3(-0.65,0.42,0.),float3(8,0.02,0.003)); 151 | ret = min(ret , paddingT); 152 | padPos.x = -pos.x; 153 | paddingT = SdClipCylinder( padPos - float3(-0.65,0.42,0.),float3(8,0.02,0.003)); 154 | ret = min(ret , paddingT); 155 | 156 | return ret; 157 | } 158 | 159 | 160 | float BridgeSeg1(float mindist,in float3 pos){ 161 | float dis= 0.; 162 | 163 | // bridge leg 164 | float3 legPos = pos; 165 | legPos.z -= LegLenGap * 0.5; 166 | if( legPos.z < BridgeL-LegLenGap && legPos.z >0.){ 167 | legPos.z = fmod(legPos.z,LegLenGap) - LegLenGap * 0.5; 168 | } 169 | 170 | dis = SdCylinder( float3(abs(legPos.x),legPos.yz)-float3(LegGap,0.,0.0), float2(LegWid,BridgeH) ); 171 | mindist = min( dis, mindist ); 172 | 173 | dis = SdBox( legPos-float3(0.,BridgeH*0.8,0.0), float3(LegGap*0.95,LegWid*0.7,LegWid*0.7) ); 174 | mindist = min( dis, mindist ); 175 | 176 | // bridge face 177 | float3 facePos = pos; 178 | dis = SdBox( facePos-float3(0.,BridgeH,BridgeL*0.5 ), float3(BridgeW,LegWid*0.7,BridgeL*0.5) ); 179 | mindist = min( dis, mindist ); 180 | 181 | float3 boardPos = pos; 182 | if( boardPos.z < BridgeL && boardPos.z >0.){ 183 | boardPos.z = fmod(boardPos.z,BoardLen)- BoardLen * 0.5; 184 | } 185 | dis = SdBox( boardPos-float3(0.,BridgeH + .1,0.), float3(BridgeW,0.1,BoardLen*0.3)); 186 | //dis = SdSphere( boardPos-float3(0.,BridgeH + 4.,BridgeL*0.5),float4(0.,0.,0.,0.5)); 187 | //dis = SdSphere( boardPos, float4(0.,BridgeH,0.,0.5) ); 188 | mindist = min( dis, mindist ); 189 | 190 | return mindist; 191 | } 192 | 193 | float BridgeSeg2(float mindist,in float3 pos){ 194 | float dis= 0.; 195 | pos.z -= BridgeL; 196 | pos.xz = pos.zx; 197 | pos.z = -pos.z; 198 | pos.z += BridgeW; 199 | 200 | return BridgeSeg1(mindist,pos); 201 | } 202 | float SdBridge( in float3 pos ) 203 | { 204 | pos*=3.; 205 | float mindist = 10000000.0; 206 | 207 | float f = 0.5;//-0.5*cos(3.14159*pos.z/20.0); 208 | mindist = BridgeSeg1(mindist,pos); 209 | mindist = BridgeSeg2(mindist,pos); 210 | return 0.25*mindist; 211 | } 212 | 213 | float SdBounceBalls(float3 pos){ 214 | float SIZE = 2.; 215 | float2 gridSize = float2(SIZE,SIZE); 216 | float rv = Hash12( floor((pos.xz) / gridSize)); 217 | pos.xz = OpRep(pos.xz,gridSize); 218 | float bollSize = 0.1; 219 | float bounceH = .5; 220 | return SdSphere(pos- float3(0.,(bollSize+bounceH+sin(_Time.y*3.14 + rv*6.24)*bounceH),0.),bollSize); 221 | } 222 | 223 | float2 Map( in float3 pos ) 224 | { 225 | float2 res = float2( SdPlane( pos), 1.0 ) ; 226 | res = OpU( res, float2( SdBounceBalls( pos),1.) ); 227 | res = OpU( res, float2( SdBridge( pos),1.) ); 228 | 229 | pos -=float3(-1,0.,-.5); 230 | float deg = 1.*3.14159/180.; 231 | pos = rY(pos,sin(deg),cos(deg)); 232 | res = OpU( res, float2( SdBoat( pos),1.) ); 233 | 234 | return res; 235 | } 236 | ENDCG 237 | }//end pass 238 | }//end SubShader 239 | FallBack Off 240 | } 241 | 242 | 243 | 244 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/SDF.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3a27162ef6c24b4d8ca621d2691f369 3 | timeCreated: 1524659081 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/SDFBounceBall.shader: -------------------------------------------------------------------------------- 1 | // create by JiepengTan 2018-04-14 2 | // email: jiepengtan@gmail.com 3 | Shader "FishManShaderTutorial/SDFBounceBall" { 4 | Properties{ 5 | _MainTex("Base (RGB)", 2D) = "white" {} 6 | } 7 | SubShader{ 8 | Pass { 9 | ZTest Always Cull Off ZWrite Off 10 | CGPROGRAM 11 | 12 | #pragma vertex vert 13 | #pragma fragment frag 14 | 15 | #define DEFAULT_MAT_COL 16 | #define DEFAULT_PROCESS_FRAG 17 | #define DEFAULT_RENDER 18 | #include "ShaderLibs/Framework3D_DefaultRender.cginc" 19 | 20 | float SdBounceBalls(float3 pos){ 21 | float SIZE = 2.; 22 | float2 gridSize = float2(SIZE,SIZE); 23 | float rv = Hash12( floor((pos.xz) / gridSize)); 24 | pos.xz = OpRep(pos.xz,gridSize); 25 | float bollSize = 0.1; 26 | float bounceH = .5; 27 | return SdSphere(pos- float3(0.,(bollSize+bounceH+sin(_Time.y*3.14 + rv*6.24)*bounceH),0.),bollSize); 28 | } 29 | 30 | float2 Map( in float3 pos ) 31 | { 32 | float2 res = float2( SdPlane( pos), 1.0 ) ; 33 | res = OpU( res, float2( SdBounceBalls( pos),1.) ); 34 | return res; 35 | } 36 | 37 | ENDCG 38 | }//end pass 39 | }//end SubShader 40 | FallBack Off 41 | } 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/SDFBounceBall.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19b89354d6324fb4ab1152cf5b42a9b4 3 | timeCreated: 1524666720 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/SDFBouncedBall.shader: -------------------------------------------------------------------------------- 1 | // create by JiepengTan 2018-04-14 2 | // email: jiepengtan@gmail.com 3 | Shader "FishManShaderTutorial/SDFBouncedBall" { 4 | Properties{ 5 | _MainTex("Base (RGB)", 2D) = "white" {} 6 | } 7 | SubShader{ 8 | Pass { 9 | ZTest Always Cull Off ZWrite Off 10 | CGPROGRAM 11 | 12 | #pragma vertex vert 13 | #pragma fragment frag 14 | 15 | #define DEFAULT_MAT_COL 16 | #define DEFAULT_PROCESS_FRAG 17 | #define DEFAULT_RENDER 18 | #include "ShaderLibs/Framework3D_DefaultRender.cginc" 19 | 20 | float SdBounceBalls(float3 pos){ 21 | float SIZE = 2.; 22 | float2 gridSize = float2(SIZE,SIZE); 23 | float rv = Hash12( floor((pos.xz) / gridSize)); 24 | pos.xz = OpRep(pos.xz,gridSize); 25 | float bollSize = 0.1; 26 | float bounceH = .5; 27 | return SdSphere(pos- float3(0.,(bollSize+bounceH+sin(_Time.y*3.14 + rv*6.24)*bounceH),0.),bollSize); 28 | } 29 | 30 | float2 Map( in float3 pos ) 31 | { 32 | float2 res = float2( SdPlane( pos), 1.0 ) ; 33 | res = OpU( res, float2( SdBounceBalls( pos),1.) ); 34 | return res; 35 | } 36 | 37 | ENDCG 38 | }//end pass 39 | }//end SubShader 40 | FallBack Off 41 | } 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/SDFBouncedBall.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02d7e736c53a771458b6edabc7768c17 3 | timeCreated: 1524839082 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/Sea.shader: -------------------------------------------------------------------------------- 1 | Shader "FishManShaderTutorial/Sea" { 2 | Properties{ 3 | _MainTex("Base (RGB)", 2D) = "white" {} 4 | _LoopNum ("_LoopNum", Vector) = (314.,1., 1, 1) 5 | _SeaBaseColor ("_SeaBaseColor", Color) = (0.1,0.19,0.22, 1) // color 6 | _SeaWaterColor ("_SeaWaterColor", Color) = (0.8,0.9,0.6) // color 7 | _SeaWaveHeight ("_SeaWaveHeight", float) = 5. // color 8 | 9 | } 10 | SubShader{ 11 | Pass { 12 | ZTest Always Cull Off ZWrite Off 13 | CGPROGRAM 14 | 15 | #pragma vertex vert 16 | #pragma fragment frag 17 | #include "ShaderLibs/Framework3D_Terrain.cginc" 18 | 19 | float3 _SeaBaseColor; 20 | float3 _SeaWaterColor; 21 | float4 _LoopNum; 22 | float _SeaWaveHeight; 23 | 24 | #define Waves(pos,NUM)\ 25 | float2 uv = pos.xz;\ 26 | float w = 0.0,sw = 0.0;\ 27 | float iter = 0.0, ww = 1.0;\ 28 | uv += ftime * 0.5;\ 29 | for(int i=0;imaxT)break; 121 | } 122 | return col; 123 | } 124 | 125 | float3 Sky(float3 ro ,float3 rd,float3 lightDir){ 126 | fixed3 col = fixed3(0.0,0.0,0.0); 127 | float sundot = clamp(dot(rd,lightDir),0.0,1.0); 128 | 129 | // sky 130 | col = float3(0.2,0.5,0.85)*1.1 - rd.y*rd.y*0.5; 131 | col = lerp( col, 0.85*float3(0.7,0.75,0.85), pow( 1.0-max(rd.y,0.0), 4.0 ) ); 132 | // sun 133 | col += 0.25*float3(1.0,0.7,0.4)*pow( sundot,5.0 ); 134 | col += 0.25*float3(1.0,0.8,0.6)*pow( sundot,64.0 ); 135 | col += 0.4*float3(1.0,0.8,0.6)*pow( sundot,512.0 ); 136 | // clouds 137 | col = Cloud(col,ro,rd,float3(1.0,0.95,1.0),1,1); 138 | // . 139 | col = lerp( col, 0.68*float3(0.4,0.65,1.0), pow( 1.0-max(rd.y,0.0), 16.0 ) ); 140 | return col; 141 | } 142 | 143 | // http://iquilezles.org/www/articles/checkerfiltering/checkerfiltering.htm 144 | fixed CheckersGradBox( in fixed2 p ) 145 | { 146 | // filter kernel 147 | fixed2 w = fwidth(p) + 0.001; 148 | // analytical integral (box filter) 149 | fixed2 i = 2.0*(abs(frac((p-0.5*w)*0.5)-0.5)-abs(frac((p+0.5*w)*0.5)-0.5))/w; 150 | // xor pattern 151 | return 0.5 - 0.5*i.x*i.y; 152 | } 153 | 154 | #define Caustic CausticRotateMin 155 | 156 | #endif // FMST_NOISE -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Feature.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef2a6d133ed480b409e6d8a28afdda64 3 | timeCreated: 1523452181 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Framework2D.cginc: -------------------------------------------------------------------------------- 1 | // Create by JiepengTan@gmail.com 2 | // 2018-03-27 3 | #include "FBM.cginc" 4 | #include "Feature.cginc" 5 | sampler2D _MainTex; 6 | float4 _MainTex_ST; 7 | struct appdata 8 | { 9 | float4 vertex : POSITION; 10 | float2 uv : TEXCOORD0; 11 | }; 12 | 13 | struct v2f 14 | { 15 | float2 uv : TEXCOORD0; 16 | float4 vertex : SV_POSITION; 17 | }; 18 | 19 | v2f vert (appdata v) 20 | { 21 | v2f o; 22 | o.vertex = UnityObjectToClipPos(v.vertex); 23 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 24 | return o; 25 | } 26 | float3 ProcessFrag(float2 uv); 27 | float4 frag(v2f i) : SV_Target{ 28 | return float4(ProcessFrag(i.uv),1.0); 29 | } -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Framework2D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 383bced5c8874784c8776fb6bc146a80 3 | timeCreated: 1524366965 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Framework3D.cginc: -------------------------------------------------------------------------------- 1 | // Create by JiepengTan@gmail.com 2 | // 2018-03-27 3 | #ifndef FRAMEWORK_3D 4 | #define FRAMEWORK_3D 5 | 6 | #include "FBM.cginc" 7 | #include "Feature.cginc" 8 | sampler2D _MainTex; 9 | float2 _MainTex_TexelSize; 10 | float4x4 _FrustumCornersRay; 11 | sampler2D _CameraDepthTexture; 12 | 13 | struct v2f { 14 | float4 pos : SV_POSITION; 15 | half2 uv : TEXCOORD0; 16 | half2 uv_depth : TEXCOORD1; 17 | float4 interpolatedRay : TEXCOORD2; 18 | }; 19 | 20 | v2f vert(appdata_img v) { 21 | v2f o; 22 | o.pos = UnityObjectToClipPos(v.vertex); 23 | 24 | o.uv = v.texcoord; 25 | o.uv_depth = v.texcoord; 26 | 27 | #if UNITY_UV_STARTS_AT_TOP 28 | if (_MainTex_TexelSize.y < 0) 29 | o.uv_depth.y = 1 - o.uv_depth.y; 30 | #endif 31 | 32 | int index = 0; 33 | if (v.texcoord.x < 0.5 && v.texcoord.y < 0.5) { 34 | index = 0; 35 | } 36 | else if (v.texcoord.x > 0.5 && v.texcoord.y < 0.5) { 37 | index = 1; 38 | } 39 | else if (v.texcoord.x > 0.5 && v.texcoord.y > 0.5) { 40 | index = 2; 41 | } 42 | else { 43 | index = 3; 44 | } 45 | 46 | #if UNITY_UV_STARTS_AT_TOP 47 | if (_MainTex_TexelSize.y < 0) 48 | index = 3 - index; 49 | #endif 50 | o.interpolatedRay = _FrustumCornersRay[index]; 51 | return o; 52 | } 53 | 54 | //RayMarching is the main world, ignore unity sky box 55 | void MergeUnityIntoRayMarching(inout float rz,inout float3 rCol, float unityDep,float4 unityCol){ 56 | if(rz>unityDep && unityDep<_ProjectionParams.z-1.){// unity camera far plane 57 | rCol = unityCol.xyz; 58 | rz = unityDep; 59 | } 60 | } 61 | //Unity scene is the main world, ignore RayMarching sky box 62 | void MergeRayMarchingIntoUnity(inout float rz,inout float3 rCol, float unityDep,float4 unityCol){ 63 | if(rz>unityDep ){ 64 | rCol = unityCol.xyz; 65 | rz = unityDep; 66 | } 67 | } 68 | 69 | 70 | float4 ProcessRayMarch(float2 uv,float3 ro,float3 rd,inout float sceneDep,float4 sceneCol); 71 | 72 | float4 frag(v2f i) : SV_Target{ 73 | float depth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_depth)); 74 | depth *= length(i.interpolatedRay.xyz); 75 | fixed4 sceneCol = tex2D(_MainTex, i.uv); 76 | float2 uv = i.uv * float2(_ScreenParams.x/_ScreenParams.y,1.0); 77 | fixed3 ro = _WorldSpaceCameraPos; 78 | fixed3 rd = normalize(i.interpolatedRay.xyz); 79 | return ProcessRayMarch(uv,ro,rd,depth,sceneCol); 80 | } 81 | 82 | 83 | #define _MACRO_CALC_NORMAL(pos,rz, MAP_FUNC)\ 84 | float2 e = float2(1.0,-1.0)*0.5773*0.002*rz;\ 85 | return normalize( e.xyy*MAP_FUNC( pos + e.xyy ).x + \ 86 | e.yyx*MAP_FUNC( pos + e.yyx ).x + \ 87 | e.yxy*MAP_FUNC( pos + e.yxy ).x + \ 88 | e.xxx*MAP_FUNC( pos + e.xxx ).x ); 89 | 90 | 91 | #define _MACRO_SOFT_SHADOW(ro, rd, maxH,MAP_FUNC) \ 92 | float res = 1.0;\ 93 | float t = 0.001;\ 94 | for( int i=0; i<80; i++ ){\ 95 | float3 p = ro + t*rd;\ 96 | float h = MAP_FUNC( p).x;\ 97 | res = min( res, 16.0*h/t );\ 98 | t += h;\ 99 | if( res<0.001 ||p.y> maxH ) break;\ 100 | }\ 101 | return clamp( res, 0.0, 1.0 ); 102 | 103 | 104 | #define _MRCRO_RAY_CAST( ro, rd ,tmax,MAP_FUNC)\ 105 | float t = .1;\ 106 | float m = -1.0;\ 107 | for( int i=0; i<256; i++ ) {\ 108 | float precis = 0.0005*t;\ 109 | float2 res = MAP_FUNC( ro+rd*t );\ 110 | if( res.xtmax ) break;\ 111 | t += 0.5*res.x;\ 112 | m = res.y;\ 113 | } \ 114 | if( t>tmax ) m=-1.0;\ 115 | return float2( t, m ); 116 | 117 | 118 | 119 | 120 | #endif -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Framework3D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bf7b3c12de434b48aa33ecab7b01207 3 | timeCreated: 1523452181 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Framework3D_DefaultRender.cginc: -------------------------------------------------------------------------------- 1 | // Create by JiepengTan@gmail.com 2 | // 2018-04-24 3 | #ifndef FRAMEWORK_3D_DEFAULT_SCENE 4 | #define FRAMEWORK_3D_DEFAULT_SCENE 5 | 6 | #include "SDF.cginc" 7 | #include "Framework3D.cginc" 8 | 9 | //DEFAULT_RENDER default render function 10 | //DEFAULT_MAT_COL defualt material color function 11 | //DEFAULT_PROCESS_FRAG default process frag function 12 | 13 | float3 MatCol(float matID,float3 pos,float3 nor); 14 | float2 Map( in float3 pos ); 15 | float3 Render( in float3 ro, in float3 rd ); 16 | 17 | float RayCast(float3 ro, float3 rd) { 18 | _MRCRO_RAY_CAST(ro,rd,1000.,Map); 19 | } 20 | float3 CalcNormal( in float3 pos, float rz ){ 21 | _MACRO_CALC_NORMAL(pos,rz,Map); 22 | } 23 | 24 | float SoftShadow(in float3 ro, in float3 rd,float tmax){ 25 | _MACRO_SOFT_SHADOW(ro,rd,tmax,Map); 26 | } 27 | 28 | float CalcAO( in float3 pos, in float3 nor ) 29 | { 30 | float occ = 0.0; 31 | float sca = 1.0; 32 | for( int i=0; i<5; i++ ) 33 | { 34 | float hr = 0.01 + 0.12*float(i)/4.0; 35 | float3 aopos = nor * hr + pos; 36 | float dd = Map( aopos ).x; 37 | occ += -(dd-hr)*sca; 38 | sca *= 0.95; 39 | } 40 | return clamp( 1.0 - 3.0*occ, 0.0, 1.0 ); 41 | } 42 | 43 | #ifdef DEFAULT_RENDER 44 | float3 Render( in float3 ro, in float3 rd ) 45 | { 46 | float3 col = float3(0.7, 0.9, 1.0) +rd.y*0.8; 47 | float2 res = RayCast(ro,rd); 48 | float t = res.x; 49 | float m = res.y; 50 | if( m>-0.5 ) 51 | { 52 | float3 pos = ro + t*rd; 53 | float3 nor = CalcNormal( pos ,t); 54 | float3 ref = reflect( rd, nor ); 55 | col = MatCol(m,pos,nor); 56 | 57 | // lighitng 58 | float occ = CalcAO( pos, nor ); 59 | float3 lig = normalize( float3(-0.4, 0.7, -0.6) ); 60 | float3 hal = normalize( lig-rd ); 61 | float amb = clamp( 0.5+0.5*nor.y, 0.0, 1.0 ); 62 | float dif = clamp( dot( nor, lig ), 0.0, 1.0 ); 63 | float bac = clamp( dot( nor, normalize(float3(-lig.x,0.0,-lig.z))), 0.0, 1.0 )*clamp( 1.0-pos.y,0.0,1.0); 64 | float dom = smoothstep( -0.1, 0.1, ref.y ); 65 | float fre = pow( clamp(1.0+dot(nor,rd),0.0,1.0), 2.0 ); 66 | 67 | dif *= SoftShadow( pos, lig, 2.5 ); 68 | dom *= SoftShadow( pos, ref, 2.5 ); 69 | 70 | float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0)* 71 | dif * 72 | (0.04 + 0.96*pow( clamp(1.0+dot(hal,rd),0.0,1.0), 5.0 )); 73 | 74 | float3 lin = float3(0.0,0.0,0.0); 75 | lin += 1.30*dif*float3(1.00,0.80,0.55); 76 | lin += 0.40*amb*float3(0.40,0.60,1.00)*occ; 77 | lin += 0.50*dom*float3(0.40,0.60,1.00)*occ; 78 | lin += 0.50*bac*float3(0.25,0.25,0.25)*occ; 79 | lin += 0.25*fre*float3(1.00,1.00,1.00)*occ; 80 | col = col*lin; 81 | col += 10.00*spe*float3(1.00,0.90,0.70); 82 | 83 | col = lerp( col, float3(0.8,0.9,1.0), 1.0-exp( -0.0002*t*t*t ) ); 84 | } 85 | 86 | return float3( clamp(col,0.0,1.0) ); 87 | } 88 | #endif 89 | 90 | #ifdef DEFAULT_MAT_COL 91 | float3 MatCol(float matID,float3 pos,float3 nor) 92 | { 93 | // material 94 | float3 col = 0.45 + 0.35*sin( float3(0.05,0.08,0.10)*(matID-1.0) ); 95 | if( matID<1.5 ) 96 | { 97 | float f = CheckersGradBox( 5.0*pos.xz ); 98 | col = 0.3 + f*float3(0.1,0.1,0.1); 99 | } 100 | return col; 101 | } 102 | #endif 103 | 104 | #ifdef DEFAULT_PROCESS_FRAG 105 | float4 ProcessRayMarch(float2 uv,float3 ro,float3 rd,inout float sceneDep,float4 sceneCol) { 106 | // render 107 | float3 col = Render( ro, rd ); 108 | // gamma 109 | col = pow( col, float3(0.4545,0.4545,0.4545) ); 110 | sceneCol.xyz = col; 111 | return sceneCol; 112 | } 113 | #endif 114 | 115 | 116 | #endif // FRAMEWORK_3D_DEFAULT_SCENE -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Framework3D_DefaultRender.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99893f3e3f144be439098fe73bece80e 3 | timeCreated: 1524666719 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Framework3D_Terrain.cginc: -------------------------------------------------------------------------------- 1 | // Create by JiepengTan@gmail.com 2 | // 2018-04-24 3 | #ifndef FRAMEWORK_3D_DEFAULT_SCENE 4 | #define FRAMEWORK_3D_DEFAULT_SCENE 5 | 6 | #include "SDF.cginc" 7 | #include "Framework3D.cginc" 8 | 9 | //DEFAULT_RENDER_SKY default sky box 10 | 11 | 12 | 13 | float2 TerrainL(float3 pos); 14 | float2 TerrainM(float3 pos); 15 | float2 TerrainH(float3 pos); 16 | 17 | float RaycastTerrain(float3 ro, float3 rd) { 18 | _MRCRO_RAY_CAST(ro,rd,10000.,TerrainL); 19 | } 20 | float3 NormalTerrian( in float3 pos, float rz ){ 21 | _MACRO_CALC_NORMAL(pos,rz,TerrainH); 22 | } 23 | 24 | float SoftShadow(in float3 ro, in float3 rd,float tmax){ 25 | _MACRO_SOFT_SHADOW(ro,rd,tmax,TerrainM); 26 | } 27 | 28 | 29 | #endif // FRAMEWORK_3D_DEFAULT_SCENE -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Framework3D_Terrain.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e3e14fefd7ba80489b2a1b745f7bd58 3 | timeCreated: 1524839082 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Hash.cginc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Hash.cginc -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Hash.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e550209de8150e45ad46c48bdc27609 3 | timeCreated: 1524191674 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Math.cginc: -------------------------------------------------------------------------------- 1 | // Create by JiepengTan@gmail.com 2 | // 2018-03-27 3 | #ifndef FMST_MATH 4 | #define FMST_MATH 5 | 6 | #define PI 3.14159265359 7 | #define PI2 6.28318530718 8 | #define Deg2Radius PI/180. 9 | #define Radius2Deg 180./PI 10 | 11 | #define clamp01(a) clamp(a,0.0,1.0) 12 | 13 | float length2( float2 p ) 14 | { 15 | return sqrt( p.x*p.x + p.y*p.y ); 16 | } 17 | 18 | float length6( float2 p ) 19 | { 20 | p = p*p*p; p = p*p; 21 | return pow( p.x + p.y, 1.0/6.0 ); 22 | } 23 | 24 | float length8( float2 p ) 25 | { 26 | p = p*p; p = p*p; p = p*p; 27 | return pow( p.x + p.y, 1.0/8.0 ); 28 | } 29 | 30 | 31 | float smin( float a, float b, float k ) 32 | { 33 | float h = clamp( 0.5+0.5*(b-a)/k, 0.0, 1.0 ); 34 | return lerp( b, a, h ) - k*h*(1.0-h); 35 | } 36 | #define _m2 (float2x2(0.8,-0.6,0.6,0.8)) 37 | #define _m3 (float3x3( 0.00, 0.80, 0.60, -0.80, 0.36, -0.48, -0.60, -0.48, 0.64 )) 38 | 39 | float2x2 Rot2D(float a){a*= Radius2Deg; float sa = sin(a); float ca = cos(a); return float2x2(ca,-sa,sa,ca);} 40 | float2x2 Rot2DRad(float a){float sa = sin(a); float ca = cos(a); return float2x2(ca,-sa,sa,ca);} 41 | 42 | 43 | float3x3 Rotx(float a){a*= Radius2Deg; float sa = sin(a); float ca = cos(a); return float3x3(1.,.0,.0, .0,ca,sa, .0,-sa,ca);} 44 | float3x3 Roty(float a){a*= Radius2Deg; float sa = sin(a); float ca = cos(a); return float3x3(ca,.0,sa, .0,1.,.0, -sa,.0,ca);} 45 | float3x3 Rotz(float a){a*= Radius2Deg; float sa = sin(a); float ca = cos(a); return float3x3(ca,sa,.0, -sa,ca,.0, .0,.0,1.); } 46 | 47 | float3x3 RotEuler(float3 ang) { 48 | ang = ang*Radius2Deg; 49 | float2 a1 = float2(sin(ang.x),cos(ang.x)); 50 | float2 a2 = float2(sin(ang.y),cos(ang.y)); 51 | float2 a3 = float2(sin(ang.z),cos(ang.z)); 52 | float3x3 m; 53 | m[0] = float3(a1.y*a3.y+a1.x*a2.x*a3.x,a1.y*a2.x*a3.x+a3.y*a1.x,-a2.y*a3.x); 54 | m[1] = float3(-a2.y*a1.x,a1.y*a2.y,a2.x); 55 | m[2] = float3(a3.y*a1.x*a2.x+a1.y*a3.x,a1.x*a3.x-a1.y*a3.y*a2.x,a2.y*a3.y); 56 | return m; 57 | } 58 | 59 | float Remap(float oa,float ob,float na,float nb,float val){ 60 | return (val-oa)/(ob-oa) * (nb-na) + na; 61 | } 62 | #endif // FMST_MATH -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Math.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 063a35099c8283a4cb298cf72f84e1ef 3 | timeCreated: 1523452181 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Noise.cginc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Noise.cginc -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/Noise.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a8079c3616c9c84a875b8abce5e5791 3 | timeCreated: 1523452181 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/SDF.cginc: -------------------------------------------------------------------------------- 1 | // Create by JiepengTan@gmail.com 2 | // 2018-03-27 3 | #ifndef FMST_SDF 4 | #define FMST_SDF 5 | #include "Math.cginc" 6 | 7 | //------------------------------------------------------------------ 8 | 9 | float OpS( float d1, float d2 ) 10 | { 11 | return max(-d2,d1); 12 | } 13 | 14 | float OpU( float d1, float d2 ) 15 | { 16 | return min(d1,d2); 17 | } 18 | float2 OpU( float2 d1, float2 d2 ) 19 | { 20 | return (d1.x 0.0 ) p = float2( p.x - k*p.y, -k*p.x - p.y )/2.0; 100 | p.x += 2.0 - 2.0*clamp( (p.x+2.0)/2.0, 0.0, 1.0 ); 101 | return -length(p)*sign(p.y); 102 | } 103 | 104 | float SdTriPrism( float3 p, float2 h ) 105 | { 106 | float3 q = abs(p); 107 | float d1 = q.z-h.y; 108 | #if 1 109 | // distance bound 110 | float d2 = max(q.x*0.866025+p.y*0.5,-p.y)-h.x*0.5; 111 | #else 112 | // correct distance 113 | h.x *= 0.866025; 114 | float d2 = SdEquilateralTriangle(p.xy/h.x)*h.x; 115 | #endif 116 | return length(max(float2(d1,d2),0.0)) + min(max(d1,d2), 0.); 117 | } 118 | 119 | 120 | 121 | float SdCylinder( float3 p, float2 h ) 122 | { 123 | float2 d = abs(float2(length(p.xz),p.y)) - h; 124 | return min(max(d.x,d.y),0.0) + length(max(d,0.0)); 125 | } 126 | 127 | float SdCone( in float3 p, in float3 c ) 128 | { 129 | float2 q = float2( length(p.xz), p.y ); 130 | float d1 = -q.y-c.z; 131 | float d2 = max( dot(q,c.xy), q.y); 132 | return length(max(float2(d1,d2),0.0)) + min(max(d1,d2), 0.); 133 | } 134 | 135 | float SdConeSection( in float3 p, in float h, in float r1, in float r2 ) 136 | { 137 | float d1 = -p.y - h; 138 | float q = p.y - h; 139 | float si = 0.5*(r1-r2)/h; 140 | float d2 = max( sqrt( dot(p.xz,p.xz)*(1.0-si*si)) + q*si - r2, q ); 141 | return length(max(float2(d1,d2),0.0)) + min(max(d1,d2), 0.); 142 | } 143 | 144 | float SdPryamid4(float3 p, float3 h ) // h = { cos a, sin a, height } 145 | { 146 | // Tetrahedron = Octahedron - Cube 147 | float box = SdBox( p - float3(0,-2.0*h.z,0), float3(2.0*h.z,2.0*h.z,2.0*h.z) ); 148 | 149 | float d = 0.0; 150 | d = max( d, abs( dot(p, float3( -h.x, h.y, 0 )) )); 151 | d = max( d, abs( dot(p, float3( h.x, h.y, 0 )) )); 152 | d = max( d, abs( dot(p, float3( 0, h.y, h.x )) )); 153 | d = max( d, abs( dot(p, float3( 0, h.y,-h.x )) )); 154 | float octa = d - h.z; 155 | return max(-box,octa); // Subtraction 156 | } 157 | 158 | 159 | float SdTorus82( float3 p, float2 t ) 160 | { 161 | float2 q = float2(length2(p.xz)-t.x,p.y); 162 | return length8(q)-t.y; 163 | } 164 | 165 | float SdTorus88( float3 p, float2 t ) 166 | { 167 | float2 q = float2(length8(p.xz)-t.x,p.y); 168 | return length8(q)-t.y; 169 | } 170 | 171 | float SdCylinder6( float3 p, float2 h ) 172 | { 173 | return max( length6(p.xz)-h.x, abs(p.y)-h.y ); 174 | } 175 | 176 | //圆柱切片 177 | float SdClipCylinder( float3 pos, float3 h) 178 | { 179 | pos.x += h.x*h.z*2. - h.x; 180 | float cy = SdCylinder(pos,h.xy); 181 | float bx = SdBox(pos-float3(h.x*(1.+2.*h.z),0.,0.),float3(h.x*2.,h.y+0.3,h.x*2.)); 182 | return OpS(cy,bx); 183 | } 184 | 185 | #endif // FMST_SDF -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/ShaderLibs/SDF.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a37b4b75e1decea4b9df15cb69062ae1 3 | timeCreated: 1523452181 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/Sky.shader: -------------------------------------------------------------------------------- 1 | // create by JiepengTan 2018-04-13 email: jiepengtan@gmail.com 2 | Shader "FishManShaderTutorial/Mountain" { 3 | Properties{ 4 | _MainTex("Base (RGB)", 2D) = "white" {} 5 | } 6 | SubShader{ 7 | Pass { 8 | ZTest Always Cull Off ZWrite Off 9 | CGPROGRAM 10 | 11 | #pragma vertex vert 12 | #pragma fragment frag 13 | #include "ShaderLibs/Framework3D.cginc" 14 | 15 | 16 | float4 ProcessRayMarch(float2 uv,float3 ro,float3 rd,inout float sceneDep,float4 sceneCol) { 17 | fixed3 col = fixed3(0.0,0.0,0.0); 18 | float3 light1 = normalize( float3(-0.8,0.4,-0.3) ); 19 | float sundot = clamp(dot(rd,light1),0.0,1.0); 20 | 21 | // sky 22 | col = float3(0.2,0.5,0.85)*1.1 - rd.y*rd.y*0.5; 23 | col = lerp( col, 0.85*float3(0.7,0.75,0.85), pow( 1.0-max(rd.y,0.0), 4.0 ) ); 24 | // sun 25 | col += 0.25*float3(1.0,0.7,0.4)*pow( sundot,5.0 ); 26 | col += 0.25*float3(1.0,0.8,0.6)*pow( sundot,64.0 ); 27 | col += 0.2*float3(1.0,0.8,0.6)*pow( sundot,512.0 ); 28 | // clouds 29 | col = Cloud(col,ro,rd,float3(1.0,0.95,1.0),1,1); 30 | // . 31 | col = lerp( col, 0.68*float3(0.4,0.65,1.0), pow( 1.0-max(rd.y,0.0), 16.0 ) ); 32 | sceneCol.xyz = col; 33 | return sceneCol; 34 | } 35 | ENDCG 36 | }//end pass 37 | }//end SubShader 38 | FallBack Off 39 | } 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/Sky.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba25e7ac3e69dbe4c934d2f74ca0d6ef 3 | timeCreated: 1523956884 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/Stars.shader: -------------------------------------------------------------------------------- 1 | // create by JiepengTan 2018-04-13 email: jiepengtan@gmail.com 2 | Shader "FishManShaderTutorial/Stars" { 3 | Properties{ 4 | _MainTex("Base (RGB)", 2D) = "white" {} 5 | } 6 | SubShader{ 7 | Pass { 8 | ZTest Always Cull Off ZWrite Off 9 | CGPROGRAM 10 | 11 | #pragma vertex vert 12 | #pragma fragment frag 13 | #include "ShaderLibs/Feature.cginc" 14 | #include "ShaderLibs/Framework3D.cginc" 15 | 16 | float4 ProcessRayMarch(float2 uv,float3 ro,float3 rd,inout float sceneDep,float4 sceneCol) { 17 | sceneCol.xyz = Stars(rd,3.,50.); 18 | return sceneCol; 19 | } 20 | ENDCG 21 | }//end pass 22 | }//end SubShader 23 | FallBack Off 24 | } 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Shaders/Stars.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7970a2fc8db5fb34493d5f9094534820 3 | timeCreated: 1523523623 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14cbc473f42f5e34983cf0db9736ea4c 3 | folderAsset: yes 4 | timeCreated: 1520669950 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Textures/NoiseTex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/Assets/UnityRayMarchingFramework/Textures/NoiseTex.png -------------------------------------------------------------------------------- /Assets/UnityRayMarchingFramework/Textures/NoiseTex.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab95a43a8c8a5394fa9247158b3ffb37 3 | timeCreated: 1523846670 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 0 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 0 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 2048 71 | textureFormat: -1 72 | textureCompression: 0 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | spriteSheet: 78 | serializedVersion: 2 79 | sprites: [] 80 | outline: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 david 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.6.3f1 2 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiepengTan/Unity-Raymarching-Framework/606b3172f1f96a72a21a4f269a3db29ee30d43a6/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Unity-Raymarching-Framework 4 | A framework to easy implement raymarching in unity. Include lots of hash,noise,fbm,SDF,rotate functions,most of them come from shadertoy,with this library,you can easy write raymarching shader in unity without rewrite the noise function again. 5 | 6 | also,this framework provide a easy way to merge your raymarching scene with unity scene. 7 | 8 | Include 9 | Noise: 10 | >1.PNoise :Perlin Noise 11 | 2.VNoise :Value Noise 12 | 3.SNoise :Simplex Noise 13 | 4.WNoise :Worley Noise (Voronoi) 14 | 4.TNoise :TriNoise 15 | 16 | Hash 17 | >// x out, x in... 18 | HashXX 19 | eg: 20 | float2 Hash22(float2 p) 21 | means 2 in 2 out 22 | 23 | FBM 24 | >float FBM( float2 p ) 25 | float FBM( float2 p,float iterNum) 26 | 27 | Rot: 28 | >Rot2D 29 | Rot3D 30 | 31 | SDF: 32 | >SdBox ... 33 | OpU OpS ... 34 | 35 | File specification: 36 | >.Math.cginc :some math functions and macros 37 | .Hash.cginc : hash function 38 | .Noise.cginc : Noise functions eg:PerlinNoise,ValueNoise,SimplexNoise,VoronoiNoise,TriNoise 39 | .FBM.cginc: Fbm functions 40 | .Feature.cginc: some special function : Caustic,Stars,Cloud,Fog ... 41 | .SDF.cginc :some distance function use for modeling 42 | .Framework3D.cginc :a raymarching framework 43 | .Framework3D_DefaultScene.cginc : use for quickly create a Test scene 44 | 45 | 46 | With this framework,you can easy merge raymarching scene with Unity ,and easy to walk around in it ,without rewrite a "SetCamera" function to init ro,rd variable. 47 | 48 | Here is a example: 49 |

50 |

51 | 52 | ```c 53 | Shader "FishManShaderTutorial/RaymarchMergeExample" { 54 | Properties{ 55 | _MainTex("Base (RGB)", 2D) = "white" {} 56 | } 57 | SubShader{ 58 | Pass { 59 | ZTest Always Cull Off ZWrite Off 60 | CGPROGRAM 61 | #pragma vertex vert 62 | #pragma fragment frag 63 | #include "ShaderLibs/Framework3D.cginc" 64 | float4 ProcessRayMarch(float2 uv,float3 ro,float3 rd,inout float sceneDep,float4 sceneCol) { 65 | float3 col = float3(0.,0.,0.); 66 | float3 n = float3(0.,1.0,0.); 67 | float t = sceneDep + 10; 68 | float occ = 0.; 69 | float3 sc = float3(0.,0.5,0.); 70 | float3 sr = 0.5; 71 | float3 ce = sc - ro; 72 | float b = dot( rd, ce ); 73 | float tt = sr*sr - (dot( ce, ce )- b*b ); 74 | if( tt > 0.0 ){ 75 | t = b - sqrt(tt); 76 | float3 p = ro+t*rd; 77 | col = 0.5+0.5*cos(2.*PI*(float3(1.,1.,1.)*p.y*0.2+float3(0.,0.33,0.67))); 78 | } 79 | MergeRayMarchingIntoUnity(t,col, sceneDep,sceneCol); 80 | return float4(col,1.0); 81 | } 82 | ENDCG 83 | }//end pass 84 | }//end SubShader 85 | FallBack Off 86 | } 87 | ``` 88 | 89 | 90 | A simple scene example: 91 |

92 |

93 | 94 | 95 | ```c 96 | // create by JiepengTan 2018-04-14 97 | // email: jiepengtan@gmail.com 98 | Shader "FishManShaderTutorial/SDFBounceBall" { 99 | Properties{ 100 | _MainTex("Base (RGB)", 2D) = "white" {} 101 | } 102 | SubShader{ 103 | Pass { 104 | ZTest Always Cull Off ZWrite Off 105 | CGPROGRAM 106 | 107 | #pragma vertex vert 108 | #pragma fragment frag 109 | 110 | #define DEFAULT_PROCESS_FRAG 111 | #define DEFAULT_RENDER 112 | #include "ShaderLibs/Framework3D_DefaultRender.cginc" 113 | 114 | fixed SdBounceBalls(fixed3 pos){ 115 | fixed SIZE = 2.; 116 | fixed2 gridSize = fixed2(SIZE,SIZE); 117 | fixed rv = Hash12( floor((pos.xz) / gridSize)); 118 | pos.xz = OpRep(pos.xz,gridSize); 119 | fixed bollSize = 0.1; 120 | fixed bounceH = .5; 121 | return SdSphere(pos- fixed3(0.,(bollSize+bounceH+sin(_Time.y*3.14 + rv*6.24)*bounceH),0.),bollSize); 122 | } 123 | // user define mat shading function 124 | fixed3 MatCol(float matID,float3 pos,float3 nor) 125 | { 126 | // material 127 | fixed3 col = 0.45 + 0.35*sin( fixed3(0.05,0.08,0.10)*(matID-1.0) ); 128 | if( matID<1.5 ) 129 | { 130 | fixed f = CheckersGradBox( 5.0*pos.xz ); 131 | col = 0.3 + f*fixed3(0.1,0.1,0.1); 132 | } 133 | return col; 134 | } 135 | // user define scene construct function 136 | fixed2 Map( in fixed3 pos ) 137 | { 138 | fixed2 res = fixed2( SdPlane( pos), 1.0 ) ; 139 | res = OpU( res, fixed2( SdBounceBalls( pos),1.) ); 140 | return res; 141 | } 142 | 143 | ENDCG 144 | }//end pass 145 | }//end SubShader 146 | FallBack Off 147 | } 148 | 149 | ``` 150 | 151 | More examples: 152 |

153 |

154 | 155 |

156 |

157 | 158 |

159 |

160 | 161 |

162 |

163 | 164 | 165 | - [More Examples][1] 166 | - [My shadertoy link][2] 167 | - [My blog][3] 168 | 169 | [1]: https://github.com/JiepengTan/FishManShaderTutorial 170 | [2]: https://www.shadertoy.com/user/FishMan 171 | [3]: https://blog.csdn.net/tjw02241035621611 --------------------------------------------------------------------------------