├── Assets
├── .gitignore
├── Scripts
│ ├── core
│ │ ├── CausticRenderer.cs
│ │ ├── Noise.meta
│ │ ├── CausticRenderer.cs.meta
│ │ ├── Noise
│ │ │ ├── NoiseWave_Component.cs.meta
│ │ │ └── NoiseWave_Component.cs
│ │ ├── Object.cs.meta
│ │ ├── WaterBody.cs.meta
│ │ ├── FloatingObject.cs.meta
│ │ ├── ReflectCamera.cs.meta
│ │ ├── SunLight.cs.meta
│ │ ├── WaterCamera.cs.meta
│ │ ├── WaterSurface.cs.meta
│ │ ├── TestForceToWater.cs.meta
│ │ ├── Object.cs
│ │ ├── TestForceToWater.cs
│ │ ├── SunLight.cs
│ │ ├── FloatingObject.cs
│ │ ├── ReflectCamera.cs
│ │ ├── WaterBody.cs
│ │ └── WaterCamera.cs
│ ├── SIneWave.meta
│ ├── WaveEquation.meta
│ ├── core.meta
│ ├── IWaveComponent.cs.meta
│ ├── SIneWave
│ │ ├── SineWaveMonoBehaviour.cs.meta
│ │ ├── SineWave_Component.cs.meta
│ │ ├── SineWaveMonoBehaviour.cs
│ │ └── SineWave_Component.cs
│ ├── SineWave
│ │ ├── GerstnerWave_Component.cs.meta
│ │ ├── SineWaveDeform_Component.cs.meta
│ │ ├── SineWaveDeform_Component.cs
│ │ └── GerstnerWave_Component.cs
│ ├── WaveEquation
│ │ ├── WaveEquation_Component.cs.meta
│ │ ├── TestWaveEquation.cs.meta
│ │ ├── WaveEquation_Component.cs
│ │ └── TestWaveEquation.cs
│ └── IWaveComponent.cs
├── FreeUnityPackageFromAssetStore
│ ├── SkyBox
│ │ ├── sky.psd
│ │ ├── sky.tga
│ │ ├── skybox.mat.meta
│ │ ├── sky.psd.meta
│ │ ├── skybox.mat
│ │ └── sky.tga.meta
│ ├── UnityShaderBook
│ │ ├── water_noise.jpg
│ │ ├── Wall01_Diffuse.tga
│ │ ├── Wall01_Normal.tga
│ │ ├── Wall02_Diffuse.png
│ │ ├── Wall02_Normal.png
│ │ ├── Wall03_Diffuse.jpg
│ │ ├── Wall03_Normal.jpg
│ │ ├── Wall04_Diffuse.jpg
│ │ ├── Wall05_Diffuse.png
│ │ ├── Wall05_Normal.png
│ │ ├── Water_Diffuse.jpg
│ │ ├── Wall01_Diffuse.tga.meta
│ │ ├── Wall01_Normal.tga.meta
│ │ ├── Wall02_Diffuse.png.meta
│ │ ├── Wall02_Normal.png.meta
│ │ ├── Wall03_Diffuse.jpg.meta
│ │ ├── Wall03_Normal.jpg.meta
│ │ ├── Wall04_Diffuse.jpg.meta
│ │ ├── Wall05_Diffuse.png.meta
│ │ ├── Wall05_Normal.png.meta
│ │ ├── Water_Diffuse.jpg.meta
│ │ └── water_noise.jpg.meta
│ ├── UnityShaderBook.meta
│ └── SkyBox.meta
├── Scenes
│ ├── 06-WaterBody&&Noise.unity.meta
│ ├── 02-WaterBody&&WaveEquation.unity.meta
│ ├── 03-WaterBody&&SineWave.unity.meta
│ ├── 05-WaterBody&&Gerstner.unity.meta
│ ├── 01-WaterSurface&&WaveEquation.unity.meta
│ ├── 04-WaterBody&&SineWaveDeform.unity.meta
│ ├── 00-WaveEquation.unity.meta
│ └── 00-WaveEquation.unity
├── Material
│ ├── Wall01.mat.meta
│ ├── Wall02.mat.meta
│ ├── Wall03.mat.meta
│ ├── Wall04.mat.meta
│ ├── Wall05.mat.meta
│ ├── WaterBody.mat.meta
│ ├── UnderWaterCube.mat.meta
│ ├── Water.mat.meta
│ ├── WaterBody.mat
│ ├── Wall01.mat
│ ├── Wall02.mat
│ ├── Wall03.mat
│ ├── Wall04.mat
│ ├── Wall05.mat
│ ├── UnderWaterCube.mat
│ └── Water.mat
├── Shaders
│ ├── SineWave.shader.meta
│ ├── WaterBody.shader.meta
│ ├── Force.shader.meta
│ ├── GerstnerWave.shader.meta
│ ├── SineWaveDeform.shader.meta
│ ├── UnderWater.shader.meta
│ ├── Caustic.shader.meta
│ ├── NoiseWave.shader.meta
│ ├── NoiseNoramlGenerate.shader.meta
│ ├── Water.shader.meta
│ ├── internal.cginc.meta
│ ├── WaveEquation.shader.meta
│ ├── NormalGenerate.shader.meta
│ ├── ShaderMapRender.shader.meta
│ ├── ShaderMapRender.shader
│ ├── Force.shader
│ ├── NoiseWave.shader
│ ├── SineWave.shader
│ ├── Caustic.shader
│ ├── SineWaveDeform.shader
│ ├── internal.cginc
│ ├── WaveEquation.shader
│ ├── NoiseNoramlGenerate.shader
│ ├── NormalGenerate.shader
│ ├── GerstnerWave.shader
│ ├── WaterBody.shader
│ ├── UnderWater.shader
│ └── Water.shader
├── Scenes.meta
├── Material.meta
├── Plugins.meta
├── Prefabs.meta
├── Prefabs
│ ├── Water.prefab.meta
│ ├── WaterSuface.prefab.meta
│ ├── Wall.prefab.meta
│ ├── Directional Light.prefab.meta
│ ├── Directional Light.prefab
│ ├── WaterSuface.prefab
│ └── Water.prefab
├── Scripts.meta
├── Shaders.meta
└── FreeUnityPackageFromAssetStore.meta
├── Packages
└── manifest.json
├── ProjectSettings
├── ProjectVersion.txt
├── ClusterInputManager.asset
├── PresetManager.asset
├── NetworkManager.asset
├── TimeManager.asset
├── EditorBuildSettings.asset
├── AudioManager.asset
├── EditorSettings.asset
├── TagManager.asset
├── DynamicsManager.asset
├── UnityConnectSettings.asset
├── Physics2DSettings.asset
├── NavMeshAreas.asset
├── GraphicsSettings.asset
├── QualitySettings.asset
└── InputManager.asset
├── readme.md
├── .gitignore
└── .gitattributes
/Assets/.gitignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Packages/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | }
4 | }
5 |
--------------------------------------------------------------------------------
/ProjectSettings/ProjectVersion.txt:
--------------------------------------------------------------------------------
1 | m_EditorVersion: 2018.1.9f2
2 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/CausticRenderer.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace LinHowe
4 | {
5 | public class CausticRenderer :MonoBehaviour
6 | {
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ProjectSettings/ClusterInputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!236 &1
4 | ClusterInputManager:
5 | m_ObjectHideFlags: 0
6 | m_Inputs: []
7 |
--------------------------------------------------------------------------------
/ProjectSettings/PresetManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1386491679 &1
4 | PresetManager:
5 | m_ObjectHideFlags: 0
6 | m_DefaultList: []
7 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/SkyBox/sky.psd:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:c891802f6f5a21411398de1395cfd7441c96ed28c2c5a99623e5538b047727cf
3 | size 11597753
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/SkyBox/sky.tga:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:13723f971f7c3e6bc5eabd3ea62801953e5a4da9d7bff1694cce7e1f671bd1be
3 | size 12582956
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/water_noise.jpg:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:babe9c5e7fb96091c9b1872aa8a4daa6f3a59f3784b222332cf2c696018b0b53
3 | size 65536
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall01_Diffuse.tga:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:21185971ec1991ad8e9e972a4c01fbe9fc7a9815e64a31e84a3f921bd570f4a0
3 | size 4196304
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall01_Normal.tga:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:3c9987adc7f0565a1e793e1a63f6623bb99f565972c3f02dc91b1fe3fcb8a043
3 | size 4196300
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall02_Diffuse.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:01bec2074af57af72beb26b98aa22855d6069022f5e197f6898aadb67e10ba0c
3 | size 2167450
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall02_Normal.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:08e7360de8c3e5085b3a0631c16feb5b3a7e73e4ad860a2ade467a79b327063e
3 | size 456710
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall03_Diffuse.jpg:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:9411d96cf8a0406138213934d9c6da448c14be8be91ece5450e76fd4c3748cfd
3 | size 260823
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall03_Normal.jpg:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:ec14d3b6e3d680f6d75210b297a01858a5f447c84ec11ddbd9f748a517f98dfe
3 | size 131072
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall04_Diffuse.jpg:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:304e73cb13458b4327cab907c4520ff51dd00949d34c0d1b181c7e340cd325fe
3 | size 139264
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall05_Diffuse.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:9a07a2477c221784f84014cf7931e62b8b049f3e04f24aa09e3dba2bf76e9340
3 | size 1917268
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall05_Normal.png:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:0feed32845f706ecae8ded11879d138d5e6a091980ab639b06eb239ee2077be4
3 | size 409919
4 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Water_Diffuse.jpg:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:de8a2f2c731668c6a4cf6bc7a8ed2c73ba209dad8804a160cb08fb25e6bf2592
3 | size 243795
4 |
--------------------------------------------------------------------------------
/ProjectSettings/NetworkManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!149 &1
4 | NetworkManager:
5 | m_ObjectHideFlags: 0
6 | m_DebugLevel: 0
7 | m_Sendrate: 15
8 | m_AssetToPrefab: {}
9 |
--------------------------------------------------------------------------------
/Assets/Scenes/06-WaterBody&&Noise.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 15b1090181b35b845ac2e28195e84644
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/Noise.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7f9491b22c8ddf143ab76106e07031d4
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Material/Wall01.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ee95ed222fc7f714fbaacb9576a9433c
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Material/Wall02.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7e4b07c339f566c46a0deb39b5351e36
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Material/Wall03.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f87832efda142fb4997aeaf7acec5b9d
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Material/Wall04.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 87c5860573aad5545800084f3e16f83b
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Material/Wall05.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 75303c38e5e2fbc41bbe67e4c62217b0
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Scenes/02-WaterBody&&WaveEquation.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8c9e545a9f5d9cc43ad766df72dc5b3a
3 | timeCreated: 1542719238
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Scenes/03-WaterBody&&SineWave.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ffab5f6006afa8d4c8149da2994a6faf
3 | timeCreated: 1542722124
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Scenes/05-WaterBody&&Gerstner.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8c69e96f35cb6b3408f82a9d37f66e99
3 | timeCreated: 1542937776
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d0ffd207d4362dd46864835508a5b54c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Scenes/01-WaterSurface&&WaveEquation.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 816a732e88683b846b3d96b2ae1014f8
3 | timeCreated: 1540650970
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Scenes/04-WaterBody&&SineWaveDeform.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b278c0287090d8b4481070a5a82b5b31
3 | timeCreated: 1542856870
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Scripts/SIneWave.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bcc59572b4e86134888e41cdb9a19c89
3 | folderAsset: yes
4 | timeCreated: 1542854581
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/WaveEquation.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5360da3adb1aac34f915281235571d2b
3 | folderAsset: yes
4 | timeCreated: 1542854581
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Shaders/SineWave.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 652973bb1a781df4bb798e9f0d0a7649
3 | timeCreated: 1542724924
4 | licenseType: Free
5 | ShaderImporter:
6 | defaultTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Shaders/WaterBody.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 27d31f245af67e345a467bef5d69c401
3 | timeCreated: 1540654804
4 | licenseType: Free
5 | ShaderImporter:
6 | defaultTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scenes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dd3ffd62390c6eb4a9dae0b4c561e14b
3 | folderAsset: yes
4 | timeCreated: 1539071784
5 | licenseType: Free
6 | DefaultImporter:
7 | externalObjects: {}
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Scenes/00-WaveEquation.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c6a242c2457b24845a40f767ec6f0c57
3 | timeCreated: 1539071890
4 | licenseType: Free
5 | DefaultImporter:
6 | externalObjects: {}
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Shaders/Force.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cf78a4d8b76ee934fa6bdb284ce6088d
3 | ShaderImporter:
4 | externalObjects: {}
5 | defaultTextures: []
6 | nonModifiableTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Shaders/GerstnerWave.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e05d11c1e917c0b40807671a9b35b54a
3 | timeCreated: 1542938896
4 | licenseType: Free
5 | ShaderImporter:
6 | defaultTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Shaders/SineWaveDeform.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ab1db5e0e0e02dc4684ff42f8853af65
3 | timeCreated: 1542856870
4 | licenseType: Free
5 | ShaderImporter:
6 | defaultTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Shaders/UnderWater.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7de2f293b3b24a44581d81b169f03e47
3 | timeCreated: 1540914350
4 | licenseType: Free
5 | ShaderImporter:
6 | defaultTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/ProjectSettings/TimeManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!5 &1
4 | TimeManager:
5 | m_ObjectHideFlags: 0
6 | Fixed Timestep: 0.02
7 | Maximum Allowed Timestep: 0.33333334
8 | m_TimeScale: 1
9 | Maximum Particle Timestep: 0.03
10 |
--------------------------------------------------------------------------------
/Assets/Material.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e8409541f49af464fa404f848cc914dc
3 | folderAsset: yes
4 | timeCreated: 1539347268
5 | licenseType: Free
6 | DefaultImporter:
7 | externalObjects: {}
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Material/WaterBody.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 698d75988f8b6db4a8d905a2658cac94
3 | timeCreated: 1540711572
4 | licenseType: Free
5 | NativeFormatImporter:
6 | mainObjectFileID: 2100000
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Plugins.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 42a7e7fe98d845d4eb7bb3df87f94cde
3 | folderAsset: yes
4 | timeCreated: 1539090736
5 | licenseType: Free
6 | DefaultImporter:
7 | externalObjects: {}
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Prefabs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d631416962b353d4d96226f0a6ecfc39
3 | folderAsset: yes
4 | timeCreated: 1539502802
5 | licenseType: Free
6 | DefaultImporter:
7 | externalObjects: {}
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Prefabs/Water.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6fed62f6ee9488149878f7b530fe7679
3 | timeCreated: 1540653925
4 | licenseType: Free
5 | NativeFormatImporter:
6 | mainObjectFileID: 100100000
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7147ef00c051a064c83f3a52b58bf45f
3 | folderAsset: yes
4 | timeCreated: 1539071932
5 | licenseType: Free
6 | DefaultImporter:
7 | externalObjects: {}
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Shaders.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b9d6cbed0fc08f540bea351575c44164
3 | folderAsset: yes
4 | timeCreated: 1539352151
5 | licenseType: Free
6 | DefaultImporter:
7 | externalObjects: {}
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Shaders/Caustic.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 37ecb2494e9e07f4cb5804f115b2ea8b
3 | ShaderImporter:
4 | externalObjects: {}
5 | defaultTextures: []
6 | nonModifiableTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Shaders/NoiseWave.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c9c92eca5a23f88438346f0b2881d7d9
3 | ShaderImporter:
4 | externalObjects: {}
5 | defaultTextures: []
6 | nonModifiableTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Material/UnderWaterCube.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2ecb83c212bfdb04aa3af77c3afc8f78
3 | timeCreated: 1540916349
4 | licenseType: Free
5 | NativeFormatImporter:
6 | mainObjectFileID: 2100000
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Scripts/core.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cb9ccd9bbb821d74cbac8a6777b31b81
3 | folderAsset: yes
4 | timeCreated: 1539099443
5 | licenseType: Free
6 | DefaultImporter:
7 | externalObjects: {}
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Prefabs/WaterSuface.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: beece6563437af440bbcb7819af52716
3 | timeCreated: 1540707472
4 | licenseType: Free
5 | NativeFormatImporter:
6 | mainObjectFileID: 100100000
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Shaders/NoiseNoramlGenerate.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f49049f8f807bae42bad5db84fccae13
3 | ShaderImporter:
4 | externalObjects: {}
5 | defaultTextures: []
6 | nonModifiableTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/Shaders/Water.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 560b19e2418a7f142a70cd8f8dc3560e
3 | timeCreated: 1539354193
4 | licenseType: Free
5 | ShaderImporter:
6 | externalObjects: {}
7 | defaultTextures: []
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Shaders/internal.cginc.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 344ce85abaeee6442bc82b94c742de2b
3 | timeCreated: 1539446682
4 | licenseType: Free
5 | ShaderImporter:
6 | externalObjects: {}
7 | defaultTextures: []
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f5e37fd1fb57cf04cb7c535a40dbab7c
3 | folderAsset: yes
4 | timeCreated: 1539260199
5 | licenseType: Free
6 | DefaultImporter:
7 | externalObjects: {}
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Shaders/WaveEquation.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cf7868a9f3dab4143b12b3e91f9f5967
3 | timeCreated: 1539572540
4 | licenseType: Free
5 | ShaderImporter:
6 | externalObjects: {}
7 | defaultTextures: []
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Material/Water.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 970a389ba39ecb44b8c1ce961104493d
3 | timeCreated: 1539354483
4 | licenseType: Free
5 | NativeFormatImporter:
6 | externalObjects: {}
7 | mainObjectFileID: 2100000
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Shaders/NormalGenerate.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e1b474b4cdd9c184a9235735a3b99d14
3 | timeCreated: 1539582516
4 | licenseType: Free
5 | ShaderImporter:
6 | externalObjects: {}
7 | defaultTextures: []
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Shaders/ShaderMapRender.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5cd80f6ec2f217a4abc8c0bbe5b87132
3 | timeCreated: 1539501335
4 | licenseType: Free
5 | ShaderImporter:
6 | externalObjects: {}
7 | defaultTextures: []
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/SkyBox.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 02744e8d13fc86040af2fbc1d804f023
3 | folderAsset: yes
4 | timeCreated: 1539344477
5 | licenseType: Free
6 | DefaultImporter:
7 | externalObjects: {}
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Prefabs/Wall.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bde2ced4d14d6294c82d6142a8e10e39
3 | timeCreated: 1539502968
4 | licenseType: Free
5 | NativeFormatImporter:
6 | externalObjects: {}
7 | mainObjectFileID: 100100000
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Prefabs/Directional Light.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f39f0165b9b52a142b920894bea80ea4
3 | timeCreated: 1539502787
4 | licenseType: Free
5 | NativeFormatImporter:
6 | externalObjects: {}
7 | mainObjectFileID: 100100000
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/ProjectSettings/EditorBuildSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1045 &1
4 | EditorBuildSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Scenes:
8 | - enabled: 1
9 | path: Assets/Scenes/02-WaterBody.unity
10 | guid: 64d7ad3b8d3efa940ae5d18afd80162d
11 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | 尝试在unity中以各种方法实现水的渲染
2 |
3 | ## 波动方程实现的水面
4 |
5 | 
6 |
7 | ## 参考资源
8 |
9 | 《GPU Gems》
10 |
11 | github.com/AsehesL/UnityWaveEquation
12 |
13 | github.com/dbrizov/Unity-WaterBuoyancy
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/SkyBox/skybox.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4a7af0e0452fcc94780115de5c5abf03
3 | timeCreated: 1523352112
4 | licenseType: Free
5 | NativeFormatImporter:
6 | externalObjects: {}
7 | mainObjectFileID: 0
8 | userData:
9 | assetBundleName:
10 | assetBundleVariant:
11 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/CausticRenderer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bd5f97d8d9b7373488af0edcf7f02794
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/Noise/NoiseWave_Component.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: daaa6c0fdcfd5ca4696a78afd73af1b6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/Object.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 91918416e00db664f86475665a8f5f1a
3 | timeCreated: 1541075914
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/Scripts/IWaveComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 719109b2e10517247affb607d9690b37
3 | timeCreated: 1542779806
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/Scripts/core/WaterBody.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a6d92144eaab86e4fb00f81f7140272e
3 | timeCreated: 1540652261
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/Scripts/core/FloatingObject.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6d8af5be06bc0ae44a7676a860941982
3 | timeCreated: 1541250112
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/Scripts/core/ReflectCamera.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2982f75578ec9454bb4040909221e3f1
3 | timeCreated: 1540559025
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/Scripts/SIneWave/SineWaveMonoBehaviour.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b489476b54e32d3459fdf95c112a249b
3 | timeCreated: 1542797702
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/Scripts/SIneWave/SineWave_Component.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 428b75a142fdbde4097f32b69f48547f
3 | timeCreated: 1542810702
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/Scripts/SineWave/GerstnerWave_Component.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e757edc65a093774da64ed2048f798c1
3 | timeCreated: 1542938213
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/Scripts/SineWave/SineWaveDeform_Component.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e4668b25e5023bf46a16abdf520f1c93
3 | timeCreated: 1542857970
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/Scripts/WaveEquation/WaveEquation_Component.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f32cb59c691d6d2439c7ae7caba7402f
3 | timeCreated: 1542810702
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/Scripts/core/SunLight.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 773e8804a9246bf47ab6265072f8803e
3 | timeCreated: 1539500412
4 | licenseType: Free
5 | MonoImporter:
6 | externalObjects: {}
7 | serializedVersion: 2
8 | defaultReferences: []
9 | executionOrder: 0
10 | icon: {instanceID: 0}
11 | userData:
12 | assetBundleName:
13 | assetBundleVariant:
14 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/WaterCamera.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b33a80d2d93a79745bbbd1656a36e91f
3 | timeCreated: 1539532947
4 | licenseType: Free
5 | MonoImporter:
6 | externalObjects: {}
7 | serializedVersion: 2
8 | defaultReferences: []
9 | executionOrder: 0
10 | icon: {instanceID: 0}
11 | userData:
12 | assetBundleName:
13 | assetBundleVariant:
14 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/WaterSurface.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 32d68a9644d8cb64593e6c7fbb7c238f
3 | timeCreated: 1539345609
4 | licenseType: Free
5 | MonoImporter:
6 | externalObjects: {}
7 | serializedVersion: 2
8 | defaultReferences: []
9 | executionOrder: 0
10 | icon: {instanceID: 0}
11 | userData:
12 | assetBundleName:
13 | assetBundleVariant:
14 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/TestForceToWater.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: aa4274f7525bb974d8e5bf36ea5ca014
3 | timeCreated: 1540115855
4 | licenseType: Free
5 | MonoImporter:
6 | externalObjects: {}
7 | serializedVersion: 2
8 | defaultReferences: []
9 | executionOrder: 0
10 | icon: {instanceID: 0}
11 | userData:
12 | assetBundleName:
13 | assetBundleVariant:
14 |
--------------------------------------------------------------------------------
/Assets/Scripts/WaveEquation/TestWaveEquation.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 22166a5df2111114c88c083b9de03d08
3 | timeCreated: 1539078462
4 | licenseType: Free
5 | MonoImporter:
6 | externalObjects: {}
7 | serializedVersion: 2
8 | defaultReferences: []
9 | executionOrder: 0
10 | icon: {instanceID: 0}
11 | userData:
12 | assetBundleName:
13 | assetBundleVariant:
14 |
--------------------------------------------------------------------------------
/ProjectSettings/AudioManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!11 &1
4 | AudioManager:
5 | m_ObjectHideFlags: 0
6 | m_Volume: 1
7 | Rolloff Scale: 1
8 | Doppler Factor: 1
9 | Default Speaker Mode: 2
10 | m_SampleRate: 0
11 | m_DSPBufferSize: 0
12 | m_VirtualVoiceCount: 512
13 | m_RealVoiceCount: 32
14 | m_SpatializerPlugin:
15 | m_DisableAudio: 0
16 | m_VirtualizeEffects: 1
17 |
--------------------------------------------------------------------------------
/ProjectSettings/EditorSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!159 &1
4 | EditorSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 3
7 | m_ExternalVersionControlSupport: Hidden Meta Files
8 | m_SerializationMode: 2
9 | m_DefaultBehaviorMode: 0
10 | m_SpritePackerMode: 0
11 | m_SpritePackerPaddingPower: 1
12 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp
13 | m_ProjectGenerationRootNamespace:
14 | m_UserGeneratedProjectSuffix:
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /[Ll]ibrary/
2 | /[Tt]emp/
3 | /[Oo]bj/
4 | /[Bb]uild/
5 | /[Bb]uilds/
6 |
7 | /Assets/AssetStoreTools*
8 |
9 | # Visual Studio 2015 cache directory
10 | /.vs/
11 |
12 | # Autogenerated VS/MD/Consulo solution and project files
13 | ExportedObj/
14 | .consulo/
15 | *.csproj
16 | *.unityproj
17 | *.sln
18 | *.suo
19 | *.tmp
20 | *.user
21 | *.userprefs
22 | *.pidb
23 | *.booproj
24 | *.svd
25 | *.pdb
26 |
27 |
28 | # Unity3D generated meta files
29 | *.pidb.meta
30 |
31 | # Unity3D Generated File On Crash Reports
32 | sysinfo.txt
33 |
34 | # Builds
35 | *.apk
36 | *.unitypackage
--------------------------------------------------------------------------------
/Assets/Scripts/SineWave/SineWaveDeform_Component.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using UnityEngine;
3 |
4 | namespace LinHowe
5 | {
6 | ///
7 | /// 正弦函数变形模拟水面
8 | ///
9 | class SineWaveDeform_Component : SineWave_Component
10 | {
11 |
12 | public SineWaveDeform_Component(WaterRender.WaterSurface water) : base(water)
13 | {
14 |
15 | }
16 | public override void InitWaterCamera(int texSize, Material waveEquationMat)
17 | {
18 | waveEquationMat.SetFloat("k", 4.4f);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ProjectSettings/TagManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!78 &1
4 | TagManager:
5 | serializedVersion: 2
6 | tags: []
7 | layers:
8 | - Default
9 | - TransparentFX
10 | - Ignore Raycast
11 | -
12 | - Water
13 | - UI
14 | -
15 | -
16 | -
17 | -
18 | -
19 | -
20 | -
21 | -
22 | -
23 | -
24 | -
25 | -
26 | -
27 | -
28 | -
29 | -
30 | -
31 | -
32 | -
33 | -
34 | -
35 | -
36 | -
37 | -
38 | -
39 | -
40 | m_SortingLayers:
41 | - name: Default
42 | uniqueID: 0
43 | locked: 0
44 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/Noise/NoiseWave_Component.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | using UnityEngine;
4 |
5 | namespace LinHowe
6 | {
7 | class NoiseWave_Component : IWaveComponent
8 | {
9 | public NoiseWave_Component(WaterRender.WaterSurface water) : base(water)
10 | {
11 |
12 | }
13 |
14 | public override bool InitAndCheckWaveParams(float speed, float viscosity, float d)
15 | {
16 | return true;
17 | }
18 |
19 | public override void OnRenderImage(RenderTexture src, RenderTexture dst, Material waveEquationMat)
20 | {
21 | Graphics.Blit(src, dst, waveEquationMat);
22 | }
23 |
24 | public override void OnPostRender()
25 | {
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Assets/Shaders/ShaderMapRender.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/ShaderMapRender"
2 | {
3 | Properties
4 | {
5 | }
6 | SubShader
7 | {
8 | Tags { "RenderType" = "Opaque" }
9 | Pass
10 | {
11 | CGPROGRAM
12 | #pragma vertex vert
13 | #pragma fragment frag
14 |
15 | #include "UnityCG.cginc"
16 |
17 | struct v2f
18 | {
19 | float4 vertex : SV_POSITION;
20 | float depth : TEXCOORD0;
21 | };
22 |
23 | v2f vert (appdata_base v)
24 | {
25 | v2f o;
26 | o.vertex = UnityObjectToClipPos(v.vertex);
27 | o.depth = COMPUTE_DEPTH_01;
28 | return o;
29 | }
30 |
31 | float4 frag (v2f i) : SV_Target
32 | {
33 | float4 col = EncodeFloatRGBA(i.depth);
34 | return col;
35 | }
36 | ENDCG
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ProjectSettings/DynamicsManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!55 &1
4 | PhysicsManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 3
7 | m_Gravity: {x: 0, y: -9.81, z: 0}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_BounceThreshold: 2
10 | m_SleepThreshold: 0.005
11 | m_DefaultContactOffset: 0.01
12 | m_DefaultSolverIterations: 6
13 | m_DefaultSolverVelocityIterations: 1
14 | m_QueriesHitBackfaces: 0
15 | m_QueriesHitTriggers: 1
16 | m_EnableAdaptiveForce: 0
17 | m_EnablePCM: 1
18 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
19 |
--------------------------------------------------------------------------------
/Assets/Shaders/Force.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/Force"
2 | {
3 | Properties
4 | {
5 | }
6 | SubShader
7 | {
8 | Tags { "RenderType"="Opaque" }
9 |
10 | Pass
11 | {
12 | cull front
13 | CGPROGRAM
14 | #pragma vertex vert
15 | #pragma fragment frag
16 |
17 | #include "UnityCG.cginc"
18 | #include "internal.cginc"
19 |
20 | struct appdata
21 | {
22 | float4 vertex : POSITION;
23 | };
24 |
25 | struct v2f
26 | {
27 | float depth : TEXCOORD0;
28 | float4 vertex : SV_POSITION;
29 | };
30 |
31 | float internal_Force;
32 |
33 | v2f vert (appdata v)
34 | {
35 | v2f o;
36 | o.vertex = UnityObjectToClipPos(v.vertex);
37 | o.depth = COMPUTE_DEPTH_01;
38 | return o;
39 | }
40 |
41 | float4 frag (v2f i) : SV_Target
42 | {
43 | return EncodeHeight(i.depth*internal_Force);
44 | }
45 | ENDCG
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ProjectSettings/UnityConnectSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!310 &1
4 | UnityConnectSettings:
5 | m_ObjectHideFlags: 0
6 | m_Enabled: 0
7 | m_TestMode: 0
8 | m_TestEventUrl:
9 | m_TestConfigUrl:
10 | m_TestInitMode: 0
11 | CrashReportingSettings:
12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes
13 | m_Enabled: 0
14 | m_CaptureEditorExceptions: 1
15 | UnityPurchasingSettings:
16 | m_Enabled: 0
17 | m_TestMode: 0
18 | UnityAnalyticsSettings:
19 | m_Enabled: 1
20 | m_InitializeOnStartup: 1
21 | m_TestMode: 0
22 | m_TestEventUrl:
23 | m_TestConfigUrl:
24 | UnityAdsSettings:
25 | m_Enabled: 0
26 | m_InitializeOnStartup: 1
27 | m_TestMode: 0
28 | m_EnabledPlatforms: 4294967295
29 | m_IosGameId:
30 | m_AndroidGameId:
31 | PerformanceReportingSettings:
32 | m_Enabled: 0
33 |
--------------------------------------------------------------------------------
/Assets/Shaders/NoiseWave.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/NoiseWave"
2 | {
3 | Properties
4 | {
5 | _MainTex("CurTex", 2D) = "white" {}
6 | _PreTex("PreTex", 2D) = "white" {}
7 | _WaveParams("WaveParams", vector) = (0,0,0,0)
8 | }
9 |
10 | SubShader
11 | {
12 | Cull Off ZWrite Off ZTest Always
13 |
14 | Pass
15 | {
16 | CGPROGRAM
17 | #pragma vertex vert
18 | #pragma fragment frag
19 |
20 | #include "UnityCG.cginc"
21 | #include "internal.cginc"
22 | struct appdata
23 | {
24 | float4 vertex : POSITION;
25 | float2 uv : TEXCOORD0;
26 | };
27 |
28 | struct v2f
29 | {
30 | float2 uv : TEXCOORD0;
31 | float4 vertex : SV_POSITION;
32 | };
33 |
34 | sampler2D _MainTex;
35 | sampler2D _PreTex;
36 | float4 _WaveParams;
37 |
38 | v2f vert(appdata v)
39 | {
40 | v2f o;
41 | o.vertex = UnityObjectToClipPos(v.vertex);
42 | o.uv = v.uv;
43 | return o;
44 | }
45 |
46 | float4 frag(v2f i) : SV_Target
47 | {
48 | float cur = DecodeHeight(tex2D(_MainTex, i.uv));
49 | return EncodeHeight(cur);
50 | }
51 | ENDCG
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall01_Diffuse.tga.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 31095fb6a0fed0d4a95df9481df488bc
3 | TextureImporter:
4 | serializedVersion: 2
5 | mipmaps:
6 | mipMapMode: 0
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 | seamlessCubemap: 0
23 | textureFormat: -1
24 | maxTextureSize: 1024
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 | spritePixelsToUnits: 100
39 | alphaIsTransparency: 0
40 | textureType: -1
41 | buildTargetSettings: []
42 | spriteSheet:
43 | sprites: []
44 | spritePackingTag:
45 | userData:
46 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall01_Normal.tga.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3d0d84a5055f7fb40bf71a422c7b3cc6
3 | TextureImporter:
4 | serializedVersion: 2
5 | mipmaps:
6 | mipMapMode: 0
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: -1
24 | maxTextureSize: 1024
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 | spritePixelsToUnits: 100
39 | alphaIsTransparency: 0
40 | textureType: 1
41 | buildTargetSettings: []
42 | spriteSheet:
43 | sprites: []
44 | spritePackingTag:
45 | userData:
46 |
--------------------------------------------------------------------------------
/Assets/Shaders/SineWave.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/SineWave"
2 | {
3 | Properties
4 | {
5 | _MainTex ("CurTex", 2D) = "white" {}
6 | _PreTex("PreTex", 2D) = "white" {}
7 | _WaveParams("WaveParams", vector) = (0,0,0,0)
8 | }
9 | SubShader
10 | {
11 | Cull Off ZWrite Off ZTest Always
12 |
13 | Pass
14 | {
15 | CGPROGRAM
16 | #pragma vertex vert
17 | #pragma fragment frag
18 |
19 | #include "UnityCG.cginc"
20 | #include "internal.cginc"
21 | struct appdata
22 | {
23 | float4 vertex : POSITION;
24 | float2 uv : TEXCOORD0;
25 | };
26 |
27 | struct v2f
28 | {
29 | float2 uv : TEXCOORD0;
30 | float4 vertex : SV_POSITION;
31 | };
32 |
33 | sampler2D _MainTex;
34 | sampler2D _PreTex;
35 | float4 _WaveParams;
36 | float4 _MainTex_TexelSize;
37 | float2 _WaveOrigin;
38 | float _Timer;
39 | v2f vert (appdata v)
40 | {
41 | v2f o;
42 | o.vertex = UnityObjectToClipPos(v.vertex);
43 | o.uv = v.uv;
44 | return o;
45 | }
46 |
47 | float4 frag (v2f i) : SV_Target
48 | {
49 |
50 | float cur = DecodeHeight(tex2D(_MainTex, i.uv));
51 | cur += _WaveParams.x * sin(dot(_WaveParams.yz,i.uv - _WaveOrigin) + _Timer * _WaveParams.w);
52 |
53 | return EncodeHeight(cur);
54 | }
55 | ENDCG
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Assets/Shaders/Caustic.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/Caustic"
2 | {
3 | Properties
4 | {
5 | _Refract("Refract", float) = 0.1
6 | }
7 | SubShader
8 | {
9 | Tags { "RenderType"="Opaque" }
10 |
11 | Pass
12 | {
13 | cull front
14 | CGPROGRAM
15 | #pragma vertex vert
16 | #pragma fragment frag
17 |
18 | #include "UnityCG.cginc"
19 | #include "internal.cginc"
20 |
21 | struct appdata
22 | {
23 | float4 vertex : POSITION;
24 | };
25 |
26 | struct v2f
27 | {
28 | float4 vertex : SV_POSITION;
29 | float2 oldPos : TEXCOORD1;
30 | float2 newPos : TEXCOORD2;
31 | };
32 |
33 | half _Refract;
34 |
35 | v2f vert (appdata v)
36 | {
37 | v2f o;
38 | float3 normal = UnpackNormal(tex2Dlod(_WaterNormalMap, float4(v.texcoord.xy, 0, 0)));
39 |
40 | o.oldPos = v.vertex.xz;
41 | v.vertex.xz += normal.xy*_Refract;
42 | o.newPos = v.vertex.xz;
43 |
44 | o.vertex = UnityObjectToClipPos(v.vertex);
45 | return o;
46 | }
47 |
48 | float4 frag (v2f i) : SV_Target
49 | {
50 | float oldArea = length(ddx(i.oldPos)) * length(ddy(i.oldPos));
51 | float newArea = length(ddx(i.newPos)) * length(ddy(i.newPos));
52 |
53 | float area = (oldArea / newArea) * 0.5;
54 |
55 | return float4(area, area, area, 1);
56 | }
57 | ENDCG
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Assets/Shaders/SineWaveDeform.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/SineWaveDeform"
2 | {
3 | Properties
4 | {
5 | _MainTex ("CurTex", 2D) = "white" {}
6 | _PreTex("PreTex", 2D) = "white" {}
7 | _WaveParams("WaveParams", vector) = (0,0,0,0)
8 | }
9 | SubShader
10 | {
11 | Cull Off ZWrite Off ZTest Always
12 |
13 | Pass
14 | {
15 | CGPROGRAM
16 | #pragma vertex vert
17 | #pragma fragment frag
18 |
19 | #include "UnityCG.cginc"
20 | #include "internal.cginc"
21 | struct appdata
22 | {
23 | float4 vertex : POSITION;
24 | float2 uv : TEXCOORD0;
25 | };
26 |
27 | struct v2f
28 | {
29 | float2 uv : TEXCOORD0;
30 | float4 vertex : SV_POSITION;
31 | };
32 |
33 | sampler2D _MainTex;
34 | sampler2D _PreTex;
35 | float4 _WaveParams;
36 | float4 _MainTex_TexelSize;
37 | float2 _WaveOrigin;
38 | float _Timer;
39 | float k;
40 | v2f vert (appdata v)
41 | {
42 | v2f o;
43 | o.vertex = UnityObjectToClipPos(v.vertex);
44 | o.uv = v.uv;
45 | return o;
46 | }
47 |
48 | float4 frag (v2f i) : SV_Target
49 | {
50 |
51 | float cur = DecodeHeight(tex2D(_MainTex, i.uv));
52 | float t = dot(_WaveParams.yz,i.uv - _WaveOrigin) + _Timer * _WaveParams.w;
53 | cur += _WaveParams.x * 2 * pow( (sin(t) + 1)/2 , k) ;
54 |
55 | return EncodeHeight(cur);
56 | }
57 | ENDCG
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Assets/Scripts/IWaveComponent.cs:
--------------------------------------------------------------------------------
1 |
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace LinHowe
6 | {
7 | ///
8 | /// 波形组件枚举
9 | ///
10 | public enum WaveComponentEnum
11 | {
12 | WaveEquation,
13 | SineWave,
14 | SineWaveDeform,
15 | GerstnerWave,
16 | NoiseWave
17 | }
18 | ///
19 | /// 水体波动组件
20 | ///
21 | public abstract class IWaveComponent
22 | {
23 | protected WaterRender.WaterSurface water;
24 | public IWaveComponent(WaterRender.WaterSurface water)
25 | {
26 | this.water = water;
27 | }
28 | ///
29 | /// 初始化检测
30 | ///
31 | /// 波速
32 | /// 水体粘度系数
33 | /// 水体网格单元间隔
34 | ///
35 | public abstract bool InitAndCheckWaveParams(float speed, float viscosity,float d);
36 |
37 | public abstract void OnRenderImage(RenderTexture src, RenderTexture dst,Material waveEquationMat);
38 |
39 | public virtual void InitWaterCamera(int texSize,Material waveEquationMat) { }
40 |
41 | public virtual void OnDestroy() { }
42 |
43 | public virtual void OnPostRender() { }
44 | }
45 |
46 |
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall02_Diffuse.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: deb661f5d7075460e967c992467b67e6
3 | timeCreated: 1444308790
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 0
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 0
20 | heightScale: .25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 8
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | spriteMode: 0
41 | spriteExtrude: 1
42 | spriteMeshType: 1
43 | alignment: 0
44 | spritePivot: {x: .5, y: .5}
45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
46 | spritePixelsToUnits: 100
47 | alphaIsTransparency: 0
48 | textureType: -1
49 | buildTargetSettings: []
50 | spriteSheet:
51 | sprites: []
52 | spritePackingTag:
53 | userData:
54 | assetBundleName:
55 | assetBundleVariant:
56 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall02_Normal.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0bb49ed3238f54c80b8b0bcc14b68d1e
3 | timeCreated: 1444308788
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 1
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 1
20 | heightScale: .25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 8
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | spriteMode: 0
41 | spriteExtrude: 1
42 | spriteMeshType: 1
43 | alignment: 0
44 | spritePivot: {x: .5, y: .5}
45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
46 | spritePixelsToUnits: 100
47 | alphaIsTransparency: 0
48 | textureType: 1
49 | buildTargetSettings: []
50 | spriteSheet:
51 | sprites: []
52 | spritePackingTag:
53 | userData:
54 | assetBundleName:
55 | assetBundleVariant:
56 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall03_Diffuse.jpg.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 77c0052bfe0214fb5ae5bfe242913675
3 | timeCreated: 1444294655
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 0
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 0
20 | heightScale: .25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 8
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | spriteMode: 0
41 | spriteExtrude: 1
42 | spriteMeshType: 1
43 | alignment: 0
44 | spritePivot: {x: .5, y: .5}
45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
46 | spritePixelsToUnits: 100
47 | alphaIsTransparency: 0
48 | textureType: -1
49 | buildTargetSettings: []
50 | spriteSheet:
51 | sprites: []
52 | spritePackingTag:
53 | userData:
54 | assetBundleName:
55 | assetBundleVariant:
56 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall03_Normal.jpg.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 731999a1749fa4f438a684f0f96e3b14
3 | timeCreated: 1444293857
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 1
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 1
20 | heightScale: .25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 8
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | spriteMode: 0
41 | spriteExtrude: 1
42 | spriteMeshType: 1
43 | alignment: 0
44 | spritePivot: {x: .5, y: .5}
45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
46 | spritePixelsToUnits: 100
47 | alphaIsTransparency: 0
48 | textureType: 1
49 | buildTargetSettings: []
50 | spriteSheet:
51 | sprites: []
52 | spritePackingTag:
53 | userData:
54 | assetBundleName:
55 | assetBundleVariant:
56 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall04_Diffuse.jpg.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1d21281d12c94442e8cd5a05f93f7bd2
3 | timeCreated: 1444293856
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 0
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 0
20 | heightScale: .25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 8
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | spriteMode: 0
41 | spriteExtrude: 1
42 | spriteMeshType: 1
43 | alignment: 0
44 | spritePivot: {x: .5, y: .5}
45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
46 | spritePixelsToUnits: 100
47 | alphaIsTransparency: 0
48 | textureType: -1
49 | buildTargetSettings: []
50 | spriteSheet:
51 | sprites: []
52 | spritePackingTag:
53 | userData:
54 | assetBundleName:
55 | assetBundleVariant:
56 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall05_Diffuse.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9bd4d6fe5f5c64ffab9c30257a7ec792
3 | timeCreated: 1444308868
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 0
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 0
20 | heightScale: .25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 8
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | spriteMode: 0
41 | spriteExtrude: 1
42 | spriteMeshType: 1
43 | alignment: 0
44 | spritePivot: {x: .5, y: .5}
45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
46 | spritePixelsToUnits: 100
47 | alphaIsTransparency: 0
48 | textureType: -1
49 | buildTargetSettings: []
50 | spriteSheet:
51 | sprites: []
52 | spritePackingTag:
53 | userData:
54 | assetBundleName:
55 | assetBundleVariant:
56 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Wall05_Normal.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c111e8298665641daabbc4bfaee19565
3 | timeCreated: 1444308869
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 1
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 1
20 | heightScale: .25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 8
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | spriteMode: 0
41 | spriteExtrude: 1
42 | spriteMeshType: 1
43 | alignment: 0
44 | spritePivot: {x: .5, y: .5}
45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
46 | spritePixelsToUnits: 100
47 | alphaIsTransparency: 0
48 | textureType: 1
49 | buildTargetSettings: []
50 | spriteSheet:
51 | sprites: []
52 | spritePackingTag:
53 | userData:
54 | assetBundleName:
55 | assetBundleVariant:
56 |
--------------------------------------------------------------------------------
/Assets/Shaders/internal.cginc:
--------------------------------------------------------------------------------
1 | #ifndef INTERNAL_CGINC
2 | #define INTERNAL_CGINC
3 |
4 | //SunLight.cs
5 | float4 internalWorldLightPos;
6 | float4 internalWorldLightDir;
7 | float4 internalWorldLightColor;
8 | float4x4 internalWorldLightMV;
9 | float4x4 internalWorldLightVP;
10 | float4 internalProjectionParams;
11 | float internalBias;
12 | sampler2D internalShadowMap;
13 |
14 | //WaterCamera.cs
15 | sampler2D _WaterHeightMap;
16 | sampler2D _WaterNormalMap;
17 |
18 | //GerstnerWave_Component.cs
19 | sampler2D _WaterOffsetXMap;
20 | sampler2D _WaterOffsetZMap;
21 |
22 | //WaterBody.cs
23 | float4 _BoundingBoxMin;
24 | float4 _BoundingBoxMax;
25 |
26 | //WaterSurface.cs
27 | sampler2D _WaveMap;
28 | float4 _WaveMap_ST;
29 |
30 | float Clip(float3 worldPos)
31 | {
32 | if (worldPos.x < _BoundingBoxMin.x || worldPos.x > _BoundingBoxMax.x)
33 | return 0;
34 | if (worldPos.y < _BoundingBoxMin.y || worldPos.y > _BoundingBoxMax.y)
35 | return 0;
36 | if (worldPos.z < _BoundingBoxMin.z || worldPos.z > _BoundingBoxMax.z)
37 | return 0;
38 | return 1;
39 | }
40 | float DecodeHeight(float4 rgba)
41 | {
42 | float d1 = DecodeFloatRG(rgba.rg);
43 | float d2 = DecodeFloatRG(rgba.ba);
44 |
45 | if (d1 >= d2)
46 | return d1;
47 | else
48 | return -d2;
49 | }
50 |
51 | float4 EncodeHeight(float height) {
52 | float2 rg = EncodeFloatRG(height >= 0 ? height : 0);
53 | float2 ba = EncodeFloatRG(height < 0 ? -height : 0);
54 |
55 | return float4(rg, ba);
56 | }
57 |
58 | #endif
--------------------------------------------------------------------------------
/ProjectSettings/Physics2DSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!19 &1
4 | Physics2DSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 3
7 | m_Gravity: {x: 0, y: -9.81}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_VelocityIterations: 8
10 | m_PositionIterations: 3
11 | m_VelocityThreshold: 1
12 | m_MaxLinearCorrection: 0.2
13 | m_MaxAngularCorrection: 8
14 | m_MaxTranslationSpeed: 100
15 | m_MaxRotationSpeed: 360
16 | m_BaumgarteScale: 0.2
17 | m_BaumgarteTimeOfImpactScale: 0.75
18 | m_TimeToSleep: 0.5
19 | m_LinearSleepTolerance: 0.01
20 | m_AngularSleepTolerance: 2
21 | m_DefaultContactOffset: 0.01
22 | m_QueriesHitTriggers: 1
23 | m_QueriesStartInColliders: 1
24 | m_ChangeStopsCallbacks: 0
25 | m_CallbacksOnDisable: 1
26 | m_AlwaysShowColliders: 0
27 | m_ShowColliderSleep: 1
28 | m_ShowColliderContacts: 0
29 | m_ShowColliderAABB: 0
30 | m_ContactArrowScale: 0.2
31 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412}
32 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
33 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
34 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
35 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
36 |
--------------------------------------------------------------------------------
/Assets/Shaders/WaveEquation.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/WaveEquation"
2 | {
3 | Properties
4 | {
5 | _MainTex ("CurTex", 2D) = "white" {}
6 | _PreTex("PreTex", 2D) = "white" {}
7 | _WaveParams("WaveParams", vector) = (0,0,0,0)
8 | }
9 | SubShader
10 | {
11 | Cull Off ZWrite Off ZTest Always
12 |
13 | Pass
14 | {
15 | CGPROGRAM
16 | #pragma vertex vert
17 | #pragma fragment frag
18 |
19 | #include "UnityCG.cginc"
20 | #include "internal.cginc"
21 | struct appdata
22 | {
23 | float4 vertex : POSITION;
24 | float2 uv : TEXCOORD0;
25 | };
26 |
27 | struct v2f
28 | {
29 | float2 uv : TEXCOORD0;
30 | float4 vertex : SV_POSITION;
31 | };
32 |
33 | sampler2D _MainTex;
34 | sampler2D _PreTex;
35 | float4 _WaveParams;
36 |
37 | v2f vert (appdata v)
38 | {
39 | v2f o;
40 | o.vertex = UnityObjectToClipPos(v.vertex);
41 | o.uv = v.uv;
42 | return o;
43 | }
44 |
45 | float4 frag (v2f i) : SV_Target
46 | {
47 | float cur = _WaveParams.x*DecodeHeight(tex2D(_MainTex, i.uv));
48 | float rg = _WaveParams.z*
49 | (
50 | DecodeHeight(tex2D(_MainTex, i.uv + float2(_WaveParams.w, 0))) +
51 | DecodeHeight(tex2D(_MainTex, i.uv + float2(-_WaveParams.w,0))) +
52 | DecodeHeight(tex2D(_MainTex, i.uv + float2(0, _WaveParams.w))) +
53 | DecodeHeight(tex2D(_MainTex, i.uv + float2(0,-_WaveParams.w)))
54 | );
55 | float pre = _WaveParams.y*DecodeHeight(tex2D(_PreTex, i.uv));
56 | cur += rg + pre;
57 | cur *= 0.95;
58 | return EncodeHeight(cur);
59 | }
60 | ENDCG
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Assets/Shaders/NoiseNoramlGenerate.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/NoiseNoramlGenerate"
2 | {
3 | Properties
4 | {
5 | _MainTex ("Texture", 2D) = "white" {}
6 | }
7 | SubShader
8 | {
9 | Cull Off ZWrite Off ZTest Always
10 |
11 | Pass
12 | {
13 | CGPROGRAM
14 | #pragma vertex vert
15 | #pragma fragment frag
16 |
17 | #include "UnityCG.cginc"
18 | #include "internal.cginc"
19 |
20 | #pragma multi_compile NoiseWave Other
21 | struct appdata
22 | {
23 | float4 vertex : POSITION;
24 | float2 uv : TEXCOORD0;
25 | };
26 |
27 | struct v2f
28 | {
29 | float2 uv : TEXCOORD0;
30 | float4 vertex : SV_POSITION;
31 | };
32 |
33 | v2f vert(appdata v)
34 | {
35 | v2f o;
36 | o.vertex = UnityObjectToClipPos(v.vertex);
37 | o.uv = v.uv;
38 | return o;
39 | }
40 |
41 | sampler2D _MainTex;
42 | float4 _MainTex_TexelSize;//Vector4(1 / width, 1 / height, width, height)
43 |
44 | float4 frag (v2f i) : SV_Target
45 | {
46 | float2 speed = _Time.y * float2(0.05f, 0.05f);
47 |
48 | float2 uv = TRANSFORM_TEX(i.uv, _WaveMap);;
49 | float3 bump1 = UnpackNormal(tex2D(_WaveMap, uv + speed)).rgb;
50 | float3 bump2 = UnpackNormal(tex2D(_WaveMap, uv - speed)).rgb;
51 | float3 normal = normalize(bump1 + bump2);
52 | #if defined(UNITY_NO_DXT5nm)
53 | return float4(normal*0.5 + 0.5, 1.0);
54 | #else
55 | #if UNITY_VERSION > 2018
56 | return float4(normal.x*0.5 + 0.5, normal.y*0.5 + 0.5, 0, 1); //2018修改了法线压缩方式,增加了一种BC5压缩
57 | #else
58 | return float4(0, normal.y*0.5 + 0.5, 0, normal.x*0.5 + 0.5);
59 | #endif
60 | #endif
61 | }
62 | ENDCG
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/ProjectSettings/NavMeshAreas.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!126 &1
4 | NavMeshProjectSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | areas:
8 | - name: Walkable
9 | cost: 1
10 | - name: Not Walkable
11 | cost: 1
12 | - name: Jump
13 | cost: 2
14 | - name:
15 | cost: 1
16 | - name:
17 | cost: 1
18 | - name:
19 | cost: 1
20 | - name:
21 | cost: 1
22 | - name:
23 | cost: 1
24 | - name:
25 | cost: 1
26 | - name:
27 | cost: 1
28 | - name:
29 | cost: 1
30 | - name:
31 | cost: 1
32 | - name:
33 | cost: 1
34 | - name:
35 | cost: 1
36 | - name:
37 | cost: 1
38 | - name:
39 | cost: 1
40 | - name:
41 | cost: 1
42 | - name:
43 | cost: 1
44 | - name:
45 | cost: 1
46 | - name:
47 | cost: 1
48 | - name:
49 | cost: 1
50 | - name:
51 | cost: 1
52 | - name:
53 | cost: 1
54 | - name:
55 | cost: 1
56 | - name:
57 | cost: 1
58 | - name:
59 | cost: 1
60 | - name:
61 | cost: 1
62 | - name:
63 | cost: 1
64 | - name:
65 | cost: 1
66 | - name:
67 | cost: 1
68 | - name:
69 | cost: 1
70 | - name:
71 | cost: 1
72 | m_LastAgentTypeID: -887442657
73 | m_Settings:
74 | - serializedVersion: 2
75 | agentTypeID: 0
76 | agentRadius: 0.5
77 | agentHeight: 2
78 | agentSlope: 45
79 | agentClimb: 0.75
80 | ledgeDropHeight: 0
81 | maxJumpAcrossDistance: 0
82 | minRegionArea: 2
83 | manualCellSize: 0
84 | cellSize: 0.16666667
85 | manualTileSize: 0
86 | tileSize: 256
87 | accuratePlacement: 0
88 | m_SettingNames:
89 | - Humanoid
90 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/Object.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using LinHowe.WaterRender;
5 |
6 | namespace LinHowe
7 | {
8 | ///
9 | /// 与水交互的物体
10 | ///
11 | [RequireComponent(typeof(Collider))]
12 | public class Object : MonoBehaviour
13 | {
14 | public List waterSurfacesList;
15 |
16 | protected Renderer m_Renderer;
17 | protected Matrix4x4 m_LocalMatrix;
18 | protected float heightOffset;//最高点
19 | protected Collider m_Collider;
20 | protected Bounds m_Bounds;
21 | protected void Start()
22 | {
23 | m_Renderer = gameObject.GetComponent();
24 | m_LocalMatrix = transform.localToWorldMatrix;
25 | m_Collider = GetComponent();
26 | m_Bounds = m_Collider.bounds;
27 | heightOffset = m_Bounds.size.y / 2 + m_Bounds.center.y - transform.position.y + 0.05f;
28 | Init();
29 | }
30 | protected virtual void Init()
31 | {
32 |
33 | }
34 | protected void OnRenderObject()
35 | {
36 | if (m_Renderer && m_LocalMatrix != transform.localToWorldMatrix)
37 | {
38 | m_LocalMatrix = transform.localToWorldMatrix;
39 | foreach(WaterSurface water in waterSurfacesList)
40 | {
41 | if(transform.position.y + heightOffset > water.transform.position.y)
42 | {
43 | water.DrawObject(m_Renderer);
44 | }
45 |
46 | }
47 |
48 | }
49 | }
50 |
51 |
52 | }
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/Assets/Shaders/NormalGenerate.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/NormalGenerate"
2 | {
3 | Properties
4 | {
5 | _MainTex ("Texture", 2D) = "white" {}
6 | }
7 | SubShader
8 | {
9 | Cull Off ZWrite Off ZTest Always
10 |
11 | Pass
12 | {
13 | CGPROGRAM
14 | #pragma vertex vert
15 | #pragma fragment frag
16 |
17 | #include "UnityCG.cginc"
18 | #include "internal.cginc"
19 |
20 | #pragma multi_compile NoiseWave Other
21 | struct appdata
22 | {
23 | float4 vertex : POSITION;
24 | float2 uv : TEXCOORD0;
25 | };
26 |
27 | struct v2f
28 | {
29 | float2 uv : TEXCOORD0;
30 | float4 vertex : SV_POSITION;
31 | };
32 |
33 | v2f vert(appdata v)
34 | {
35 | v2f o;
36 | o.vertex = UnityObjectToClipPos(v.vertex);
37 | o.uv = v.uv;
38 | return o;
39 | }
40 |
41 | sampler2D _MainTex;
42 | float4 _MainTex_TexelSize;//Vector4(1 / width, 1 / height, width, height)
43 |
44 | float4 frag (v2f i) : SV_Target
45 | {
46 | float lh = DecodeHeight(tex2D(_MainTex, i.uv + float2(-_MainTex_TexelSize.x, 0.0)));
47 | float rh = DecodeHeight(tex2D(_MainTex, i.uv + float2(_MainTex_TexelSize.x, 0.0)));
48 | float bh = DecodeHeight(tex2D(_MainTex, i.uv + float2(0.0, -_MainTex_TexelSize.y)));
49 | float th = DecodeHeight(tex2D(_MainTex, i.uv + float2(0.0, _MainTex_TexelSize.y)));
50 | float3 normal = normalize(float3(lh - rh, bh - th, 5.0*_MainTex_TexelSize.x));
51 | #if defined(UNITY_NO_DXT5nm)
52 | return float4(normal*0.5 + 0.5, 1.0);
53 | #else
54 | #if UNITY_VERSION > 2018
55 | return float4(normal.x*0.5 + 0.5, normal.y*0.5 + 0.5, 0, 1); //2018修改了法线压缩方式,增加了一种BC5压缩
56 | #else
57 | return float4(0, normal.y*0.5 + 0.5, 0, normal.x*0.5 + 0.5);
58 | #endif
59 | #endif
60 | }
61 | ENDCG
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Assets/Shaders/GerstnerWave.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/GerstnerWave"
2 | {
3 | Properties
4 | {
5 | _MainTex ("CurTex", 2D) = "white" {}
6 | _PreTex("PreTex", 2D) = "white" {}
7 | _WaveParams("WaveParams", vector) = (0,0,0,0)
8 | }
9 | SubShader
10 | {
11 | Cull Off ZWrite Off ZTest Always
12 |
13 | Pass
14 | {
15 | CGPROGRAM
16 | #pragma vertex vert
17 | #pragma fragment frag
18 |
19 | #include "UnityCG.cginc"
20 | #include "internal.cginc"
21 | struct appdata
22 | {
23 | float4 vertex : POSITION;
24 | float2 uv : TEXCOORD0;
25 | };
26 |
27 | struct v2f
28 | {
29 | float2 uv : TEXCOORD0;
30 | float4 vertex : SV_POSITION;
31 | };
32 |
33 | sampler2D _MainTex;
34 | sampler2D _PreTex;
35 | float4 _WaveParams;
36 | float4 _MainTex_TexelSize;
37 | float2 _WaveOrigin;
38 | float _Timer;
39 | float Qi;
40 | v2f vert (appdata v)
41 | {
42 | v2f o;
43 | o.vertex = UnityObjectToClipPos(v.vertex);
44 | o.uv = v.uv;
45 | return o;
46 | }
47 |
48 | float4 frag (v2f i) : SV_Target
49 | {
50 | float t = dot(_WaveParams.yz,i.uv - _WaveOrigin) + _Timer * _WaveParams.w;
51 | Qi = 1 / _WaveParams.w / _WaveParams.x;
52 | #if GenerateGerstnerOffsetX
53 | float offset = DecodeHeight(tex2D(_WaterOffsetXMap, float4(i.uv,0,0)));
54 | offset += _WaveParams.x / _WaveParams.w * Qi * dot(_WaveParams.yz,float2((i.uv - _WaveOrigin).x,0)) * cos(t) ;
55 | return EncodeHeight(offset);
56 | #elif GenerateGerstnerOffsetZ
57 | float offset = DecodeHeight(tex2D(_WaterOffsetZMap, float4(i.uv,0,0)));
58 | offset += _WaveParams.x / _WaveParams.w * Qi * dot(_WaveParams.yz,float2(0,(i.uv - _WaveOrigin).y)) * cos(t) ;
59 | return EncodeHeight(offset);
60 | #else
61 | float cur = DecodeHeight(tex2D(_MainTex, i.uv));
62 | cur += _WaveParams.x * sin(t);
63 | return EncodeHeight(cur);
64 | #endif
65 |
66 | }
67 | ENDCG
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/TestForceToWater.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 | using LinHowe.WaterRender;
5 |
6 | namespace LinHowe.WaveEquation
7 | {
8 |
9 | public class TestForceToWater : MonoBehaviour
10 | {
11 |
12 |
13 | public WaterSurface water;//水面
14 | public float swipeSize;
15 | public Mesh swipeMesh;
16 | public float height, force;
17 | private bool IsBeginDrag;
18 | private Camera MainCamera;
19 | private void Start()
20 | {
21 | MainCamera = GameObject.FindGameObjectWithTag("MainCamera")
22 | .GetComponent();
23 | }
24 | private void Update()
25 | {
26 | Shader.SetGlobalFloat("internal_Force", force);
27 |
28 | if (Input.GetMouseButton(0))
29 | {
30 | Ray ray = MainCamera.ScreenPointToRay(Input.mousePosition);
31 | RaycastHit hit;
32 | if (!IsBeginDrag)
33 | {
34 | if (Physics.Raycast(ray, out hit))
35 | {
36 | if (hit.collider.gameObject == water.gameObject)
37 | {
38 | float t = (height -
39 | Vector3.Dot(ray.origin, Vector3.up)) /
40 | Vector3.Dot(ray.direction, Vector3.up);
41 | Vector3 hitpos = ray.origin + ray.direction * t;
42 | Matrix4x4 matrix = Matrix4x4.TRS(hitpos, Quaternion.identity, Vector3.one * swipeSize);
43 | if (water && water.enabled) water.DrawMesh(swipeMesh, matrix);
44 | }
45 | }
46 | }
47 | }
48 |
49 | if (Input.GetMouseButtonUp(0))
50 | {
51 | IsBeginDrag = false;
52 | }
53 | }
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/SkyBox/sky.psd.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fde800138f4b6f449863727b84958248
3 | timeCreated: 1523352074
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | externalObjects: {}
8 | serializedVersion: 4
9 | mipmaps:
10 | mipMapMode: 0
11 | enableMipMap: 1
12 | sRGBTexture: 1
13 | linearTexture: 0
14 | fadeOut: 0
15 | borderMipMap: 0
16 | mipMapsPreserveCoverage: 0
17 | alphaTestReferenceValue: 0.5
18 | mipMapFadeDistanceStart: 1
19 | mipMapFadeDistanceEnd: 3
20 | bumpmap:
21 | convertToNormalMap: 0
22 | externalNormalMap: 0
23 | heightScale: 0.25
24 | normalMapFilter: 0
25 | isReadable: 0
26 | grayScaleToAlpha: 0
27 | generateCubemap: 6
28 | cubemapConvolution: 0
29 | seamlessCubemap: 0
30 | textureFormat: 1
31 | maxTextureSize: 2048
32 | textureSettings:
33 | serializedVersion: 2
34 | filterMode: -1
35 | aniso: -1
36 | mipBias: -1
37 | wrapU: -1
38 | wrapV: -1
39 | wrapW: -1
40 | nPOTScale: 1
41 | lightmap: 0
42 | compressionQuality: 50
43 | spriteMode: 0
44 | spriteExtrude: 1
45 | spriteMeshType: 1
46 | alignment: 0
47 | spritePivot: {x: 0.5, y: 0.5}
48 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
49 | spritePixelsToUnits: 100
50 | alphaUsage: 1
51 | alphaIsTransparency: 0
52 | spriteTessellationDetail: -1
53 | textureType: 0
54 | textureShape: 1
55 | maxTextureSizeSet: 0
56 | compressionQualitySet: 0
57 | textureFormatSet: 0
58 | platformSettings:
59 | - buildTarget: DefaultTexturePlatform
60 | maxTextureSize: 2048
61 | resizeAlgorithm: 0
62 | textureFormat: -1
63 | textureCompression: 1
64 | compressionQuality: 50
65 | crunchedCompression: 0
66 | allowsAlphaSplitting: 0
67 | overridden: 0
68 | androidETC2FallbackOverride: 0
69 | spriteSheet:
70 | serializedVersion: 2
71 | sprites: []
72 | outline: []
73 | physicsShape: []
74 | spritePackingTag:
75 | userData:
76 | assetBundleName:
77 | assetBundleVariant:
78 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/Water_Diffuse.jpg.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dbeabbc7bce59984eb99a72bd4609547
3 | TextureImporter:
4 | fileIDToRecycleName: {}
5 | externalObjects: {}
6 | serializedVersion: 5
7 | mipmaps:
8 | mipMapMode: 0
9 | enableMipMap: 1
10 | sRGBTexture: 1
11 | linearTexture: 0
12 | fadeOut: 0
13 | borderMipMap: 0
14 | mipMapsPreserveCoverage: 0
15 | alphaTestReferenceValue: 0.5
16 | mipMapFadeDistanceStart: 1
17 | mipMapFadeDistanceEnd: 3
18 | bumpmap:
19 | convertToNormalMap: 0
20 | externalNormalMap: 0
21 | heightScale: 0.25
22 | normalMapFilter: 0
23 | isReadable: 0
24 | grayScaleToAlpha: 0
25 | generateCubemap: 6
26 | cubemapConvolution: 0
27 | seamlessCubemap: 0
28 | textureFormat: 1
29 | maxTextureSize: 2048
30 | textureSettings:
31 | serializedVersion: 2
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapU: -1
36 | wrapV: -1
37 | wrapW: -1
38 | nPOTScale: 1
39 | lightmap: 0
40 | compressionQuality: 50
41 | spriteMode: 0
42 | spriteExtrude: 1
43 | spriteMeshType: 1
44 | alignment: 0
45 | spritePivot: {x: 0.5, y: 0.5}
46 | spritePixelsToUnits: 100
47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
48 | spriteGenerateFallbackPhysicsShape: 1
49 | alphaUsage: 1
50 | alphaIsTransparency: 0
51 | spriteTessellationDetail: -1
52 | textureType: 0
53 | textureShape: 1
54 | singleChannelComponent: 0
55 | maxTextureSizeSet: 0
56 | compressionQualitySet: 0
57 | textureFormatSet: 0
58 | platformSettings:
59 | - serializedVersion: 2
60 | buildTarget: DefaultTexturePlatform
61 | maxTextureSize: 2048
62 | resizeAlgorithm: 0
63 | textureFormat: -1
64 | textureCompression: 1
65 | compressionQuality: 50
66 | crunchedCompression: 0
67 | allowsAlphaSplitting: 0
68 | overridden: 0
69 | androidETC2FallbackOverride: 0
70 | spriteSheet:
71 | serializedVersion: 2
72 | sprites: []
73 | outline: []
74 | physicsShape: []
75 | bones: []
76 | spriteID:
77 | vertices: []
78 | indices:
79 | edges: []
80 | weights: []
81 | spritePackingTag:
82 | userData:
83 | assetBundleName:
84 | assetBundleVariant:
85 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/UnityShaderBook/water_noise.jpg.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6190bb5c670d318448ae118edebfee07
3 | TextureImporter:
4 | fileIDToRecycleName: {}
5 | externalObjects: {}
6 | serializedVersion: 5
7 | mipmaps:
8 | mipMapMode: 0
9 | enableMipMap: 1
10 | sRGBTexture: 1
11 | linearTexture: 0
12 | fadeOut: 0
13 | borderMipMap: 0
14 | mipMapsPreserveCoverage: 0
15 | alphaTestReferenceValue: 0.5
16 | mipMapFadeDistanceStart: 1
17 | mipMapFadeDistanceEnd: 3
18 | bumpmap:
19 | convertToNormalMap: 0
20 | externalNormalMap: 0
21 | heightScale: 0.25
22 | normalMapFilter: 0
23 | isReadable: 0
24 | grayScaleToAlpha: 0
25 | generateCubemap: 6
26 | cubemapConvolution: 0
27 | seamlessCubemap: 0
28 | textureFormat: 1
29 | maxTextureSize: 2048
30 | textureSettings:
31 | serializedVersion: 2
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapU: -1
36 | wrapV: -1
37 | wrapW: -1
38 | nPOTScale: 1
39 | lightmap: 0
40 | compressionQuality: 50
41 | spriteMode: 0
42 | spriteExtrude: 1
43 | spriteMeshType: 1
44 | alignment: 0
45 | spritePivot: {x: 0.5, y: 0.5}
46 | spritePixelsToUnits: 100
47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
48 | spriteGenerateFallbackPhysicsShape: 1
49 | alphaUsage: 1
50 | alphaIsTransparency: 0
51 | spriteTessellationDetail: -1
52 | textureType: 0
53 | textureShape: 1
54 | singleChannelComponent: 0
55 | maxTextureSizeSet: 0
56 | compressionQualitySet: 0
57 | textureFormatSet: 0
58 | platformSettings:
59 | - serializedVersion: 2
60 | buildTarget: DefaultTexturePlatform
61 | maxTextureSize: 2048
62 | resizeAlgorithm: 0
63 | textureFormat: -1
64 | textureCompression: 1
65 | compressionQuality: 50
66 | crunchedCompression: 0
67 | allowsAlphaSplitting: 0
68 | overridden: 0
69 | androidETC2FallbackOverride: 0
70 | spriteSheet:
71 | serializedVersion: 2
72 | sprites: []
73 | outline: []
74 | physicsShape: []
75 | bones: []
76 | spriteID:
77 | vertices: []
78 | indices:
79 | edges: []
80 | weights: []
81 | spritePackingTag:
82 | userData:
83 | assetBundleName:
84 | assetBundleVariant:
85 |
--------------------------------------------------------------------------------
/Assets/Material/WaterBody.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: WaterBody
10 | m_Shader: {fileID: 4800000, guid: 27d31f245af67e345a467bef5d69c401, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _BumpMap:
22 | m_Texture: {fileID: 0}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _DetailAlbedoMap:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _DetailMask:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _DetailNormalMap:
34 | m_Texture: {fileID: 0}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | - _EmissionMap:
38 | m_Texture: {fileID: 0}
39 | m_Scale: {x: 1, y: 1}
40 | m_Offset: {x: 0, y: 0}
41 | - _MainTex:
42 | m_Texture: {fileID: 0}
43 | m_Scale: {x: 1, y: 1}
44 | m_Offset: {x: 0, y: 0}
45 | - _MetallicGlossMap:
46 | m_Texture: {fileID: 0}
47 | m_Scale: {x: 1, y: 1}
48 | m_Offset: {x: 0, y: 0}
49 | - _OcclusionMap:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | - _ParallaxMap:
54 | m_Texture: {fileID: 0}
55 | m_Scale: {x: 1, y: 1}
56 | m_Offset: {x: 0, y: 0}
57 | m_Floats:
58 | - _BumpScale: 1
59 | - _Cutoff: 0.5
60 | - _DetailNormalMapScale: 1
61 | - _DstBlend: 0
62 | - _GlossMapScale: 1
63 | - _Glossiness: 0.5
64 | - _GlossyReflections: 1
65 | - _Height: 1
66 | - _Metallic: 0
67 | - _Mode: 0
68 | - _OcclusionStrength: 1
69 | - _Parallax: 0.02
70 | - _RayStep: 64
71 | - _SmoothnessTextureChannel: 0
72 | - _SpecularHighlights: 1
73 | - _SrcBlend: 1
74 | - _UVSec: 0
75 | - _ZWrite: 1
76 | m_Colors:
77 | - _Color: {r: 1, g: 1, b: 1, a: 1}
78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
79 | - _MainColor: {r: 0, g: 0.66896534, b: 1, a: 1}
80 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
3 | # Unity files
4 | *.meta -text -merge=unityamlmerge
5 | *.unity -text -merge=unityamlmerge
6 | *.asset -text -merge=unityamlmerge
7 | *.prefab -text -merge=unityamlmerge
8 |
9 | # Image formats
10 | *.psd filter=lfs diff=lfs merge=lfs -text
11 | *.jpg filter=lfs diff=lfs merge=lfs -text
12 | *.png filter=lfs diff=lfs merge=lfs -text
13 | *.gif filter=lfs diff=lfs merge=lfs -text
14 | *.bmp filter=lfs diff=lfs merge=lfs -text
15 | *.tga filter=lfs diff=lfs merge=lfs -text
16 | *.tiff filter=lfs diff=lfs merge=lfs -text
17 | *.iff filter=lfs diff=lfs merge=lfs -text
18 | *.pict filter=lfs diff=lfs merge=lfs -text
19 | *.dds filter=lfs diff=lfs merge=lfs -text
20 |
21 | # Audio formats
22 | *.mp3 filter=lfs diff=lfs merge=lfs -text
23 | *.ogg filter=lfs diff=lfs merge=lfs -text
24 | *.wav filter=lfs diff=lfs merge=lfs -text
25 | *.aiff filter=lfs diff=lfs merge=lfs -text
26 | *.aif filter=lfs diff=lfs merge=lfs -text
27 | *.mod filter=lfs diff=lfs merge=lfs -text
28 | *.it filter=lfs diff=lfs merge=lfs -text
29 | *.s3m filter=lfs diff=lfs merge=lfs -text
30 | *.xm filter=lfs diff=lfs merge=lfs -text
31 |
32 | # Video formats
33 | *.mov filter=lfs diff=lfs merge=lfs -text
34 | *.avi filter=lfs diff=lfs merge=lfs -text
35 | *.asf filter=lfs diff=lfs merge=lfs -text
36 | *.mpg filter=lfs diff=lfs merge=lfs -text
37 | *.mpeg filter=lfs diff=lfs merge=lfs -text
38 | *.mp4 filter=lfs diff=lfs merge=lfs -text
39 |
40 | # 3D formats
41 | *.fbx filter=lfs diff=lfs merge=lfs -text
42 | *.obj filter=lfs diff=lfs merge=lfs -text
43 | *.max filter=lfs diff=lfs merge=lfs -text
44 | *.blend filter=lfs diff=lfs merge=lfs -text
45 | *.dae filter=lfs diff=lfs merge=lfs -text
46 | *.mb filter=lfs diff=lfs merge=lfs -text
47 | *.ma filter=lfs diff=lfs merge=lfs -text
48 | *.3ds filter=lfs diff=lfs merge=lfs -text
49 | *.dfx filter=lfs diff=lfs merge=lfs -text
50 | *.c4d filter=lfs diff=lfs merge=lfs -text
51 | *.lwo filter=lfs diff=lfs merge=lfs -text
52 | *.lwo2 filter=lfs diff=lfs merge=lfs -text
53 | *.abc filter=lfs diff=lfs merge=lfs -text
54 | *.3dm filter=lfs diff=lfs merge=lfs -text
55 |
56 | # Build
57 | *.dll filter=lfs diff=lfs merge=lfs -text
58 | *.pdb filter=lfs diff=lfs merge=lfs -text
59 | *.mdb filter=lfs diff=lfs merge=lfs -text
60 |
61 | # Packaging
62 | *.zip filter=lfs diff=lfs merge=lfs -text
63 | *.7z filter=lfs diff=lfs merge=lfs -text
64 | *.gz filter=lfs diff=lfs merge=lfs -text
65 | *.rar filter=lfs diff=lfs merge=lfs -text
66 | *.tar filter=lfs diff=lfs merge=lfs -text
--------------------------------------------------------------------------------
/ProjectSettings/GraphicsSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!30 &1
4 | GraphicsSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 12
7 | m_Deferred:
8 | m_Mode: 1
9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
10 | m_DeferredReflections:
11 | m_Mode: 1
12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
13 | m_ScreenSpaceShadows:
14 | m_Mode: 1
15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0}
16 | m_LegacyDeferred:
17 | m_Mode: 1
18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
19 | m_DepthNormals:
20 | m_Mode: 1
21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0}
22 | m_MotionVectors:
23 | m_Mode: 1
24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0}
25 | m_LightHalo:
26 | m_Mode: 1
27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0}
28 | m_LensFlare:
29 | m_Mode: 1
30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0}
31 | m_AlwaysIncludedShaders:
32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0}
34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0}
35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
38 | - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
39 | m_PreloadedShaders: []
40 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
41 | type: 0}
42 | m_CustomRenderPipeline: {fileID: 0}
43 | m_TransparencySortMode: 0
44 | m_TransparencySortAxis: {x: 0, y: 0, z: 1}
45 | m_DefaultRenderingPath: 1
46 | m_DefaultMobileRenderingPath: 1
47 | m_TierSettings: []
48 | m_LightmapStripping: 0
49 | m_FogStripping: 0
50 | m_InstancingStripping: 0
51 | m_LightmapKeepPlain: 1
52 | m_LightmapKeepDirCombined: 1
53 | m_LightmapKeepDynamicPlain: 1
54 | m_LightmapKeepDynamicDirCombined: 1
55 | m_LightmapKeepShadowMask: 1
56 | m_LightmapKeepSubtractive: 1
57 | m_FogKeepLinear: 1
58 | m_FogKeepExp: 1
59 | m_FogKeepExp2: 1
60 | m_AlbedoSwatchInfos: []
61 | m_LightsUseLinearIntensity: 0
62 | m_LightsUseColorTemperature: 0
63 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/SkyBox/skybox.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: skybox
10 | m_Shader: {fileID: 103, guid: 0000000000000000f000000000000000, type: 0}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 5
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: 1000
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _BumpMap:
22 | m_Texture: {fileID: 0}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _DetailAlbedoMap:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _DetailMask:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _DetailNormalMap:
34 | m_Texture: {fileID: 0}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | - _EmissionMap:
38 | m_Texture: {fileID: 0}
39 | m_Scale: {x: 1, y: 1}
40 | m_Offset: {x: 0, y: 0}
41 | - _MainTex:
42 | m_Texture: {fileID: 2800000, guid: 566cada353cad2441ba7b045c8ea1a79, type: 3}
43 | m_Scale: {x: 1, y: 1}
44 | m_Offset: {x: 0, y: 0}
45 | - _MetallicGlossMap:
46 | m_Texture: {fileID: 0}
47 | m_Scale: {x: 1, y: 1}
48 | m_Offset: {x: 0, y: 0}
49 | - _OcclusionMap:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | - _ParallaxMap:
54 | m_Texture: {fileID: 0}
55 | m_Scale: {x: 1, y: 1}
56 | m_Offset: {x: 0, y: 0}
57 | - _Tex:
58 | m_Texture: {fileID: 8900000, guid: cc28972a3532dba4c82bf9bed5f68340, type: 3}
59 | m_Scale: {x: 1, y: 1}
60 | m_Offset: {x: 0, y: 0}
61 | m_Floats:
62 | - _BumpScale: 1
63 | - _Cutoff: 0.5
64 | - _DetailNormalMapScale: 1
65 | - _DstBlend: 0
66 | - _Exposure: 1
67 | - _Glossiness: 0.5
68 | - _Metallic: 0
69 | - _Mode: 0
70 | - _OcclusionStrength: 1
71 | - _Parallax: 0.02
72 | - _Rotation: 0
73 | - _SrcBlend: 1
74 | - _UVSec: 0
75 | - _ZWrite: 1
76 | m_Colors:
77 | - _Color: {r: 1, g: 1, b: 1, a: 1}
78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
79 | - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}
80 |
--------------------------------------------------------------------------------
/Assets/Material/Wall01.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: Wall01
10 | m_Shader: {fileID: 4800000, guid: 7de2f293b3b24a44581d81b169f03e47, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _BumpMap:
22 | m_Texture: {fileID: 2800000, guid: 3d0d84a5055f7fb40bf71a422c7b3cc6, type: 3}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _DetailAlbedoMap:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _DetailMask:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _DetailNormalMap:
34 | m_Texture: {fileID: 0}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | - _EmissionMap:
38 | m_Texture: {fileID: 0}
39 | m_Scale: {x: 1, y: 1}
40 | m_Offset: {x: 0, y: 0}
41 | - _MainTex:
42 | m_Texture: {fileID: 2800000, guid: 31095fb6a0fed0d4a95df9481df488bc, type: 3}
43 | m_Scale: {x: 1, y: 1}
44 | m_Offset: {x: 0, y: 0}
45 | - _MetallicGlossMap:
46 | m_Texture: {fileID: 0}
47 | m_Scale: {x: 1, y: 1}
48 | m_Offset: {x: 0, y: 0}
49 | - _OcclusionMap:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | - _ParallaxMap:
54 | m_Texture: {fileID: 0}
55 | m_Scale: {x: 1, y: 1}
56 | m_Offset: {x: 0, y: 0}
57 | m_Floats:
58 | - _BumpScale: 1
59 | - _Cutoff: 0.5
60 | - _DetailNormalMapScale: 1
61 | - _Diffuse: 0
62 | - _DstBlend: 0
63 | - _Gloss: 1
64 | - _GlossMapScale: 1
65 | - _Glossiness: 0.5
66 | - _GlossyReflections: 1
67 | - _Metallic: 0
68 | - _Mode: 0
69 | - _OcclusionStrength: 1
70 | - _Parallax: 0.02
71 | - _SmoothnessTextureChannel: 0
72 | - _Specular: 0
73 | - _SpecularHighlights: 1
74 | - _SrcBlend: 1
75 | - _UVSec: 0
76 | - _ZWrite: 1
77 | m_Colors:
78 | - _Color: {r: 1, g: 1, b: 1, a: 1}
79 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
80 | - _WaterColor: {r: 1, g: 1, b: 1, a: 1}
81 |
--------------------------------------------------------------------------------
/Assets/Material/Wall02.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: Wall02
10 | m_Shader: {fileID: 4800000, guid: 7de2f293b3b24a44581d81b169f03e47, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _BumpMap:
22 | m_Texture: {fileID: 2800000, guid: 0bb49ed3238f54c80b8b0bcc14b68d1e, type: 3}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _DetailAlbedoMap:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _DetailMask:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _DetailNormalMap:
34 | m_Texture: {fileID: 0}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | - _EmissionMap:
38 | m_Texture: {fileID: 0}
39 | m_Scale: {x: 1, y: 1}
40 | m_Offset: {x: 0, y: 0}
41 | - _MainTex:
42 | m_Texture: {fileID: 2800000, guid: deb661f5d7075460e967c992467b67e6, type: 3}
43 | m_Scale: {x: 1, y: 1}
44 | m_Offset: {x: 0, y: 0}
45 | - _MetallicGlossMap:
46 | m_Texture: {fileID: 0}
47 | m_Scale: {x: 1, y: 1}
48 | m_Offset: {x: 0, y: 0}
49 | - _OcclusionMap:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | - _ParallaxMap:
54 | m_Texture: {fileID: 0}
55 | m_Scale: {x: 1, y: 1}
56 | m_Offset: {x: 0, y: 0}
57 | m_Floats:
58 | - _BumpScale: 1
59 | - _Cutoff: 0.5
60 | - _DetailNormalMapScale: 1
61 | - _Diffuse: 0.36
62 | - _DstBlend: 0
63 | - _Gloss: 1
64 | - _GlossMapScale: 1
65 | - _Glossiness: 0.5
66 | - _GlossyReflections: 1
67 | - _Metallic: 0
68 | - _Mode: 0
69 | - _OcclusionStrength: 1
70 | - _Parallax: 0.02
71 | - _SmoothnessTextureChannel: 0
72 | - _Specular: 0
73 | - _SpecularHighlights: 1
74 | - _SrcBlend: 1
75 | - _UVSec: 0
76 | - _ZWrite: 1
77 | m_Colors:
78 | - _Color: {r: 1, g: 1, b: 1, a: 1}
79 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
80 | - _WaterColor: {r: 0.4227483, g: 0.8035137, b: 0.9433962, a: 1}
81 |
--------------------------------------------------------------------------------
/Assets/Material/Wall03.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: Wall03
10 | m_Shader: {fileID: 4800000, guid: 7de2f293b3b24a44581d81b169f03e47, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _BumpMap:
22 | m_Texture: {fileID: 2800000, guid: 731999a1749fa4f438a684f0f96e3b14, type: 3}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _DetailAlbedoMap:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _DetailMask:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _DetailNormalMap:
34 | m_Texture: {fileID: 0}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | - _EmissionMap:
38 | m_Texture: {fileID: 0}
39 | m_Scale: {x: 1, y: 1}
40 | m_Offset: {x: 0, y: 0}
41 | - _MainTex:
42 | m_Texture: {fileID: 2800000, guid: 77c0052bfe0214fb5ae5bfe242913675, type: 3}
43 | m_Scale: {x: 1, y: 1}
44 | m_Offset: {x: 0, y: 0}
45 | - _MetallicGlossMap:
46 | m_Texture: {fileID: 0}
47 | m_Scale: {x: 1, y: 1}
48 | m_Offset: {x: 0, y: 0}
49 | - _OcclusionMap:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | - _ParallaxMap:
54 | m_Texture: {fileID: 0}
55 | m_Scale: {x: 1, y: 1}
56 | m_Offset: {x: 0, y: 0}
57 | m_Floats:
58 | - _BumpScale: 1
59 | - _Cutoff: 0.5
60 | - _DetailNormalMapScale: 1
61 | - _Diffuse: 0.3
62 | - _DstBlend: 0
63 | - _Gloss: 1
64 | - _GlossMapScale: 1
65 | - _Glossiness: 0.5
66 | - _GlossyReflections: 1
67 | - _Metallic: 0
68 | - _Mode: 0
69 | - _OcclusionStrength: 1
70 | - _Parallax: 0.02
71 | - _SmoothnessTextureChannel: 0
72 | - _Specular: 0
73 | - _SpecularHighlights: 1
74 | - _SrcBlend: 1
75 | - _UVSec: 0
76 | - _ZWrite: 1
77 | m_Colors:
78 | - _Color: {r: 1, g: 1, b: 1, a: 1}
79 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
80 | - _WaterColor: {r: 0.42352942, g: 0.8039216, b: 0.94509804, a: 1}
81 |
--------------------------------------------------------------------------------
/Assets/Material/Wall04.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: Wall04
10 | m_Shader: {fileID: 4800000, guid: 7de2f293b3b24a44581d81b169f03e47, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _BumpMap:
22 | m_Texture: {fileID: 2800000, guid: 731999a1749fa4f438a684f0f96e3b14, type: 3}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _DetailAlbedoMap:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _DetailMask:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _DetailNormalMap:
34 | m_Texture: {fileID: 0}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | - _EmissionMap:
38 | m_Texture: {fileID: 0}
39 | m_Scale: {x: 1, y: 1}
40 | m_Offset: {x: 0, y: 0}
41 | - _MainTex:
42 | m_Texture: {fileID: 2800000, guid: 1d21281d12c94442e8cd5a05f93f7bd2, type: 3}
43 | m_Scale: {x: 1, y: 1}
44 | m_Offset: {x: 0, y: 0}
45 | - _MetallicGlossMap:
46 | m_Texture: {fileID: 0}
47 | m_Scale: {x: 1, y: 1}
48 | m_Offset: {x: 0, y: 0}
49 | - _OcclusionMap:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | - _ParallaxMap:
54 | m_Texture: {fileID: 0}
55 | m_Scale: {x: 1, y: 1}
56 | m_Offset: {x: 0, y: 0}
57 | m_Floats:
58 | - _BumpScale: 1
59 | - _Cutoff: 0.5
60 | - _DetailNormalMapScale: 1
61 | - _Diffuse: 0
62 | - _DstBlend: 0
63 | - _Gloss: 1
64 | - _GlossMapScale: 1
65 | - _Glossiness: 0.5
66 | - _GlossyReflections: 1
67 | - _Metallic: 0
68 | - _Mode: 0
69 | - _OcclusionStrength: 1
70 | - _Parallax: 0.02
71 | - _SmoothnessTextureChannel: 0
72 | - _Specular: 0
73 | - _SpecularHighlights: 1
74 | - _SrcBlend: 1
75 | - _UVSec: 0
76 | - _ZWrite: 1
77 | m_Colors:
78 | - _Color: {r: 1, g: 1, b: 1, a: 1}
79 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
80 | - _WaterColor: {r: 0.42352942, g: 0.8039216, b: 0.94509804, a: 1}
81 |
--------------------------------------------------------------------------------
/Assets/Material/Wall05.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: Wall05
10 | m_Shader: {fileID: 4800000, guid: 7de2f293b3b24a44581d81b169f03e47, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _BumpMap:
22 | m_Texture: {fileID: 2800000, guid: c111e8298665641daabbc4bfaee19565, type: 3}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _DetailAlbedoMap:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _DetailMask:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _DetailNormalMap:
34 | m_Texture: {fileID: 0}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | - _EmissionMap:
38 | m_Texture: {fileID: 0}
39 | m_Scale: {x: 1, y: 1}
40 | m_Offset: {x: 0, y: 0}
41 | - _MainTex:
42 | m_Texture: {fileID: 2800000, guid: 9bd4d6fe5f5c64ffab9c30257a7ec792, type: 3}
43 | m_Scale: {x: 1, y: 1}
44 | m_Offset: {x: 0, y: 0}
45 | - _MetallicGlossMap:
46 | m_Texture: {fileID: 0}
47 | m_Scale: {x: 1, y: 1}
48 | m_Offset: {x: 0, y: 0}
49 | - _OcclusionMap:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | - _ParallaxMap:
54 | m_Texture: {fileID: 0}
55 | m_Scale: {x: 1, y: 1}
56 | m_Offset: {x: 0, y: 0}
57 | m_Floats:
58 | - _BumpScale: 1
59 | - _Cutoff: 0.5
60 | - _DetailNormalMapScale: 1
61 | - _Diffuse: 0
62 | - _DstBlend: 0
63 | - _Gloss: 1.28
64 | - _GlossMapScale: 1
65 | - _Glossiness: 0.5
66 | - _GlossyReflections: 1
67 | - _Metallic: 0
68 | - _Mode: 0
69 | - _OcclusionStrength: 1
70 | - _Parallax: 0.02
71 | - _SmoothnessTextureChannel: 0
72 | - _Specular: 0
73 | - _SpecularHighlights: 1
74 | - _SrcBlend: 1
75 | - _UVSec: 0
76 | - _ZWrite: 1
77 | m_Colors:
78 | - _Color: {r: 1, g: 1, b: 1, a: 1}
79 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
80 | - _WaterColor: {r: 0.42352942, g: 0.8039216, b: 0.94509804, a: 1}
81 |
--------------------------------------------------------------------------------
/Assets/Material/UnderWaterCube.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: UnderWaterCube
10 | m_Shader: {fileID: 4800000, guid: 7de2f293b3b24a44581d81b169f03e47, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _BumpMap:
22 | m_Texture: {fileID: 2800000, guid: 3d0d84a5055f7fb40bf71a422c7b3cc6, type: 3}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _DetailAlbedoMap:
26 | m_Texture: {fileID: 0}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _DetailMask:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _DetailNormalMap:
34 | m_Texture: {fileID: 0}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | - _EmissionMap:
38 | m_Texture: {fileID: 0}
39 | m_Scale: {x: 1, y: 1}
40 | m_Offset: {x: 0, y: 0}
41 | - _MainTex:
42 | m_Texture: {fileID: 2800000, guid: 31095fb6a0fed0d4a95df9481df488bc, type: 3}
43 | m_Scale: {x: 1, y: 1}
44 | m_Offset: {x: 0, y: 0}
45 | - _MetallicGlossMap:
46 | m_Texture: {fileID: 0}
47 | m_Scale: {x: 1, y: 1}
48 | m_Offset: {x: 0, y: 0}
49 | - _OcclusionMap:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | - _ParallaxMap:
54 | m_Texture: {fileID: 0}
55 | m_Scale: {x: 1, y: 1}
56 | m_Offset: {x: 0, y: 0}
57 | m_Floats:
58 | - _BumpScale: 1
59 | - _Cutoff: 0.5
60 | - _DetailNormalMapScale: 1
61 | - _Diffuse: 0.6
62 | - _DstBlend: 0
63 | - _Gloss: 0.42
64 | - _GlossMapScale: 1
65 | - _Glossiness: 0.5
66 | - _GlossyReflections: 1
67 | - _Metallic: 0
68 | - _Mode: 0
69 | - _OcclusionStrength: 1
70 | - _Parallax: 0.02
71 | - _SmoothnessTextureChannel: 0
72 | - _Specular: 0.7
73 | - _SpecularHighlights: 1
74 | - _SrcBlend: 1
75 | - _UVSec: 0
76 | - _ZWrite: 1
77 | m_Colors:
78 | - _Color: {r: 1, g: 1, b: 1, a: 1}
79 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
80 | - _WaterColor: {r: 0.5882353, g: 0.6052738, b: 0.9411765, a: 1}
81 |
--------------------------------------------------------------------------------
/Assets/Scripts/SIneWave/SineWaveMonoBehaviour.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 | namespace LinHowe
5 | {
6 | [Serializable]
7 | public struct SineWave
8 | {
9 | public float L, A, S;//波长,波幅,速度
10 | public Vector2 pos;//波源
11 | public Vector2 D;//方向
12 | public float T;//周期
13 | }
14 | ///
15 | /// 用以显示波形参数
16 | ///
17 | public class SineWaveMonoBehaviour : MonoBehaviour
18 | {
19 | [SerializeField]
20 | public List waves = new List();
21 | private WaterRender.WaterSurface water;
22 | private void Awake()
23 | {
24 | water = GetComponent();
25 | if (water == null)
26 | Debug.LogError("Need WaterSurface Component");
27 | }
28 |
29 | ///
30 | /// 需要将SineWave.pos 转换成uv
31 | ///
32 | public void CaluateUV()
33 | {
34 | Vector2 WaterMinBoundary = new Vector2(-water.width / 2, -water.length / 2);
35 | for(int i = 0;i _BoundingBoxMax.x)
57 | return 0;
58 | if (worldPos.y < _BoundingBoxMin.y )
59 | return 0;
60 | if (worldPos.z < _BoundingBoxMin.z || worldPos.z > _BoundingBoxMax.z)
61 | return 0;
62 | return 1;
63 | }
64 | float4 frag (v2f i) : SV_Target
65 | {
66 | float4 lightDeltaColor =1.0 /_RayStep ;//* internalWorldLightColor;
67 |
68 | float3 viewDir = normalize(UnityWorldSpaceViewDir(i.worldPos));
69 |
70 | float4 col = float4(0, 0, 0, 0);
71 |
72 | float delta = max(max(_BoundingBoxSize.x,_BoundingBoxSize.y),_BoundingBoxSize.z)/_RayStep;
73 | for (float k = 0 ; k <_RayStep; k += 1)
74 | {
75 |
76 | float3 p = i.worldPos - viewDir * k * delta;
77 | float3 lightDir = normalize(internalWorldLightPos.xyz - p);
78 | float3 hitPos = p + lightDir * (_WaterPlane.w - dot(p, _WaterPlane.xyz) / dot(lightDir, _WaterPlane.xyz));
79 | float2 uv = (hitPos.xz - _BoundingBoxMin.xz) / _BoundingBoxSize.xz;
80 | float3 normal = UnpackNormal(tex2D(_WaterNormalMap, uv));
81 | float diffuse = saturate(dot( -lightDir ,normal ) ) ;
82 | float isClip = ClipInBoundingBox(p);
83 |
84 | col += _MainColor * lightDeltaColor * isClip * diffuse ;
85 | }
86 | UNITY_APPLY_FOG(i.fogCoord, col);
87 | return col ;
88 | }
89 |
90 |
91 | ENDCG
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Assets/Scripts/SineWave/GerstnerWave_Component.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using UnityEngine;
3 |
4 | namespace LinHowe
5 | {
6 | ///
7 | /// Gerstner几何波
8 | ///
9 | class GerstnerWave_Component : SineWave_Component
10 | {
11 | RenderTexture GerstnerOffsetXMap;
12 | RenderTexture GerstnerOffsetZMap;
13 | public GerstnerWave_Component(WaterRender.WaterSurface water) : base(water)
14 | {
15 |
16 | }
17 |
18 | public override void InitWaterCamera(int texSize, Material waveEquationMat)
19 | {
20 | GerstnerOffsetXMap = RenderTexture.GetTemporary(texSize, texSize, 16);
21 | GerstnerOffsetXMap.name = "[GerstnerOffsetXMap]";
22 | RenderTexture.active = GerstnerOffsetXMap;
23 | GL.Clear(false, true, new Color(0, 0, 0, 0));
24 |
25 | GerstnerOffsetZMap = RenderTexture.GetTemporary(texSize, texSize, 16);
26 | GerstnerOffsetZMap.name = "[GerstnerOffsetZMap]";
27 | RenderTexture.active = GerstnerOffsetZMap;
28 | GL.Clear(false, true, new Color(0, 0, 0, 0));
29 |
30 | waveEquationMat.SetFloat("Qi", 0.9f);
31 | }
32 |
33 | public override void OnDestroy()
34 | {
35 | if (GerstnerOffsetXMap)
36 | RenderTexture.ReleaseTemporary(GerstnerOffsetXMap);
37 | if (GerstnerOffsetZMap)
38 | RenderTexture.ReleaseTemporary(GerstnerOffsetZMap);
39 | }
40 |
41 | public override void OnRenderImage(RenderTexture src, RenderTexture dst, Material waveEquationMat)
42 | {
43 | int size = waves.Count;
44 |
45 | for (int i = 0; i < size; ++i)
46 | {
47 | timers[i] += Time.fixedDeltaTime;
48 | if (cycles[i] >= timers[i])
49 | {
50 | timers[i] -= cycles[i];
51 | Vector4 waveParams = waves[i];
52 | Vector2 uv = origins[i];
53 |
54 | SetWaveParams(waveEquationMat, waveParams, uv);
55 | Shader.EnableKeyword("GenerateGerstnerOffsetX");
56 | Graphics.Blit(src, GerstnerOffsetXMap, waveEquationMat);
57 | Shader.DisableKeyword("GenerateGerstnerOffsetX");
58 | Shader.EnableKeyword("GenerateGerstnerOffsetZ");
59 | Graphics.Blit(src, GerstnerOffsetZMap, waveEquationMat);
60 | Shader.DisableKeyword("GenerateGerstnerOffsetZ");
61 | Graphics.Blit(src, dst, waveEquationMat);
62 | Graphics.Blit(dst, src);
63 |
64 | }
65 | }
66 | MainTimer += Time.fixedDeltaTime;
67 | }
68 |
69 | public override void OnPostRender()
70 | {
71 | Shader.SetGlobalTexture("_WaterOffsetXMap", GerstnerOffsetXMap);
72 | Shader.SetGlobalTexture("_WaterOffsetZMap", GerstnerOffsetZMap);
73 | }
74 |
75 |
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/Assets/FreeUnityPackageFromAssetStore/SkyBox/sky.tga.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cc28972a3532dba4c82bf9bed5f68340
3 | timeCreated: 1523352067
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName:
7 | 8900000: generatedCubemap
8 | externalObjects: {}
9 | serializedVersion: 4
10 | mipmaps:
11 | mipMapMode: 0
12 | enableMipMap: 1
13 | sRGBTexture: 1
14 | linearTexture: 0
15 | fadeOut: 0
16 | borderMipMap: 0
17 | mipMapsPreserveCoverage: 0
18 | alphaTestReferenceValue: 0.5
19 | mipMapFadeDistanceStart: 1
20 | mipMapFadeDistanceEnd: 3
21 | bumpmap:
22 | convertToNormalMap: 0
23 | externalNormalMap: 0
24 | heightScale: 0.25
25 | normalMapFilter: 0
26 | isReadable: 0
27 | grayScaleToAlpha: 0
28 | generateCubemap: 2
29 | cubemapConvolution: 0
30 | seamlessCubemap: 0
31 | textureFormat: 1
32 | maxTextureSize: 2048
33 | textureSettings:
34 | serializedVersion: 2
35 | filterMode: -1
36 | aniso: -1
37 | mipBias: -1
38 | wrapU: -1
39 | wrapV: -1
40 | wrapW: -1
41 | nPOTScale: 1
42 | lightmap: 0
43 | compressionQuality: 50
44 | spriteMode: 0
45 | spriteExtrude: 1
46 | spriteMeshType: 1
47 | alignment: 0
48 | spritePivot: {x: 0.5, y: 0.5}
49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
50 | spritePixelsToUnits: 100
51 | alphaUsage: 1
52 | alphaIsTransparency: 0
53 | spriteTessellationDetail: -1
54 | textureType: 0
55 | textureShape: 2
56 | maxTextureSizeSet: 0
57 | compressionQualitySet: 0
58 | textureFormatSet: 0
59 | platformSettings:
60 | - buildTarget: DefaultTexturePlatform
61 | maxTextureSize: 2048
62 | resizeAlgorithm: 0
63 | textureFormat: -1
64 | textureCompression: 1
65 | compressionQuality: 50
66 | crunchedCompression: 0
67 | allowsAlphaSplitting: 0
68 | overridden: 0
69 | androidETC2FallbackOverride: 0
70 | - buildTarget: Standalone
71 | maxTextureSize: 2048
72 | resizeAlgorithm: 0
73 | textureFormat: -1
74 | textureCompression: 1
75 | compressionQuality: 50
76 | crunchedCompression: 0
77 | allowsAlphaSplitting: 0
78 | overridden: 0
79 | androidETC2FallbackOverride: 0
80 | - buildTarget: Android
81 | maxTextureSize: 2048
82 | resizeAlgorithm: 0
83 | textureFormat: -1
84 | textureCompression: 1
85 | compressionQuality: 50
86 | crunchedCompression: 0
87 | allowsAlphaSplitting: 0
88 | overridden: 0
89 | androidETC2FallbackOverride: 0
90 | - buildTarget: WebGL
91 | maxTextureSize: 2048
92 | resizeAlgorithm: 0
93 | textureFormat: -1
94 | textureCompression: 1
95 | compressionQuality: 50
96 | crunchedCompression: 0
97 | allowsAlphaSplitting: 0
98 | overridden: 0
99 | androidETC2FallbackOverride: 0
100 | spriteSheet:
101 | serializedVersion: 2
102 | sprites: []
103 | outline: []
104 | physicsShape: []
105 | spritePackingTag:
106 | userData:
107 | assetBundleName:
108 | assetBundleVariant:
109 |
--------------------------------------------------------------------------------
/Assets/Prefabs/Directional Light.prefab:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1001 &100100000
4 | Prefab:
5 | m_ObjectHideFlags: 1
6 | serializedVersion: 2
7 | m_Modification:
8 | m_TransformParent: {fileID: 0}
9 | m_Modifications: []
10 | m_RemovedComponents: []
11 | m_ParentPrefab: {fileID: 0}
12 | m_RootGameObject: {fileID: 1726585030221000}
13 | m_IsPrefabParent: 1
14 | --- !u!1 &1726585030221000
15 | GameObject:
16 | m_ObjectHideFlags: 0
17 | m_PrefabParentObject: {fileID: 0}
18 | m_PrefabInternal: {fileID: 100100000}
19 | serializedVersion: 5
20 | m_Component:
21 | - component: {fileID: 4237094823504832}
22 | - component: {fileID: 114462551540829376}
23 | - component: {fileID: 108109447153778836}
24 | m_Layer: 0
25 | m_Name: Directional Light
26 | m_TagString: Untagged
27 | m_Icon: {fileID: 0}
28 | m_NavMeshLayer: 0
29 | m_StaticEditorFlags: 0
30 | m_IsActive: 1
31 | --- !u!4 &4237094823504832
32 | Transform:
33 | m_ObjectHideFlags: 1
34 | m_PrefabParentObject: {fileID: 0}
35 | m_PrefabInternal: {fileID: 100100000}
36 | m_GameObject: {fileID: 1726585030221000}
37 | m_LocalRotation: {x: 0.31482086, y: 0, z: 0, w: 0.94915116}
38 | m_LocalPosition: {x: 0, y: 8.4, z: -10}
39 | m_LocalScale: {x: 1, y: 1, z: 1}
40 | m_Children: []
41 | m_Father: {fileID: 0}
42 | m_RootOrder: 0
43 | m_LocalEulerAnglesHint: {x: 36.7, y: -0, z: 0}
44 | --- !u!108 &108109447153778836
45 | Light:
46 | m_ObjectHideFlags: 1
47 | m_PrefabParentObject: {fileID: 0}
48 | m_PrefabInternal: {fileID: 100100000}
49 | m_GameObject: {fileID: 1726585030221000}
50 | m_Enabled: 1
51 | serializedVersion: 8
52 | m_Type: 1
53 | m_Color: {r: 1, g: 1, b: 1, a: 1}
54 | m_Intensity: 1
55 | m_Range: 10
56 | m_SpotAngle: 30
57 | m_CookieSize: 10
58 | m_Shadows:
59 | m_Type: 0
60 | m_Resolution: -1
61 | m_CustomResolution: -1
62 | m_Strength: 1
63 | m_Bias: 0.05
64 | m_NormalBias: 0.4
65 | m_NearPlane: 0.2
66 | m_Cookie: {fileID: 0}
67 | m_DrawHalo: 0
68 | m_Flare: {fileID: 0}
69 | m_RenderMode: 0
70 | m_CullingMask:
71 | serializedVersion: 2
72 | m_Bits: 4294967295
73 | m_Lightmapping: 4
74 | m_AreaSize: {x: 1, y: 1}
75 | m_BounceIntensity: 1
76 | m_ColorTemperature: 6570
77 | m_UseColorTemperature: 0
78 | m_ShadowRadius: 0
79 | m_ShadowAngle: 0
80 | --- !u!114 &114462551540829376
81 | MonoBehaviour:
82 | m_ObjectHideFlags: 1
83 | m_PrefabParentObject: {fileID: 0}
84 | m_PrefabInternal: {fileID: 100100000}
85 | m_GameObject: {fileID: 1726585030221000}
86 | m_Enabled: 1
87 | m_EditorHideFlags: 0
88 | m_Script: {fileID: 11500000, guid: 773e8804a9246bf47ab6265072f8803e, type: 3}
89 | m_Name:
90 | m_EditorClassIdentifier:
91 | shadowMapSize: 1024
92 | bias: 0.05
93 | near: 0
94 | far: 28
95 | size: 9
96 | aspect: 1
97 | color: {r: 1, g: 1, b: 1, a: 1}
98 | intensity: 1
99 | shadowMapRenderShader: {fileID: 4800000, guid: 5cd80f6ec2f217a4abc8c0bbe5b87132,
100 | type: 3}
101 |
--------------------------------------------------------------------------------
/Assets/Scripts/WaveEquation/WaveEquation_Component.cs:
--------------------------------------------------------------------------------
1 |
2 | using UnityEngine;
3 |
4 | namespace LinHowe
5 | {
6 | ///
7 | /// 波动方程模拟组件
8 | ///
9 | class WaveEquation_Component : IWaveComponent
10 | {
11 | private Vector4 waveParams; //波形参数
12 | private RenderTexture PreTexture;//上一刻的渲染纹理
13 |
14 | public WaveEquation_Component(WaterRender.WaterSurface water) : base(water)
15 | {
16 |
17 | }
18 |
19 | public override bool InitAndCheckWaveParams(float speed, float viscosity, float d)
20 | {
21 | if (speed <= 0)
22 | {
23 | Debug.LogError("波速不允许小于等于0!");
24 | return false;
25 | }
26 | if (viscosity <= 0)
27 | {
28 | Debug.LogError("粘度系数不允许小于等于0!");
29 | return false;
30 | }
31 | float maxvelocity = d / (2 * Time.fixedDeltaTime) * Mathf.Sqrt(viscosity * Time.fixedDeltaTime + 2);
32 | float velocity = maxvelocity * speed;
33 | float viscositySq = viscosity * viscosity;
34 | float velocitySq = velocity * velocity;
35 | float deltaSizeSq = d * d;
36 | float dt = Mathf.Sqrt(viscositySq + 32 * velocitySq / (deltaSizeSq));
37 | float dtden = 8 * velocitySq / (deltaSizeSq);
38 | float maxT = (viscosity + dt) / dtden;
39 | float maxT2 = (viscosity - dt) / dtden;
40 | if (maxT2 > 0 && maxT2 < maxT)
41 | maxT = maxT2;
42 | if (maxT < Time.fixedDeltaTime)
43 | {
44 | Debug.LogError("粘度系数不符合要求");
45 | return false;
46 | }
47 |
48 | float fac = velocitySq * Time.fixedDeltaTime * Time.fixedDeltaTime / deltaSizeSq;
49 | float i = viscosity * Time.fixedDeltaTime - 2;
50 | float j = viscosity * Time.fixedDeltaTime + 2;
51 |
52 | float k1 = (4 - 8 * fac) / (j);
53 | float k2 = i / j;
54 | float k3 = 2 * fac / j;
55 |
56 | waveParams = new Vector4(k1, k2, k3, d);
57 |
58 | return true;
59 | }
60 |
61 | public override void InitWaterCamera(int texSize, Material waveEquationMat)
62 | {
63 | PreTexture = RenderTexture.GetTemporary(texSize, texSize, 16);
64 | PreTexture.name = "[PreTex]";
65 | RenderTexture.active = PreTexture;
66 | GL.Clear(false, true, new Color(0, 0, 0, 0));
67 |
68 | SetWaveParams(waveEquationMat);
69 | }
70 |
71 | public override void OnDestroy()
72 | {
73 | if (PreTexture)
74 | RenderTexture.ReleaseTemporary(PreTexture);
75 | }
76 |
77 | public override void OnRenderImage(RenderTexture src, RenderTexture dst, Material waveEquationMat)
78 | {
79 | //传入前一次的高度渲染结果,以在shader中根据二维波方程计算当前高度
80 | waveEquationMat.SetTexture("_PreTex", PreTexture);
81 |
82 | Graphics.Blit(src, dst, waveEquationMat);
83 |
84 | Graphics.Blit(src, PreTexture);
85 |
86 | }
87 |
88 | protected void SetWaveParams(Material waveEquationMat)
89 | {
90 | waveEquationMat.SetVector("_WaveParams", waveParams);
91 | }
92 |
93 |
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/Assets/Scripts/SIneWave/SineWave_Component.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using UnityEngine;
3 |
4 | namespace LinHowe
5 | {
6 | ///
7 | /// 正弦函数模拟水面波形
8 | ///
9 | class SineWave_Component : IWaveComponent
10 | {
11 |
12 | protected SineWaveMonoBehaviour sineWavesMonoBehaviour;
13 | protected List waves = new List();//传入shader中的波形参数
14 | protected List origins = new List();//传入shader中的波源uv参数
15 | protected List timers = new List();//计时器
16 | protected List cycles = new List();//周期
17 | protected float MainTimer = 0;//传入shader的时间参数
18 |
19 | public SineWave_Component(WaterRender.WaterSurface water) : base(water)
20 | {
21 |
22 | }
23 | public override bool InitAndCheckWaveParams(float speed, float viscosity, float d)
24 | {
25 | sineWavesMonoBehaviour = water.GetComponent();
26 | if (sineWavesMonoBehaviour == null) return false;
27 | sineWavesMonoBehaviour.CaluateUV();
28 | int size = sineWavesMonoBehaviour.waves.Count;
29 | waves = new List(size);
30 | origins = new List(size);
31 | timers = new List(size);
32 | cycles = new List(size);
33 | for (int i = 0; i < size; ++i)
34 | {
35 | SineWave wave = sineWavesMonoBehaviour.waves[i];
36 | if (wave.T < 0.1f) wave.T = 0.1f;
37 | //wave.S = speed;
38 | Vector2 direction = wave.D;
39 | wave.D = direction.normalized;
40 | Vector4 WaveParams = Vector4.zero;
41 | float AngularFrequency = 2 * Mathf.PI / wave.L;
42 | float PhaseConstant = AngularFrequency * wave.S;
43 | WaveParams.x = wave.A * PhaseConstant;
44 | WaveParams.y = wave.D.x * AngularFrequency;
45 | WaveParams.z = wave.D.y * AngularFrequency;
46 | WaveParams.w = PhaseConstant;
47 | waves.Add(WaveParams);
48 | origins.Add(wave.pos);
49 | timers.Add(0);
50 | cycles.Add(wave.T);
51 | }
52 | return true;
53 | }
54 |
55 | public override void OnRenderImage(RenderTexture src, RenderTexture dst, Material waveEquationMat)
56 | {
57 | int size = waves.Count;
58 |
59 | for (int i = 0; i < size; ++i)
60 | {
61 | timers[i] += Time.fixedDeltaTime;
62 | if(cycles[i]>=timers[i])
63 | {
64 | timers[i] -= cycles[i];
65 | Vector4 waveParams = waves[i];
66 | Vector2 uv = origins[i];
67 |
68 | SetWaveParams(waveEquationMat, waveParams, uv);
69 | Graphics.Blit(src, dst, waveEquationMat);
70 | Graphics.Blit(dst, src);
71 | }
72 |
73 | }
74 | MainTimer += Time.fixedDeltaTime;
75 |
76 |
77 | }
78 |
79 | protected void SetWaveParams(Material waveEquationMat, Vector4 waveParams, Vector2 waveOrigin)
80 | {
81 | waveEquationMat.SetVector("_WaveOrigin", waveOrigin);
82 | waveEquationMat.SetVector("_WaveParams", waveParams);
83 | waveEquationMat.SetFloat("_Timer", MainTimer);
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/Assets/Shaders/UnderWater.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/UnderWater"
2 | {
3 | Properties
4 | {
5 | _MainTex ("Texture", 2D) = "white" {}
6 | _BumpMap ("Normal Map", 2D) = "bump" { }
7 | _Gloss("Gloss", float) = 0
8 | _Specular("Specular", float) = 0
9 | _Diffuse("Diffuse", float) = 0
10 | _WaterColor("WaterColor", color) = (1,1,1,1)
11 | }
12 | SubShader
13 | {
14 | Tags { "RenderType"="Opaque" }
15 |
16 | Pass
17 | {
18 | CGPROGRAM
19 | #pragma vertex vert
20 | #pragma fragment frag
21 | #pragma multi_compile_fog
22 |
23 | #include "UnityCG.cginc"
24 | #include "internal.cginc"
25 |
26 | struct v2f
27 | {
28 | float4 vertex : SV_POSITION;
29 | float2 uv : TEXCOORD0;
30 | UNITY_FOG_COORDS(1)
31 | float4 TW0 : TEXCOORD2;
32 | float4 TW1 : TEXCOORD3;
33 | float4 TW2 : TEXCOORD4;
34 | float4 shadowProj : TEXCOORD5;
35 | float shadowDepth : TEXCOORD6;
36 | };
37 |
38 | float _Gloss;
39 | float _Specular;
40 | float _Diffuse;
41 |
42 | sampler2D _MainTex;
43 | sampler2D _BumpTex;
44 |
45 | float4 _WaterColor;
46 |
47 | v2f vert (appdata_full v)
48 | {
49 | v2f o;
50 | o.vertex = UnityObjectToClipPos(v.vertex);
51 | o.uv = v.texcoord;
52 |
53 |
54 | UNITY_TRANSFER_FOG(o,o.vertex);
55 |
56 |
57 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
58 | float3 worldNormal = UnityObjectToWorldNormal(v.normal);
59 | float3 worldTan = UnityObjectToWorldDir(v.tangent.xyz);
60 | float tanSign = v.tangent.w * unity_WorldTransformParams.w;
61 | float3 worldBinormal = cross(worldNormal, worldTan)*tanSign;
62 |
63 | o.TW0 = float4(worldTan.x, worldBinormal.x, worldNormal.x, worldPos.x);
64 | o.TW1 = float4(worldTan.y, worldBinormal.y, worldNormal.y, worldPos.y);
65 | o.TW2 = float4(worldTan.z, worldBinormal.z, worldNormal.z, worldPos.z);
66 |
67 | float4 cpos = mul(internalWorldLightMV, mul(unity_ObjectToWorld, v.vertex));
68 | o.shadowProj = mul(internalWorldLightVP, cpos);
69 | float4 pj = o.shadowProj * 0.5f;
70 | pj.xy = float2(pj.x, pj.y) + pj.w;
71 | pj.zw = o.shadowProj.zw;
72 | o.shadowProj = pj;
73 | o.shadowDepth = -cpos.z * internalProjectionParams.w;
74 |
75 |
76 |
77 | return o;
78 | }
79 |
80 |
81 |
82 | float4 frag (v2f i) : SV_Target
83 | {
84 | float3 worldPos = float3(i.TW0.w, i.TW1.w, i.TW2.w);
85 | float3 normal = UnpackNormal(tex2D(_BumpTex, i.uv));
86 | float3 worldNormal = float3(dot(i.TW0.xyz, normal), dot(i.TW1.xyz, normal), dot(i.TW2.xyz, normal));
87 |
88 | float3 lightDir = normalize(internalWorldLightDir.xyz);
89 | float3 viewDir = normalize(UnityWorldSpaceViewDir(worldPos));
90 |
91 | float4 col = tex2D(_MainTex, i.uv);
92 |
93 | //半兰伯特模型
94 | float3 diffuse = internalWorldLightColor.rgb * saturate(0.5 * dot(worldNormal, lightDir) + 0.5) * _Diffuse;
95 |
96 | //Blinn-Phong光照模型
97 | float3 halfdir = normalize(lightDir + viewDir);
98 | float ndh = saturate(dot(worldNormal, halfdir));
99 | float3 specular = internalWorldLightColor.rgb * pow(ndh, _Specular*128.0)*_Gloss;
100 |
101 | col.rgb *= diffuse + specular;
102 |
103 | float4 shadow = tex2Dproj(internalShadowMap, i.shadowProj);
104 | float shadowdepth = DecodeFloatRGBA(shadow);
105 | float shadowcol = step(i.shadowDepth - internalBias, shadowdepth)*0.7 + 0.3;
106 | float2 uv = 0.5 - abs(i.shadowProj.xy / i.shadowProj.w - 0.5);
107 | float2 shadowatten = saturate(uv / (1 - internalWorldLightColor.a));
108 | float atten = shadowatten.x*shadowatten.y*shadowcol;
109 | col *= atten;
110 |
111 | //裁剪水底部分
112 | float clip = Clip(worldPos);
113 | if(clip == 1)
114 | col *= _WaterColor;
115 |
116 | UNITY_APPLY_FOG(i.fogCoord, col);
117 | return col;
118 | }
119 | ENDCG
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/Assets/Material/Water.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!21 &2100000
4 | Material:
5 | serializedVersion: 6
6 | m_ObjectHideFlags: 0
7 | m_PrefabParentObject: {fileID: 0}
8 | m_PrefabInternal: {fileID: 0}
9 | m_Name: Water
10 | m_Shader: {fileID: 4800000, guid: 560b19e2418a7f142a70cd8f8dc3560e, type: 3}
11 | m_ShaderKeywords:
12 | m_LightmapFlags: 4
13 | m_EnableInstancingVariants: 0
14 | m_DoubleSidedGI: 0
15 | m_CustomRenderQueue: -1
16 | stringTagMap: {}
17 | disabledShaderPasses: []
18 | m_SavedProperties:
19 | serializedVersion: 3
20 | m_TexEnvs:
21 | - _BumpMap:
22 | m_Texture: {fileID: 0}
23 | m_Scale: {x: 1, y: 1}
24 | m_Offset: {x: 0, y: 0}
25 | - _Cubemap:
26 | m_Texture: {fileID: 8900000, guid: cc28972a3532dba4c82bf9bed5f68340, type: 3}
27 | m_Scale: {x: 1, y: 1}
28 | m_Offset: {x: 0, y: 0}
29 | - _DetailAlbedoMap:
30 | m_Texture: {fileID: 0}
31 | m_Scale: {x: 1, y: 1}
32 | m_Offset: {x: 0, y: 0}
33 | - _DetailMask:
34 | m_Texture: {fileID: 0}
35 | m_Scale: {x: 1, y: 1}
36 | m_Offset: {x: 0, y: 0}
37 | - _DetailNormalMap:
38 | m_Texture: {fileID: 0}
39 | m_Scale: {x: 1, y: 1}
40 | m_Offset: {x: 0, y: 0}
41 | - _Diffuse:
42 | m_Texture: {fileID: 0}
43 | m_Scale: {x: 1, y: 1}
44 | m_Offset: {x: 0, y: 0}
45 | - _EmissionMap:
46 | m_Texture: {fileID: 0}
47 | m_Scale: {x: 1, y: 1}
48 | m_Offset: {x: 0, y: 0}
49 | - _LiquidHeightMap:
50 | m_Texture: {fileID: 0}
51 | m_Scale: {x: 1, y: 1}
52 | m_Offset: {x: 0, y: 0}
53 | - _LiquidReflectMap:
54 | m_Texture: {fileID: 0}
55 | m_Scale: {x: 1, y: 1}
56 | m_Offset: {x: 0, y: 0}
57 | - _MainTex:
58 | m_Texture: {fileID: 2800000, guid: dbeabbc7bce59984eb99a72bd4609547, type: 3}
59 | m_Scale: {x: 1, y: 1}
60 | m_Offset: {x: 0, y: 0}
61 | - _MetallicGlossMap:
62 | m_Texture: {fileID: 0}
63 | m_Scale: {x: 1, y: 1}
64 | m_Offset: {x: 0, y: 0}
65 | - _OcclusionMap:
66 | m_Texture: {fileID: 0}
67 | m_Scale: {x: 1, y: 1}
68 | m_Offset: {x: 0, y: 0}
69 | - _ParallaxMap:
70 | m_Texture: {fileID: 0}
71 | m_Scale: {x: 1, y: 1}
72 | m_Offset: {x: 0, y: 0}
73 | - _WaveMap:
74 | m_Texture: {fileID: 0}
75 | m_Scale: {x: 1, y: 1}
76 | m_Offset: {x: 0, y: 0}
77 | m_Floats:
78 | - _BumpScale: 1
79 | - _Cutoff: 0.5
80 | - _DetailNormalMapScale: 1
81 | - _Diffuse: 0.2
82 | - _Distortion: 0
83 | - _DstBlend: 0
84 | - _Gloss: 0.48
85 | - _GlossMapScale: 1
86 | - _Glossiness: 0.5
87 | - _GlossyReflections: 1
88 | - _Height: 1
89 | - _Metallic: 0
90 | - _Mode: 0
91 | - _OcclusionStrength: 1
92 | - _Offset: 0
93 | - _Parallax: 0.02
94 | - _Range: 4.33
95 | - _Refract: 0.124
96 | - _SmoothnessTextureChannel: 0
97 | - _Specular: 1.9
98 | - _SpecularHighlights: 1
99 | - _SrcBlend: 1
100 | - _UVSec: 0
101 | - _WaveXSpeed: 0.01
102 | - _WaveYSpeed: 0.01
103 | - _ZWrite: 1
104 | m_Colors:
105 | - _BaseColor: {r: 0.5036224, g: 0.95217603, b: 0.99264705, a: 1}
106 | - _Color: {r: 0.5994809, g: 0.95523196, b: 0.9705882, a: 1}
107 | - _Color1: {r: 0.30882353, g: 1, b: 0.8387255, a: 1}
108 | - _Color2: {r: 0, g: 0.25517225, b: 1, a: 1}
109 | - _DeepColor: {r: 0.15819634, g: 0.5705833, b: 0.97794116, a: 1}
110 | - _Diffuse: {r: 0.9632353, g: 0.9632353, b: 0.9632353, a: 1}
111 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
112 | - _Fresnel: {r: -0.38, g: 3.72, b: 4.5, a: 0}
113 | - _Range: {r: 0, g: 5, b: 0, a: 0}
114 | - _ShallowColor: {r: 0.16176468, g: 1, b: 0.51440156, a: 1}
115 | - _WaterColor: {r: 0.08088237, g: 0.39148086, b: 1, a: 1}
116 |
--------------------------------------------------------------------------------
/Assets/Shaders/Water.shader:
--------------------------------------------------------------------------------
1 | Shader "LinHowe/Water"
2 | {
3 | Properties
4 | {
5 | _Gloss("Gloss", float) = 0
6 | _Specular("Specular", float) = 0
7 | _Diffuse("Diffuse", float) = 0
8 | _Height("Height", float) = 0
9 | _Offset("Offset", float) = 0
10 | _Range("Range", float) = 0
11 | _Refract("Refract", Range(0,1)) = 0
12 | _BaseColor("BaseColor", color) = (1,1,1,1)
13 | _WaterColor("WaterColor", color) = (1,1,1,1)
14 | _Fresnel("Fresnel x = bias,y = scale,z = power", vector) = (0, 0, 0, 0)
15 | }
16 |
17 | SubShader
18 | {
19 | //半透明着色器
20 | Tags{ "RenderType" = "Transparent" "Queue" = "Transparent" }
21 | LOD 100
22 |
23 | //抓取水底内容放到_GrabTexture纹理中
24 | GrabPass{}
25 |
26 | Pass
27 | {
28 | //不写入深度缓存
29 | zwrite off
30 |
31 | //透明度混合
32 | blend srcalpha oneminussrcalpha
33 |
34 | CGPROGRAM
35 | #pragma vertex vert
36 | #pragma fragment frag
37 | #pragma multi_compile_fog
38 |
39 | #include "UnityCG.cginc"
40 | #include "Lighting.cginc"
41 | #include "internal.cginc"
42 |
43 | struct v2f
44 | {
45 | float2 uv : TEXCOORD0;
46 | UNITY_FOG_COORDS(1)
47 | float4 proj0 : TEXCOORD2;
48 |
49 | float4 TW0 : TEXCOORD3;
50 | float4 TW1 : TEXCOORD4;
51 | float4 TW2 : TEXCOORD5;
52 |
53 | float4 vertex : SV_POSITION;
54 |
55 | };
56 | float _Gloss;
57 | float _Specular;
58 | float _Diffuse;
59 | float _Range;
60 | float _Refract;
61 | float _Height;
62 | float _Offset;
63 |
64 | float4 _BaseColor;
65 | float4 _WaterColor;
66 |
67 | float4 _Fresnel;
68 |
69 | sampler2D _GrabTexture;
70 | sampler2D _CameraDepthTexture;
71 | sampler2D _WaterReflectTexture;
72 |
73 | float4 _GrabTexture_TexelSize;
74 | v2f vert(appdata_full v)
75 | {
76 | v2f o;
77 |
78 | float4 projPos = UnityObjectToClipPos(v.vertex);
79 |
80 | //计算GrabPass纹理的纹理坐标
81 | o.proj0 = ComputeGrabScreenPos(projPos);
82 |
83 | //获取水面的高度
84 | float height = DecodeHeight(tex2Dlod(_WaterHeightMap, float4(v.texcoord.xy,0,0)));
85 | v.vertex.y += height * _Height;
86 |
87 | ////水面几何波造成的偏移
88 | //float offset = DecodeHeight(tex2Dlod(_WaterOffsetXMap, float4(v.texcoord.xy,0,0)));
89 | //v.vertex.x += offset * _Offset;
90 | //offset = DecodeHeight(tex2Dlod(_WaterOffsetZMap, float4(v.texcoord.xy,0,0)));
91 | //v.vertex.z += offset * _Offset;
92 |
93 | o.uv = v.texcoord;
94 | //从顶点着色输出雾数据
95 | UNITY_TRANSFER_FOG(o,o.vertex);
96 | o.vertex = UnityObjectToClipPos(v.vertex);
97 |
98 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
99 | float3 worldNormal = UnityObjectToWorldNormal(v.normal);
100 | float3 worldTan = UnityObjectToWorldDir(v.tangent.xyz);
101 | float tanSign = v.tangent.w * unity_WorldTransformParams.w;
102 | float3 worldBinormal = cross(worldNormal, worldTan)*tanSign;
103 | o.TW0 = float4(worldTan.x, worldBinormal.x, worldNormal.x, worldPos.x);
104 | o.TW1 = float4(worldTan.y, worldBinormal.y, worldNormal.y, worldPos.y);
105 | o.TW2 = float4(worldTan.z, worldBinormal.z, worldNormal.z, worldPos.z);
106 |
107 | return o;
108 | }
109 |
110 |
111 | float4 frag(v2f i) : SV_Target
112 | {
113 | float3 normal = UnpackNormal(tex2D(_WaterNormalMap, i.uv));
114 | float3 worldNormal = float3(dot(i.TW0.xyz, normal), dot(i.TW1.xyz, normal), dot(i.TW2.xyz, normal));
115 | float3 worldPos = float3(i.TW0.w, i.TW1.w, i.TW2.w);
116 | float3 lightDir = normalize(internalWorldLightDir.xyz);
117 | float3 viewDir = normalize(UnityWorldSpaceViewDir(worldPos));
118 |
119 | float2 projUv = i.proj0.xy / i.proj0.w + normal.xy * _Refract;
120 | float4 refrcol = tex2D(_GrabTexture, projUv);
121 |
122 | float4 reflcol = tex2D(_WaterReflectTexture, projUv);
123 |
124 | refrcol.rgb *= _BaseColor.rgb;
125 | float height = max(DecodeHeight(tex2D(_WaterHeightMap, i.uv)),0);
126 |
127 | //半兰伯特模型
128 | float3 diffuse = internalWorldLightColor.rgb * saturate(0.5 * dot(worldNormal, lightDir) + 0.5) * _Diffuse;
129 |
130 | //Blinn-Phong光照模型
131 | float3 halfdir = normalize(lightDir + viewDir);
132 | float ndh = saturate(dot(worldNormal, halfdir));
133 | float3 specular = internalWorldLightColor.rgb * pow(ndh, _Specular*128.0)*_Gloss;
134 |
135 | //菲涅尔效果
136 | float bias = _Fresnel.x,scale = _Fresnel.y,power =_Fresnel.z;
137 | float f = clamp(bias + pow(1 - saturate(dot(worldNormal, viewDir)),power) * scale, 0.0, 1.0);
138 |
139 | float4 col;
140 | col.rgb = (diffuse + reflcol.rgb) * f + refrcol.rgb * (1 - f);
141 | col.rgb += specular;
142 |
143 |
144 | //水波突出
145 | col.rgb += _WaterColor.rgb * (height*_Range);
146 |
147 | //从顶点着色器中输出雾效数据,将第二个参数中的颜色值作为雾效的颜色值,且在正向附加渲染通道(forward-additive pass)中
148 | UNITY_APPLY_FOG(i.fogCoord, col);
149 | col.a = 1.0;
150 |
151 | return col;
152 | }
153 | ENDCG
154 | }
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/SunLight.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 | namespace LinHowe.WaterRender
5 | {
6 | ///
7 | /// 平行光-用于渲染和投射阴影
8 | ///
9 |
10 | [RequireComponent(typeof(Camera))]
11 | public class SunLight : MonoBehaviour
12 | {
13 | public int shadowMapSize;
14 |
15 | public float bias;
16 |
17 | public float near;
18 | public float far;
19 |
20 | public float size;
21 | public float aspect;
22 | public Color color;
23 | public float intensity;
24 |
25 | public Shader shadowMapRenderShader;
26 |
27 | private Camera m_Camera;
28 | private RenderTexture m_ShadowMap;
29 |
30 | private Material m_BGMaterial;
31 |
32 | void Start()
33 | {
34 |
35 | InitRenderTarget();
36 |
37 | m_BGMaterial = new Material(shadowMapRenderShader);
38 |
39 | }
40 |
41 | void OnPreRender()
42 | {
43 | InitRenderTarget();
44 | Matrix4x4 wtl = m_Camera.worldToCameraMatrix;
45 |
46 | Shader.SetGlobalColor("internalWorldLightColor",
47 | new Color(color.r * intensity, color.g * intensity, color.b * intensity, color.a));
48 | Vector3 dirction = transform.rotation * - Vector3.forward;
49 | Shader.SetGlobalVector("internalWorldLightDir",
50 | dirction);
51 | Shader.SetGlobalVector("internalWorldLightPos",
52 | transform.position);
53 | Shader.SetGlobalMatrix("internalWorldLightMV", wtl);
54 | Shader.SetGlobalMatrix("internalWorldLightVP", m_Camera.projectionMatrix);
55 | Shader.SetGlobalVector("internalProjectionParams",
56 | new Vector4(0.01f, m_Camera.nearClipPlane, m_Camera.farClipPlane, 1 / m_Camera.farClipPlane));
57 | Shader.SetGlobalFloat("internalBias", bias);
58 | }
59 |
60 | void InitRenderTarget()
61 | {
62 | if (m_Camera == null)
63 | {
64 | m_Camera = GetComponent();
65 | if (m_Camera == null)
66 | m_Camera = gameObject.AddComponent();
67 |
68 | m_Camera.aspect = aspect;
69 | m_Camera.backgroundColor = new Color(1, 1, 1, 0);
70 | m_Camera.clearFlags = CameraClearFlags.SolidColor;
71 | m_Camera.depth = 0;
72 | m_Camera.farClipPlane = far;
73 | m_Camera.nearClipPlane = near;
74 | m_Camera.orthographic = true;
75 | m_Camera.orthographicSize = size;
76 | m_Camera.SetReplacementShader(shadowMapRenderShader, "RenderType");
77 | }
78 | if (m_ShadowMap == null)
79 | {
80 | m_ShadowMap = RenderTexture.GetTemporary(shadowMapSize, shadowMapSize, 16);
81 | m_Camera.targetTexture = m_ShadowMap;
82 | Shader.SetGlobalTexture("internalShadowMap", m_ShadowMap);
83 | }
84 |
85 | }
86 |
87 | void OnDrawGizmos()
88 | {
89 | Gizmos.color = new Color(0, 0.3f, 1f, 0.6f);
90 |
91 | Vector3 vp1 = transform.position + transform.rotation * new Vector3(-size * aspect, -size, near);
92 | Vector3 vp2 = transform.position + transform.rotation * new Vector3(-size * aspect, size, near);
93 | Vector3 vp3 = transform.position + transform.rotation * new Vector3(size * aspect, size, near);
94 | Vector3 vp4 = transform.position + transform.rotation * new Vector3(size * aspect, -size, near);
95 |
96 | Vector3 vp5 = transform.position + transform.rotation * new Vector3(-size * aspect, -size, far);
97 | Vector3 vp6 = transform.position + transform.rotation * new Vector3(-size * aspect, size, far);
98 | Vector3 vp7 = transform.position + transform.rotation * new Vector3(size * aspect, size, far);
99 | Vector3 vp8 = transform.position + transform.rotation * new Vector3(size * aspect, -size, far);
100 |
101 | Gizmos.DrawLine(vp1, vp2);
102 | Gizmos.DrawLine(vp2, vp3);
103 | Gizmos.DrawLine(vp3, vp4);
104 | Gizmos.DrawLine(vp4, vp1);
105 |
106 | Gizmos.DrawLine(vp5, vp6);
107 | Gizmos.DrawLine(vp6, vp7);
108 | Gizmos.DrawLine(vp7, vp8);
109 | Gizmos.DrawLine(vp8, vp5);
110 |
111 | Gizmos.DrawLine(vp1, vp5);
112 | Gizmos.DrawLine(vp2, vp6);
113 | Gizmos.DrawLine(vp3, vp7);
114 | Gizmos.DrawLine(vp4, vp8);
115 | }
116 |
117 | private void OnDestroy()
118 | {
119 | if (m_BGMaterial)
120 | Destroy(m_BGMaterial);
121 | if (m_ShadowMap)
122 | RenderTexture.ReleaseTemporary(m_ShadowMap);
123 | }
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/ProjectSettings/QualitySettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!47 &1
4 | QualitySettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 5
7 | m_CurrentQuality: 5
8 | m_QualitySettings:
9 | - serializedVersion: 2
10 | name: Very Low
11 | pixelLightCount: 0
12 | shadows: 0
13 | shadowResolution: 0
14 | shadowProjection: 1
15 | shadowCascades: 1
16 | shadowDistance: 15
17 | shadowNearPlaneOffset: 3
18 | shadowCascade2Split: 0.33333334
19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
20 | blendWeights: 1
21 | textureQuality: 1
22 | anisotropicTextures: 0
23 | antiAliasing: 0
24 | softParticles: 0
25 | softVegetation: 0
26 | realtimeReflectionProbes: 0
27 | billboardsFaceCameraPosition: 0
28 | vSyncCount: 0
29 | lodBias: 0.3
30 | maximumLODLevel: 0
31 | particleRaycastBudget: 4
32 | asyncUploadTimeSlice: 2
33 | asyncUploadBufferSize: 4
34 | excludedTargetPlatforms: []
35 | - serializedVersion: 2
36 | name: Low
37 | pixelLightCount: 0
38 | shadows: 0
39 | shadowResolution: 0
40 | shadowProjection: 1
41 | shadowCascades: 1
42 | shadowDistance: 20
43 | shadowNearPlaneOffset: 3
44 | shadowCascade2Split: 0.33333334
45 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
46 | blendWeights: 2
47 | textureQuality: 0
48 | anisotropicTextures: 0
49 | antiAliasing: 0
50 | softParticles: 0
51 | softVegetation: 0
52 | realtimeReflectionProbes: 0
53 | billboardsFaceCameraPosition: 0
54 | vSyncCount: 0
55 | lodBias: 0.4
56 | maximumLODLevel: 0
57 | particleRaycastBudget: 16
58 | asyncUploadTimeSlice: 2
59 | asyncUploadBufferSize: 4
60 | excludedTargetPlatforms: []
61 | - serializedVersion: 2
62 | name: Medium
63 | pixelLightCount: 1
64 | shadows: 1
65 | shadowResolution: 0
66 | shadowProjection: 1
67 | shadowCascades: 1
68 | shadowDistance: 20
69 | shadowNearPlaneOffset: 3
70 | shadowCascade2Split: 0.33333334
71 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
72 | blendWeights: 2
73 | textureQuality: 0
74 | anisotropicTextures: 1
75 | antiAliasing: 0
76 | softParticles: 0
77 | softVegetation: 0
78 | realtimeReflectionProbes: 0
79 | billboardsFaceCameraPosition: 0
80 | vSyncCount: 1
81 | lodBias: 0.7
82 | maximumLODLevel: 0
83 | particleRaycastBudget: 64
84 | asyncUploadTimeSlice: 2
85 | asyncUploadBufferSize: 4
86 | excludedTargetPlatforms: []
87 | - serializedVersion: 2
88 | name: High
89 | pixelLightCount: 2
90 | shadows: 2
91 | shadowResolution: 1
92 | shadowProjection: 1
93 | shadowCascades: 2
94 | shadowDistance: 40
95 | shadowNearPlaneOffset: 3
96 | shadowCascade2Split: 0.33333334
97 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
98 | blendWeights: 2
99 | textureQuality: 0
100 | anisotropicTextures: 1
101 | antiAliasing: 0
102 | softParticles: 0
103 | softVegetation: 1
104 | realtimeReflectionProbes: 1
105 | billboardsFaceCameraPosition: 1
106 | vSyncCount: 1
107 | lodBias: 1
108 | maximumLODLevel: 0
109 | particleRaycastBudget: 256
110 | asyncUploadTimeSlice: 2
111 | asyncUploadBufferSize: 4
112 | excludedTargetPlatforms: []
113 | - serializedVersion: 2
114 | name: Very High
115 | pixelLightCount: 3
116 | shadows: 2
117 | shadowResolution: 2
118 | shadowProjection: 1
119 | shadowCascades: 2
120 | shadowDistance: 70
121 | shadowNearPlaneOffset: 3
122 | shadowCascade2Split: 0.33333334
123 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
124 | blendWeights: 4
125 | textureQuality: 0
126 | anisotropicTextures: 2
127 | antiAliasing: 2
128 | softParticles: 1
129 | softVegetation: 1
130 | realtimeReflectionProbes: 1
131 | billboardsFaceCameraPosition: 1
132 | vSyncCount: 1
133 | lodBias: 1.5
134 | maximumLODLevel: 0
135 | particleRaycastBudget: 1024
136 | asyncUploadTimeSlice: 2
137 | asyncUploadBufferSize: 4
138 | excludedTargetPlatforms: []
139 | - serializedVersion: 2
140 | name: Ultra
141 | pixelLightCount: 4
142 | shadows: 2
143 | shadowResolution: 2
144 | shadowProjection: 1
145 | shadowCascades: 4
146 | shadowDistance: 150
147 | shadowNearPlaneOffset: 3
148 | shadowCascade2Split: 0.33333334
149 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
150 | blendWeights: 4
151 | textureQuality: 0
152 | anisotropicTextures: 2
153 | antiAliasing: 2
154 | softParticles: 1
155 | softVegetation: 1
156 | realtimeReflectionProbes: 1
157 | billboardsFaceCameraPosition: 1
158 | vSyncCount: 1
159 | lodBias: 2
160 | maximumLODLevel: 0
161 | particleRaycastBudget: 4096
162 | asyncUploadTimeSlice: 2
163 | asyncUploadBufferSize: 4
164 | excludedTargetPlatforms: []
165 | m_PerPlatformDefaultQuality:
166 | Android: 2
167 | Nintendo 3DS: 5
168 | Nintendo Switch: 5
169 | PS4: 5
170 | PSM: 5
171 | PSP2: 2
172 | Standalone: 5
173 | Tizen: 2
174 | WebGL: 3
175 | WiiU: 5
176 | Windows Store Apps: 5
177 | XboxOne: 5
178 | iPhone: 2
179 | tvOS: 2
180 |
--------------------------------------------------------------------------------
/Assets/Prefabs/WaterSuface.prefab:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1001 &100100000
4 | Prefab:
5 | m_ObjectHideFlags: 1
6 | serializedVersion: 2
7 | m_Modification:
8 | m_TransformParent: {fileID: 0}
9 | m_Modifications: []
10 | m_RemovedComponents: []
11 | m_ParentPrefab: {fileID: 0}
12 | m_RootGameObject: {fileID: 1928560118655970}
13 | m_IsPrefabParent: 1
14 | --- !u!1 &1519024601794918
15 | GameObject:
16 | m_ObjectHideFlags: 0
17 | m_PrefabParentObject: {fileID: 0}
18 | m_PrefabInternal: {fileID: 100100000}
19 | serializedVersion: 5
20 | m_Component:
21 | - component: {fileID: 4972800990472218}
22 | - component: {fileID: 20778188902970190}
23 | - component: {fileID: 124618477675250666}
24 | - component: {fileID: 81863421911153676}
25 | - component: {fileID: 114979467076298336}
26 | m_Layer: 0
27 | m_Name: Main Camera
28 | m_TagString: MainCamera
29 | m_Icon: {fileID: 0}
30 | m_NavMeshLayer: 0
31 | m_StaticEditorFlags: 0
32 | m_IsActive: 1
33 | --- !u!1 &1928560118655970
34 | GameObject:
35 | m_ObjectHideFlags: 0
36 | m_PrefabParentObject: {fileID: 0}
37 | m_PrefabInternal: {fileID: 100100000}
38 | serializedVersion: 5
39 | m_Component:
40 | - component: {fileID: 4512926232532318}
41 | - component: {fileID: 65851466969466572}
42 | - component: {fileID: 114029954623772442}
43 | m_Layer: 0
44 | m_Name: WaterSuface
45 | m_TagString: Untagged
46 | m_Icon: {fileID: 0}
47 | m_NavMeshLayer: 0
48 | m_StaticEditorFlags: 0
49 | m_IsActive: 1
50 | --- !u!4 &4512926232532318
51 | Transform:
52 | m_ObjectHideFlags: 1
53 | m_PrefabParentObject: {fileID: 0}
54 | m_PrefabInternal: {fileID: 100100000}
55 | m_GameObject: {fileID: 1928560118655970}
56 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
57 | m_LocalPosition: {x: -0.12, y: 0, z: 0.08}
58 | m_LocalScale: {x: 1, y: 1, z: 1}
59 | m_Children:
60 | - {fileID: 4972800990472218}
61 | m_Father: {fileID: 0}
62 | m_RootOrder: 0
63 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
64 | --- !u!4 &4972800990472218
65 | Transform:
66 | m_ObjectHideFlags: 1
67 | m_PrefabParentObject: {fileID: 0}
68 | m_PrefabInternal: {fileID: 100100000}
69 | m_GameObject: {fileID: 1519024601794918}
70 | m_LocalRotation: {x: 0.17364816, y: -0, z: -0, w: 0.9848078}
71 | m_LocalPosition: {x: 0, y: 3, z: -8}
72 | m_LocalScale: {x: 1, y: 1, z: 1}
73 | m_Children: []
74 | m_Father: {fileID: 4512926232532318}
75 | m_RootOrder: 0
76 | m_LocalEulerAnglesHint: {x: 20, y: 0, z: 0}
77 | --- !u!20 &20778188902970190
78 | Camera:
79 | m_ObjectHideFlags: 1
80 | m_PrefabParentObject: {fileID: 0}
81 | m_PrefabInternal: {fileID: 100100000}
82 | m_GameObject: {fileID: 1519024601794918}
83 | m_Enabled: 1
84 | serializedVersion: 2
85 | m_ClearFlags: 1
86 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
87 | m_NormalizedViewPortRect:
88 | serializedVersion: 2
89 | x: 0
90 | y: 0
91 | width: 1
92 | height: 1
93 | near clip plane: 0.3
94 | far clip plane: 1000
95 | field of view: 60
96 | orthographic: 0
97 | orthographic size: 5
98 | m_Depth: -1
99 | m_CullingMask:
100 | serializedVersion: 2
101 | m_Bits: 4294967295
102 | m_RenderingPath: -1
103 | m_TargetTexture: {fileID: 0}
104 | m_TargetDisplay: 0
105 | m_TargetEye: 3
106 | m_HDR: 1
107 | m_AllowMSAA: 1
108 | m_ForceIntoRT: 0
109 | m_OcclusionCulling: 1
110 | m_StereoConvergence: 10
111 | m_StereoSeparation: 0.022
112 | m_StereoMirrorMode: 0
113 | --- !u!65 &65851466969466572
114 | BoxCollider:
115 | m_ObjectHideFlags: 1
116 | m_PrefabParentObject: {fileID: 0}
117 | m_PrefabInternal: {fileID: 100100000}
118 | m_GameObject: {fileID: 1928560118655970}
119 | m_Material: {fileID: 0}
120 | m_IsTrigger: 0
121 | m_Enabled: 1
122 | serializedVersion: 2
123 | m_Size: {x: 9, y: 0.07, z: 9}
124 | m_Center: {x: 0, y: 0, z: 0}
125 | --- !u!81 &81863421911153676
126 | AudioListener:
127 | m_ObjectHideFlags: 1
128 | m_PrefabParentObject: {fileID: 0}
129 | m_PrefabInternal: {fileID: 100100000}
130 | m_GameObject: {fileID: 1519024601794918}
131 | m_Enabled: 1
132 | --- !u!114 &114029954623772442
133 | MonoBehaviour:
134 | m_ObjectHideFlags: 1
135 | m_PrefabParentObject: {fileID: 0}
136 | m_PrefabInternal: {fileID: 100100000}
137 | m_GameObject: {fileID: 1928560118655970}
138 | m_Enabled: 1
139 | m_EditorHideFlags: 0
140 | m_Script: {fileID: 11500000, guid: 32d68a9644d8cb64593e6c7fbb7c238f, type: 3}
141 | m_Name:
142 | m_EditorClassIdentifier:
143 | width: 9
144 | length: 9
145 | cellSize: 0.1
146 | material: {fileID: 2100000, guid: 970a389ba39ecb44b8c1ce961104493d, type: 2}
147 | depth: 4.6
148 | MapSize: 128
149 | Velocity: 1
150 | Viscosity: 0.894
151 | --- !u!114 &114979467076298336
152 | MonoBehaviour:
153 | m_ObjectHideFlags: 1
154 | m_PrefabParentObject: {fileID: 0}
155 | m_PrefabInternal: {fileID: 100100000}
156 | m_GameObject: {fileID: 1519024601794918}
157 | m_Enabled: 1
158 | m_EditorHideFlags: 0
159 | m_Script: {fileID: 11500000, guid: aa4274f7525bb974d8e5bf36ea5ca014, type: 3}
160 | m_Name:
161 | m_EditorClassIdentifier:
162 | water: {fileID: 114029954623772442}
163 | swipeSize: 0.4
164 | swipeMesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
165 | height: 0
166 | force: 1
167 | --- !u!124 &124618477675250666
168 | Behaviour:
169 | m_ObjectHideFlags: 1
170 | m_PrefabParentObject: {fileID: 0}
171 | m_PrefabInternal: {fileID: 100100000}
172 | m_GameObject: {fileID: 1519024601794918}
173 | m_Enabled: 1
174 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/FloatingObject.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using LinHowe.WaterRender;
5 |
6 | namespace LinHowe
7 | {
8 | ///
9 | /// 浮体
10 | ///
11 |
12 | [RequireComponent(typeof(Rigidbody))]
13 | [RequireComponent(typeof(MeshFilter))]
14 | public class FloatingObject : Object
15 | {
16 | public int VoxelSize = 1;
17 | public float dragInWater = 1f,angularDragInWater = 1f;//阻力
18 |
19 | private Rigidbody m_Rigidbody;
20 | private float m_Volume;//体积
21 | //private float m_Density;//密度
22 | //private float m_Mass;//质量
23 | private Vector3[] m_Voxels;//体素
24 | private Vector3 voxelSize;
25 | private float initialDrag, initialAngularDrag;
26 |
27 | protected override void Init()
28 | {
29 |
30 | if(VoxelSize<1)
31 | VoxelSize = 1;
32 | m_Rigidbody = gameObject.GetComponent();
33 | initialDrag = m_Rigidbody.drag;
34 | initialAngularDrag = m_Rigidbody.angularDrag;
35 |
36 |
37 | //m_Mass = m_Rigidbody.mass;
38 |
39 | CalualateVolume();
40 | //m_Density = m_Mass / m_Volume;
41 | CalualateVoxels();
42 | }
43 |
44 | ///
45 | /// 计算体积
46 | ///
47 | private void CalualateVolume()
48 | {
49 | MeshFilter mf = GetComponent();
50 | Mesh mesh = mf.mesh;
51 | float volume = 0f;
52 | Vector3[] vertices = mesh.vertices;
53 | int[] triangles = mesh.triangles;
54 | for (int i = 0; i < mesh.triangles.Length; i += 3)
55 | {
56 | Vector3 p1 = vertices[triangles[i + 0]];
57 | Vector3 p2 = vertices[triangles[i + 1]];
58 | Vector3 p3 = vertices[triangles[i + 2]];
59 |
60 | Vector3 a = p1 - p2;
61 | Vector3 b = p1 - p3;
62 | Vector3 c = p1 - Vector3.zero;
63 |
64 | volume += (Vector3.Dot(a, Vector3.Cross(b, c))) / 6f;
65 |
66 | }
67 |
68 | m_Volume = Mathf.Abs(volume) * transform.localScale.x * transform.localScale.y * transform.localScale.z;
69 | }
70 |
71 | private void CalualateVoxels()
72 | {
73 | Quaternion initialRotation = this.transform.rotation;
74 | this.transform.rotation = Quaternion.identity;
75 |
76 | Bounds bounds = m_Bounds;
77 | this.voxelSize.x = bounds.size.x / VoxelSize;
78 | this.voxelSize.y = bounds.size.y / VoxelSize;
79 | this.voxelSize.z = bounds.size.z / VoxelSize;
80 | List voxels = new List( VoxelSize * VoxelSize * VoxelSize);
81 |
82 | for (int j = 0; j < VoxelSize; j++)
83 | {
84 | for (int i = 0; i < VoxelSize; i++)
85 | {
86 | for (int k = 0; k < VoxelSize; k++)
87 | {
88 | float pX = bounds.min.x + this.voxelSize.x * (0.5f + i);
89 | float pY = bounds.min.y + this.voxelSize.y * (0.5f + j);
90 | float pZ = bounds.min.z + this.voxelSize.z * (0.5f + k);
91 |
92 | Vector3 point = new Vector3(pX, pY, pZ);
93 | if (IsPointInsideCollider(point))
94 | {
95 | voxels.Add(this.transform.InverseTransformPoint(point));
96 | }
97 | }
98 | }
99 | }
100 |
101 | transform.rotation = initialRotation;
102 |
103 | m_Voxels = voxels.ToArray();
104 | }
105 |
106 | private bool IsPointInsideCollider(Vector3 point)
107 | {
108 | float rayLength = m_Bounds.size.magnitude;
109 | Ray ray = new Ray(point, m_Collider.transform.position - point);
110 | RaycastHit hit;
111 |
112 | if (Physics.Raycast(ray, out hit, rayLength))
113 | {
114 | if (hit.collider == m_Collider)
115 | {
116 | return false;
117 | }
118 | }
119 |
120 | return true;
121 | }
122 |
123 |
124 | private void FixedUpdate()
125 | {
126 |
127 | int len = m_Voxels.Length;
128 | //int planeVoxels = VoxelSize * VoxelSize;
129 |
130 | foreach (WaterSurface water in waterSurfacesList)
131 | {
132 | Vector3 force = water.Density * m_Volume * -Physics.gravity / m_Voxels.Length;
133 |
134 | float submergedVolume = 0f;
135 |
136 | for (int i = 0; i < len; i++)
137 | {
138 | Vector3 worldPoint = transform.TransformPoint(m_Voxels[i]);
139 |
140 | float submergedFactor = 0;
141 |
142 | if (worldPoint.y < water.transform.position.y)
143 | {
144 | submergedFactor = 1;// i / planeVoxels + voxelSize.y*0.5f;
145 | submergedVolume += submergedFactor;
146 | }
147 |
148 |
149 | Vector3 surfaceNormal = water.GetSurfaceNormal(worldPoint);
150 | Quaternion surfaceRotation = Quaternion.FromToRotation(water.transform.up, surfaceNormal);
151 | surfaceRotation = Quaternion.Slerp(surfaceRotation, Quaternion.identity, submergedFactor);
152 |
153 | Vector3 finalVoxelForce = surfaceRotation * force * submergedFactor;
154 | m_Rigidbody.AddForceAtPosition(finalVoxelForce, worldPoint);
155 |
156 | Debug.DrawLine(worldPoint, worldPoint + finalVoxelForce.normalized, Color.blue);
157 | }
158 |
159 | submergedVolume /= len;
160 |
161 | m_Rigidbody.drag = Mathf.Lerp(this.initialDrag, this.dragInWater, submergedVolume);
162 | m_Rigidbody.angularDrag = Mathf.Lerp(this.initialAngularDrag, this.angularDragInWater, submergedVolume);
163 | }
164 | }
165 |
166 |
167 | }
168 | }
--------------------------------------------------------------------------------
/Assets/Scripts/core/ReflectCamera.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace LinHowe.WaterRender
4 | {
5 | ///
6 | /// 反射相机
7 | ///
8 |
9 | public class ReflectCamera : MonoBehaviour
10 | {
11 | private RenderTexture MirrorTexture;//镜像纹理
12 | private Camera m_camera;
13 | private Material WaterMat;
14 | private bool isInit = false,isRender =false;
15 |
16 | private void Init()
17 | {
18 | MirrorTexture = RenderTexture.GetTemporary(512, 512, 16);
19 |
20 | m_camera = new GameObject("ReflectCamera").AddComponent();
21 | m_camera.enabled = false;
22 | m_camera.hideFlags = HideFlags.HideInHierarchy;
23 | Transform t = m_camera.transform;
24 | t.position = transform.position;
25 | t.rotation = transform.rotation;
26 |
27 | Camera curCamera = Camera.current;
28 | CopyCamera(curCamera, m_camera);
29 |
30 | WaterMat = GetComponent().sharedMaterial;
31 |
32 | MirrorTexture.isPowerOfTwo = true;
33 |
34 | m_camera.targetTexture = MirrorTexture;
35 | m_camera.cullingMask = ~(1 << 4) & -1; //设置可以反射的物体
36 |
37 | WaterMat.SetTexture("_WaterReflectTexture", MirrorTexture);
38 | }
39 |
40 | private void OnDestroy()
41 | {
42 | if(MirrorTexture) RenderTexture.ReleaseTemporary(MirrorTexture);
43 |
44 | }
45 | private static void CopyCamera(Camera src, Camera dest)
46 | {
47 |
48 | dest.clearFlags = src.clearFlags;
49 | dest.backgroundColor = src.backgroundColor;
50 | dest.farClipPlane = src.farClipPlane;
51 | dest.nearClipPlane = src.nearClipPlane;
52 | dest.orthographic = src.orthographic;
53 | dest.fieldOfView = src.fieldOfView;
54 | dest.aspect = src.aspect;
55 | dest.orthographicSize = src.orthographicSize;
56 | dest.depthTextureMode = DepthTextureMode.None;
57 | dest.renderingPath = RenderingPath.Forward;
58 | }
59 |
60 | ///
61 | /// 计算反射矩阵
62 | /// 原理https://www.cnblogs.com/wantnon/p/5630915.html
63 | ///
64 | ///
65 | ///
66 | private static void CalculateReflectionMatrix(ref Matrix4x4 reflectionMatrix, Vector4 plane)
67 | {
68 | reflectionMatrix.m00 = (1F - 2F * plane[0] * plane[0]);
69 | reflectionMatrix.m01 = (-2F * plane[0] * plane[1]);
70 | reflectionMatrix.m02 = (-2F * plane[0] * plane[2]);
71 | reflectionMatrix.m03 = (-2F * plane[3] * plane[0]);
72 |
73 | reflectionMatrix.m10 = (-2F * plane[1] * plane[0]);
74 | reflectionMatrix.m11 = (1F - 2F * plane[1] * plane[1]);
75 | reflectionMatrix.m12 = (-2F * plane[1] * plane[2]);
76 | reflectionMatrix.m13 = (-2F * plane[3] * plane[1]);
77 |
78 | reflectionMatrix.m20 = (-2F * plane[2] * plane[0]);
79 | reflectionMatrix.m21 = (-2F * plane[2] * plane[1]);
80 | reflectionMatrix.m22 = (1F - 2F * plane[2] * plane[2]);
81 | reflectionMatrix.m23 = (-2F * plane[3] * plane[2]);
82 |
83 | reflectionMatrix.m30 = 0F;
84 | reflectionMatrix.m31 = 0F;
85 | reflectionMatrix.m32 = 0F;
86 | reflectionMatrix.m33 = 1F;
87 | }
88 |
89 | private static float SignExt(float a)
90 | {
91 | if (a > 0.0f) return 1.0f;
92 | if (a < 0.0f) return -1.0f;
93 | return 0.0f;
94 | }
95 |
96 |
97 | /////
98 | /////
99 | /////
100 | /////
101 | /////
102 | //private static void CalculateObliqueMatrix(ref Matrix4x4 projection, Vector4 clipPlane)
103 | //{
104 | // Vector4 q = projection.inverse * new Vector4(SignExt(clipPlane.x), SignExt(clipPlane.y), 1.0f, 1.0f);
105 | // Vector4 c = clipPlane * (2.0F / (Vector4.Dot(clipPlane, q)));
106 |
107 | // projection[2] = c.x - projection[3];
108 | // projection[6] = c.y - projection[7];
109 | // projection[10] = c.z - projection[11];
110 | // projection[14] = c.w - projection[15];
111 | //}
112 |
113 | private void OnWillRenderObject()
114 | {
115 | if(!isInit)
116 | {
117 | Init();
118 | isInit = true;
119 | }
120 | if (isRender) return;
121 | isRender = true;
122 |
123 | Vector3 pos = transform.position;
124 | Vector3 normal = transform.up;
125 | Camera curCamera = Camera.current;
126 |
127 | //计算反射矩阵
128 | float d = -Vector3.Dot(normal, pos);
129 | Vector4 reflectionPlane = new Vector4(normal.x, normal.y, normal.z, d);
130 | Matrix4x4 reflectionMatrix = Matrix4x4.zero;
131 | CalculateReflectionMatrix(ref reflectionMatrix, reflectionPlane);
132 |
133 | Vector3 oldpos = curCamera.transform.position;
134 | Vector3 newpos = reflectionMatrix.MultiplyPoint(oldpos);
135 |
136 | Matrix4x4 m = m_camera.worldToCameraMatrix = curCamera.worldToCameraMatrix * reflectionMatrix;
137 |
138 | //计算剪切面
139 | Vector3 cpos = m.MultiplyPoint(pos);
140 | Vector3 cnormal = m.MultiplyVector(normal).normalized;
141 | Vector4 clipPlane = new Vector4(cnormal.x, cnormal.y, cnormal.z, -Vector3.Dot(cpos, cnormal));
142 |
143 | //计算出剪切面相关的投影矩阵,剪切面以下内容不显示
144 | Matrix4x4 projection = curCamera.projectionMatrix;
145 | projection = curCamera.CalculateObliqueMatrix(clipPlane);
146 | m_camera.projectionMatrix = projection;
147 |
148 | //反射相机渲染
149 | GL.invertCulling = true;//渲染的顶点做了翻转操作,但法线没有,所以背面会消隐,该操作翻转剔除操作
150 | {
151 | m_camera.transform.position = newpos;
152 | Vector3 euler = curCamera.transform.eulerAngles;
153 | m_camera.transform.eulerAngles = new Vector3(0, euler.y, euler.z);
154 | m_camera.Render();
155 | m_camera.transform.position = oldpos;
156 | }
157 | GL.invertCulling = false;
158 | isRender = false;
159 | }
160 |
161 |
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/ProjectSettings/InputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!13 &1
4 | InputManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Axes:
8 | - serializedVersion: 3
9 | m_Name: Horizontal
10 | descriptiveName:
11 | descriptiveNegativeName:
12 | negativeButton: left
13 | positiveButton: right
14 | altNegativeButton: a
15 | altPositiveButton: d
16 | gravity: 3
17 | dead: 0.001
18 | sensitivity: 3
19 | snap: 1
20 | invert: 0
21 | type: 0
22 | axis: 0
23 | joyNum: 0
24 | - serializedVersion: 3
25 | m_Name: Vertical
26 | descriptiveName:
27 | descriptiveNegativeName:
28 | negativeButton: down
29 | positiveButton: up
30 | altNegativeButton: s
31 | altPositiveButton: w
32 | gravity: 3
33 | dead: 0.001
34 | sensitivity: 3
35 | snap: 1
36 | invert: 0
37 | type: 0
38 | axis: 0
39 | joyNum: 0
40 | - serializedVersion: 3
41 | m_Name: Fire1
42 | descriptiveName:
43 | descriptiveNegativeName:
44 | negativeButton:
45 | positiveButton: left ctrl
46 | altNegativeButton:
47 | altPositiveButton: mouse 0
48 | gravity: 1000
49 | dead: 0.001
50 | sensitivity: 1000
51 | snap: 0
52 | invert: 0
53 | type: 0
54 | axis: 0
55 | joyNum: 0
56 | - serializedVersion: 3
57 | m_Name: Fire2
58 | descriptiveName:
59 | descriptiveNegativeName:
60 | negativeButton:
61 | positiveButton: left alt
62 | altNegativeButton:
63 | altPositiveButton: mouse 1
64 | gravity: 1000
65 | dead: 0.001
66 | sensitivity: 1000
67 | snap: 0
68 | invert: 0
69 | type: 0
70 | axis: 0
71 | joyNum: 0
72 | - serializedVersion: 3
73 | m_Name: Fire3
74 | descriptiveName:
75 | descriptiveNegativeName:
76 | negativeButton:
77 | positiveButton: left shift
78 | altNegativeButton:
79 | altPositiveButton: mouse 2
80 | gravity: 1000
81 | dead: 0.001
82 | sensitivity: 1000
83 | snap: 0
84 | invert: 0
85 | type: 0
86 | axis: 0
87 | joyNum: 0
88 | - serializedVersion: 3
89 | m_Name: Jump
90 | descriptiveName:
91 | descriptiveNegativeName:
92 | negativeButton:
93 | positiveButton: space
94 | altNegativeButton:
95 | altPositiveButton:
96 | gravity: 1000
97 | dead: 0.001
98 | sensitivity: 1000
99 | snap: 0
100 | invert: 0
101 | type: 0
102 | axis: 0
103 | joyNum: 0
104 | - serializedVersion: 3
105 | m_Name: Mouse X
106 | descriptiveName:
107 | descriptiveNegativeName:
108 | negativeButton:
109 | positiveButton:
110 | altNegativeButton:
111 | altPositiveButton:
112 | gravity: 0
113 | dead: 0
114 | sensitivity: 0.1
115 | snap: 0
116 | invert: 0
117 | type: 1
118 | axis: 0
119 | joyNum: 0
120 | - serializedVersion: 3
121 | m_Name: Mouse Y
122 | descriptiveName:
123 | descriptiveNegativeName:
124 | negativeButton:
125 | positiveButton:
126 | altNegativeButton:
127 | altPositiveButton:
128 | gravity: 0
129 | dead: 0
130 | sensitivity: 0.1
131 | snap: 0
132 | invert: 0
133 | type: 1
134 | axis: 1
135 | joyNum: 0
136 | - serializedVersion: 3
137 | m_Name: Mouse ScrollWheel
138 | descriptiveName:
139 | descriptiveNegativeName:
140 | negativeButton:
141 | positiveButton:
142 | altNegativeButton:
143 | altPositiveButton:
144 | gravity: 0
145 | dead: 0
146 | sensitivity: 0.1
147 | snap: 0
148 | invert: 0
149 | type: 1
150 | axis: 2
151 | joyNum: 0
152 | - serializedVersion: 3
153 | m_Name: Horizontal
154 | descriptiveName:
155 | descriptiveNegativeName:
156 | negativeButton:
157 | positiveButton:
158 | altNegativeButton:
159 | altPositiveButton:
160 | gravity: 0
161 | dead: 0.19
162 | sensitivity: 1
163 | snap: 0
164 | invert: 0
165 | type: 2
166 | axis: 0
167 | joyNum: 0
168 | - serializedVersion: 3
169 | m_Name: Vertical
170 | descriptiveName:
171 | descriptiveNegativeName:
172 | negativeButton:
173 | positiveButton:
174 | altNegativeButton:
175 | altPositiveButton:
176 | gravity: 0
177 | dead: 0.19
178 | sensitivity: 1
179 | snap: 0
180 | invert: 1
181 | type: 2
182 | axis: 1
183 | joyNum: 0
184 | - serializedVersion: 3
185 | m_Name: Fire1
186 | descriptiveName:
187 | descriptiveNegativeName:
188 | negativeButton:
189 | positiveButton: joystick button 0
190 | altNegativeButton:
191 | altPositiveButton:
192 | gravity: 1000
193 | dead: 0.001
194 | sensitivity: 1000
195 | snap: 0
196 | invert: 0
197 | type: 0
198 | axis: 0
199 | joyNum: 0
200 | - serializedVersion: 3
201 | m_Name: Fire2
202 | descriptiveName:
203 | descriptiveNegativeName:
204 | negativeButton:
205 | positiveButton: joystick button 1
206 | altNegativeButton:
207 | altPositiveButton:
208 | gravity: 1000
209 | dead: 0.001
210 | sensitivity: 1000
211 | snap: 0
212 | invert: 0
213 | type: 0
214 | axis: 0
215 | joyNum: 0
216 | - serializedVersion: 3
217 | m_Name: Fire3
218 | descriptiveName:
219 | descriptiveNegativeName:
220 | negativeButton:
221 | positiveButton: joystick button 2
222 | altNegativeButton:
223 | altPositiveButton:
224 | gravity: 1000
225 | dead: 0.001
226 | sensitivity: 1000
227 | snap: 0
228 | invert: 0
229 | type: 0
230 | axis: 0
231 | joyNum: 0
232 | - serializedVersion: 3
233 | m_Name: Jump
234 | descriptiveName:
235 | descriptiveNegativeName:
236 | negativeButton:
237 | positiveButton: joystick button 3
238 | altNegativeButton:
239 | altPositiveButton:
240 | gravity: 1000
241 | dead: 0.001
242 | sensitivity: 1000
243 | snap: 0
244 | invert: 0
245 | type: 0
246 | axis: 0
247 | joyNum: 0
248 | - serializedVersion: 3
249 | m_Name: Submit
250 | descriptiveName:
251 | descriptiveNegativeName:
252 | negativeButton:
253 | positiveButton: return
254 | altNegativeButton:
255 | altPositiveButton: joystick button 0
256 | gravity: 1000
257 | dead: 0.001
258 | sensitivity: 1000
259 | snap: 0
260 | invert: 0
261 | type: 0
262 | axis: 0
263 | joyNum: 0
264 | - serializedVersion: 3
265 | m_Name: Submit
266 | descriptiveName:
267 | descriptiveNegativeName:
268 | negativeButton:
269 | positiveButton: enter
270 | altNegativeButton:
271 | altPositiveButton: space
272 | gravity: 1000
273 | dead: 0.001
274 | sensitivity: 1000
275 | snap: 0
276 | invert: 0
277 | type: 0
278 | axis: 0
279 | joyNum: 0
280 | - serializedVersion: 3
281 | m_Name: Cancel
282 | descriptiveName:
283 | descriptiveNegativeName:
284 | negativeButton:
285 | positiveButton: escape
286 | altNegativeButton:
287 | altPositiveButton: joystick button 1
288 | gravity: 1000
289 | dead: 0.001
290 | sensitivity: 1000
291 | snap: 0
292 | invert: 0
293 | type: 0
294 | axis: 0
295 | joyNum: 0
296 |
--------------------------------------------------------------------------------
/Assets/Prefabs/Water.prefab:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1001 &100100000
4 | Prefab:
5 | m_ObjectHideFlags: 1
6 | serializedVersion: 2
7 | m_Modification:
8 | m_TransformParent: {fileID: 0}
9 | m_Modifications: []
10 | m_RemovedComponents: []
11 | m_ParentPrefab: {fileID: 0}
12 | m_RootGameObject: {fileID: 1623687497035066}
13 | m_IsPrefabParent: 1
14 | --- !u!1 &1299437505971242
15 | GameObject:
16 | m_ObjectHideFlags: 0
17 | m_PrefabParentObject: {fileID: 0}
18 | m_PrefabInternal: {fileID: 100100000}
19 | serializedVersion: 5
20 | m_Component:
21 | - component: {fileID: 4773415176013616}
22 | - component: {fileID: 20055055807154726}
23 | - component: {fileID: 124242931751583312}
24 | - component: {fileID: 81717627046905738}
25 | - component: {fileID: 114608972004171434}
26 | m_Layer: 0
27 | m_Name: Main Camera
28 | m_TagString: MainCamera
29 | m_Icon: {fileID: 0}
30 | m_NavMeshLayer: 0
31 | m_StaticEditorFlags: 0
32 | m_IsActive: 1
33 | --- !u!1 &1462712892622830
34 | GameObject:
35 | m_ObjectHideFlags: 0
36 | m_PrefabParentObject: {fileID: 0}
37 | m_PrefabInternal: {fileID: 100100000}
38 | serializedVersion: 5
39 | m_Component:
40 | - component: {fileID: 4769697928826940}
41 | - component: {fileID: 114445022955975918}
42 | m_Layer: 0
43 | m_Name: WaterBody
44 | m_TagString: Untagged
45 | m_Icon: {fileID: 0}
46 | m_NavMeshLayer: 0
47 | m_StaticEditorFlags: 0
48 | m_IsActive: 1
49 | --- !u!1 &1623687497035066
50 | GameObject:
51 | m_ObjectHideFlags: 0
52 | m_PrefabParentObject: {fileID: 0}
53 | m_PrefabInternal: {fileID: 100100000}
54 | serializedVersion: 5
55 | m_Component:
56 | - component: {fileID: 4140759847350974}
57 | - component: {fileID: 65026031802465156}
58 | - component: {fileID: 114859584621364724}
59 | m_Layer: 0
60 | m_Name: Water
61 | m_TagString: Untagged
62 | m_Icon: {fileID: 0}
63 | m_NavMeshLayer: 0
64 | m_StaticEditorFlags: 0
65 | m_IsActive: 1
66 | --- !u!4 &4140759847350974
67 | Transform:
68 | m_ObjectHideFlags: 1
69 | m_PrefabParentObject: {fileID: 0}
70 | m_PrefabInternal: {fileID: 100100000}
71 | m_GameObject: {fileID: 1623687497035066}
72 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
73 | m_LocalPosition: {x: 0, y: 0, z: 0}
74 | m_LocalScale: {x: 1, y: 1, z: 1}
75 | m_Children:
76 | - {fileID: 4773415176013616}
77 | - {fileID: 4769697928826940}
78 | m_Father: {fileID: 0}
79 | m_RootOrder: 0
80 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
81 | --- !u!4 &4769697928826940
82 | Transform:
83 | m_ObjectHideFlags: 1
84 | m_PrefabParentObject: {fileID: 0}
85 | m_PrefabInternal: {fileID: 100100000}
86 | m_GameObject: {fileID: 1462712892622830}
87 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
88 | m_LocalPosition: {x: 0, y: 0, z: 0}
89 | m_LocalScale: {x: 1, y: 1, z: 1}
90 | m_Children: []
91 | m_Father: {fileID: 4140759847350974}
92 | m_RootOrder: 1
93 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
94 | --- !u!4 &4773415176013616
95 | Transform:
96 | m_ObjectHideFlags: 1
97 | m_PrefabParentObject: {fileID: 0}
98 | m_PrefabInternal: {fileID: 100100000}
99 | m_GameObject: {fileID: 1299437505971242}
100 | m_LocalRotation: {x: 0.17364816, y: -0, z: -0, w: 0.9848078}
101 | m_LocalPosition: {x: 0, y: 3, z: -8}
102 | m_LocalScale: {x: 1, y: 1, z: 1}
103 | m_Children: []
104 | m_Father: {fileID: 4140759847350974}
105 | m_RootOrder: 0
106 | m_LocalEulerAnglesHint: {x: 20, y: 0, z: 0}
107 | --- !u!20 &20055055807154726
108 | Camera:
109 | m_ObjectHideFlags: 1
110 | m_PrefabParentObject: {fileID: 0}
111 | m_PrefabInternal: {fileID: 100100000}
112 | m_GameObject: {fileID: 1299437505971242}
113 | m_Enabled: 1
114 | serializedVersion: 2
115 | m_ClearFlags: 1
116 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
117 | m_NormalizedViewPortRect:
118 | serializedVersion: 2
119 | x: 0
120 | y: 0
121 | width: 1
122 | height: 1
123 | near clip plane: 0.3
124 | far clip plane: 1000
125 | field of view: 60
126 | orthographic: 0
127 | orthographic size: 5
128 | m_Depth: -1
129 | m_CullingMask:
130 | serializedVersion: 2
131 | m_Bits: 4294967295
132 | m_RenderingPath: -1
133 | m_TargetTexture: {fileID: 0}
134 | m_TargetDisplay: 0
135 | m_TargetEye: 3
136 | m_HDR: 1
137 | m_AllowMSAA: 1
138 | m_ForceIntoRT: 0
139 | m_OcclusionCulling: 1
140 | m_StereoConvergence: 10
141 | m_StereoSeparation: 0.022
142 | m_StereoMirrorMode: 0
143 | --- !u!65 &65026031802465156
144 | BoxCollider:
145 | m_ObjectHideFlags: 1
146 | m_PrefabParentObject: {fileID: 0}
147 | m_PrefabInternal: {fileID: 100100000}
148 | m_GameObject: {fileID: 1623687497035066}
149 | m_Material: {fileID: 0}
150 | m_IsTrigger: 0
151 | m_Enabled: 1
152 | serializedVersion: 2
153 | m_Size: {x: 9, y: 0.07, z: 9}
154 | m_Center: {x: 0, y: 0, z: 0}
155 | --- !u!81 &81717627046905738
156 | AudioListener:
157 | m_ObjectHideFlags: 1
158 | m_PrefabParentObject: {fileID: 0}
159 | m_PrefabInternal: {fileID: 100100000}
160 | m_GameObject: {fileID: 1299437505971242}
161 | m_Enabled: 1
162 | --- !u!114 &114445022955975918
163 | MonoBehaviour:
164 | m_ObjectHideFlags: 1
165 | m_PrefabParentObject: {fileID: 0}
166 | m_PrefabInternal: {fileID: 100100000}
167 | m_GameObject: {fileID: 1462712892622830}
168 | m_Enabled: 1
169 | m_EditorHideFlags: 0
170 | m_Script: {fileID: 11500000, guid: a6d92144eaab86e4fb00f81f7140272e, type: 3}
171 | m_Name:
172 | m_EditorClassIdentifier:
173 | width: 9
174 | length: 9
175 | cellSize: 0.1
176 | depth: 4.6
177 | material: {fileID: 2100000, guid: 698d75988f8b6db4a8d905a2658cac94, type: 2}
178 | --- !u!114 &114608972004171434
179 | MonoBehaviour:
180 | m_ObjectHideFlags: 1
181 | m_PrefabParentObject: {fileID: 0}
182 | m_PrefabInternal: {fileID: 100100000}
183 | m_GameObject: {fileID: 1299437505971242}
184 | m_Enabled: 1
185 | m_EditorHideFlags: 0
186 | m_Script: {fileID: 11500000, guid: aa4274f7525bb974d8e5bf36ea5ca014, type: 3}
187 | m_Name:
188 | m_EditorClassIdentifier:
189 | water: {fileID: 114859584621364724}
190 | swipeSize: 0.4
191 | swipeMesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
192 | height: 0
193 | force: 1
194 | --- !u!114 &114859584621364724
195 | MonoBehaviour:
196 | m_ObjectHideFlags: 1
197 | m_PrefabParentObject: {fileID: 0}
198 | m_PrefabInternal: {fileID: 100100000}
199 | m_GameObject: {fileID: 1623687497035066}
200 | m_Enabled: 1
201 | m_EditorHideFlags: 0
202 | m_Script: {fileID: 11500000, guid: 32d68a9644d8cb64593e6c7fbb7c238f, type: 3}
203 | m_Name:
204 | m_EditorClassIdentifier:
205 | width: 9
206 | length: 9
207 | cellSize: 0.1
208 | material: {fileID: 2100000, guid: 970a389ba39ecb44b8c1ce961104493d, type: 2}
209 | depth: 4.6
210 | MapSize: 128
211 | Velocity: 0.8
212 | Viscosity: 0.84
213 | waveEquationShader: {fileID: 4800000, guid: cf7868a9f3dab4143b12b3e91f9f5967, type: 3}
214 | normalGenerateShader: {fileID: 4800000, guid: e1b474b4cdd9c184a9235735a3b99d14,
215 | type: 3}
216 | forceShader: {fileID: 4800000, guid: cf78a4d8b76ee934fa6bdb284ce6088d, type: 3}
217 | forceFactor: 1
218 | --- !u!124 &124242931751583312
219 | Behaviour:
220 | m_ObjectHideFlags: 1
221 | m_PrefabParentObject: {fileID: 0}
222 | m_PrefabInternal: {fileID: 100100000}
223 | m_GameObject: {fileID: 1299437505971242}
224 | m_Enabled: 1
225 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/WaterBody.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | namespace LinHowe.WaterRender
6 | {
7 |
8 | public class WaterBody : MonoBehaviour
9 | {
10 | //需要配置的参数
11 | public float width, length, cellSize;//水宽度,长度,单元格大小
12 | public float depth;//水深度
13 | public Material material;//水体材质
14 |
15 | private MeshRenderer mr;
16 | private MeshFilter mf;
17 | private Mesh mesh;
18 |
19 | private void Start()
20 | {
21 | if(material == null)
22 | {
23 | Debug.LogError("Please add material");
24 | return;
25 | }
26 | InitComponent();
27 | InitMesh();
28 | InitMat();
29 | }
30 |
31 | private void InitMat()
32 | {
33 | //水体包围盒
34 | Vector3 BoundingBoxMin = new Vector3
35 | (
36 | transform.position.x - width * 0.5f,
37 | transform.position.y - depth,
38 | transform.position.z - length * 0.5f
39 | );
40 | Vector3 BoundingBoxMax = new Vector3
41 | (
42 | transform.position.x + width * 0.5f,
43 | transform.position.y,
44 | transform.position.z + length * 0.5f
45 | );
46 |
47 | //水体平面
48 | Vector4 WaterPlane =
49 | new Vector4
50 | (
51 | 0, 1, 0,
52 | Vector3.Dot(new Vector3(0, 1, 0), transform.position)
53 | );
54 |
55 | Vector3 BoundingBoxSize = BoundingBoxMax - BoundingBoxMin;
56 |
57 | Shader.SetGlobalVector("_BoundingBoxMin", BoundingBoxMin);
58 | Shader.SetGlobalVector("_BoundingBoxMax", BoundingBoxMax);
59 | material.SetVector("_BoundingBoxSize", BoundingBoxSize);
60 | material.SetVector("_WaterPlane", WaterPlane);
61 | }
62 | private void InitComponent()
63 | {
64 | mr = gameObject.GetComponent();
65 | if (mr == null)
66 | mr = gameObject.AddComponent();
67 | mf = gameObject.GetComponent();
68 | if (mf == null)
69 | mf = gameObject.AddComponent();
70 | }
71 |
72 | private void InitMesh()
73 | {
74 | int xsize = Mathf.RoundToInt(width / cellSize);
75 | int ysize = Mathf.RoundToInt(length / cellSize);
76 |
77 | mesh = new Mesh();
78 |
79 | int ListCapacity = 4 * (ysize + 1) + 4 * (xsize + 1);
80 | List vertexList = new List(ListCapacity);
81 | List normalList = new List(ListCapacity);
82 | List uvList = new List(ListCapacity);
83 | List colorList = new List(ListCapacity);
84 | List indexList = new List(ListCapacity * 3);
85 |
86 | float xcellsize = width / xsize;
87 | float uvxcellsize = 1.0f / xsize;
88 | float ycellsize = length / ysize;
89 | float uvycellsize = 1.0f / ysize;
90 |
91 | for (int i = 0; i <= ysize; i++)
92 | {
93 | vertexList.Add(new Vector3(-width * 0.5f, -depth, -length * 0.5f + i * ycellsize));
94 | vertexList.Add(new Vector3(-width * 0.5f, 0, -length * 0.5f + i * ycellsize));
95 | vertexList.Add(new Vector3(width * 0.5f, -depth, -length * 0.5f + i * ycellsize));
96 | vertexList.Add(new Vector3(width * 0.5f, 0, -length * 0.5f + i * ycellsize));
97 | normalList.Add(Vector3.left);
98 | normalList.Add(Vector3.left);
99 | normalList.Add(Vector3.right);
100 | normalList.Add(Vector3.right);
101 | colorList.Add(Color.white);
102 | colorList.Add(new Color(1, 1, 1, 0));
103 | colorList.Add(Color.white);
104 | colorList.Add(new Color(1, 1, 1, 0));
105 | uvList.Add(new Vector2(0, i * uvycellsize));
106 | uvList.Add(new Vector2(0, i * uvycellsize));
107 | uvList.Add(new Vector2(1, i * uvycellsize));
108 | uvList.Add(new Vector2(1, i * uvycellsize));
109 |
110 | if (i < ysize)
111 | {
112 | indexList.Add(i * 4);
113 | indexList.Add((i + 1) * 4 + 1);
114 | indexList.Add(i * 4 + 1);
115 | indexList.Add(i * 4);
116 | indexList.Add((i + 1) * 4);
117 | indexList.Add((i + 1) * 4 + 1);
118 |
119 | indexList.Add((i + 1) * 4 + 2);
120 | indexList.Add(i * 4 + 3);
121 | indexList.Add((i + 1) * 4 + 3);
122 | indexList.Add((i + 1) * 4 + 2);
123 | indexList.Add(i * 4 + 2);
124 | indexList.Add(i * 4 + 3);
125 | }
126 | }
127 |
128 | for (int j = 0; j <= xsize; j++)
129 | {
130 | vertexList.Add(new Vector3(-width * 0.5f + j * xcellsize, -depth, -length * 0.5f));
131 | vertexList.Add(new Vector3(-width * 0.5f + j * xcellsize, 0, -length * 0.5f));
132 | vertexList.Add(new Vector3(-width * 0.5f + j * xcellsize, -depth, length * 0.5f));
133 | vertexList.Add(new Vector3(-width * 0.5f + j * xcellsize, 0, length * 0.5f));
134 | normalList.Add(Vector3.back);
135 | normalList.Add(Vector3.back);
136 | normalList.Add(Vector3.forward);
137 | normalList.Add(Vector3.forward);
138 | colorList.Add(Color.white);
139 | colorList.Add(new Color(1, 1, 1, 0));
140 | colorList.Add(Color.white);
141 | colorList.Add(new Color(1, 1, 1, 0));
142 | uvList.Add(new Vector2(j * uvxcellsize, 0));
143 | uvList.Add(new Vector2(j * uvxcellsize, 0));
144 | uvList.Add(new Vector2(j * uvxcellsize, 1));
145 | uvList.Add(new Vector2(j * uvxcellsize, 1));
146 |
147 | if (j < xsize)
148 | {
149 | indexList.Add((ysize + 1) * 4 + j * 4);
150 | indexList.Add((ysize + 1) * 4 + j * 4 + 1);
151 | indexList.Add((ysize + 1) * 4 + (j + 1) * 4 + 1);
152 | indexList.Add((ysize + 1) * 4 + j * 4);
153 | indexList.Add((ysize + 1) * 4 + (j + 1) * 4 + 1);
154 | indexList.Add((ysize + 1) * 4 + (j + 1) * 4);
155 |
156 | indexList.Add((ysize + 1) * 4 + (j + 1) * 4 + 2);
157 | indexList.Add((ysize + 1) * 4 + (j + 1) * 4 + 3);
158 | indexList.Add((ysize + 1) * 4 + j * 4 + 3);
159 | indexList.Add((ysize + 1) * 4 + (j + 1) * 4 + 2);
160 | indexList.Add((ysize + 1) * 4 + j * 4 + 3);
161 | indexList.Add((ysize + 1) * 4 + j * 4 + 2);
162 | }
163 | }
164 |
165 | mesh.SetVertices(vertexList);
166 | mesh.SetNormals(normalList);
167 | mesh.SetColors(colorList);
168 | mesh.SetUVs(0, uvList);
169 | mesh.SetTriangles(indexList, 0);
170 | mesh.RecalculateNormals();
171 | mesh.RecalculateTangents();
172 |
173 | mf.sharedMesh = mesh;
174 | mr.sharedMaterial = material;
175 | }
176 | }
177 | }
178 |
179 |
--------------------------------------------------------------------------------
/Assets/Scripts/WaveEquation/TestWaveEquation.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 | using System;
5 |
6 |
7 | namespace LinHowe.WaveEquation
8 | {
9 | ///
10 | /// 测试波动方程
11 | ///
12 | public class TestWaveEquation : MonoBehaviour
13 | {
14 | //需要配置的参数
15 | public int Xsize = 90;//x轴绘制的精度
16 | public Material mat = null;//水材质
17 | public float u = 0.894f;//液体粘稠度
18 |
19 |
20 | private MeshRenderer mr;
21 | private MeshFilter mf;
22 |
23 | private Mesh mesh;
24 |
25 | //波形顶点位置
26 | private List VertexList = new List();
27 |
28 | //记录的前个时间点的波形位置
29 | private List LastVertexList = new List();
30 |
31 | //记录的下个时间点的波形位置
32 | private List NextVertexList = new List();
33 |
34 | private List Indexes = new List();
35 |
36 | //波速和dx
37 | public float c, d;
38 |
39 | private float K1, K2, K3;
40 |
41 | private float minX;
42 | ///
43 | /// 将xOy平面上的单位正方形转换到物体坐标系
44 | ///
45 | ///
46 | ///
47 | private Vector3 CubeToLocal(Vector3 PosInCube)
48 | {
49 | Vector3 PosInCamera = Camera.main.projectionMatrix.inverse.MultiplyPoint(PosInCube);
50 | Vector3 PosInWorld = Camera.main.cameraToWorldMatrix.MultiplyPoint(PosInCamera);
51 | Vector3 PosInLocal = transform.worldToLocalMatrix.MultiplyPoint(PosInWorld);
52 | return PosInLocal;
53 | }
54 |
55 | private void Awake()
56 | {
57 | InitMesh();
58 | RandomWave();
59 | }
60 | ///
61 | /// 初始化组件
62 | ///
63 | private void InitComponents()
64 | {
65 | mr = GetComponent();
66 | if(null == mr)
67 | mr = gameObject.AddComponent();
68 | mf = GetComponent();
69 | if (null == mf)
70 | mf = gameObject.AddComponent();
71 | }
72 |
73 | ///
74 | /// 网格初始化
75 | ///
76 | private void InitMesh()
77 | {
78 | InitComponents();
79 |
80 | if (mat == null)
81 | mat = new Material(Shader.Find("Diffuse"));
82 | mesh = new Mesh();
83 | mr.sharedMaterial = mat;
84 | mf.sharedMesh = mesh;
85 |
86 | //为List分配好容量
87 | int PointsNumber = Xsize * 2 + 2;
88 | if (PointsNumber < 0)
89 | PointsNumber = 0;
90 | VertexList = new List(PointsNumber);
91 | LastVertexList = new List(PointsNumber);
92 | NextVertexList = new List(PointsNumber);
93 | Indexes = new List(PointsNumber);
94 |
95 | DrawMesh();
96 |
97 | mesh.SetVertices(VertexList);
98 | mesh.SetTriangles(Indexes, 0);
99 |
100 | Vector3 ZeroCenter = CubeToLocal(Vector3.zero);
101 |
102 | float HalfXLength = CubeToLocal(Vector3.right).x - ZeroCenter.x;
103 | d = HalfXLength / (Xsize / 2);
104 |
105 | minX = CubeToLocal(Vector3.left).x;
106 | }
107 |
108 | ///
109 | /// 绘制网格
110 | ///
111 | private void DrawMesh()
112 | {
113 |
114 | Vector3 p1 = new Vector3(-1, -1, 0);
115 | Vector3 p2 = Vector3.left;
116 | if (Xsize < 10)
117 | Xsize = 10;
118 | Vector3 deleteVector = new Vector3(2f / Xsize, 0,0);
119 |
120 |
121 | for (int i = 0;i <= Xsize; ++i,p1 += deleteVector,p2 += deleteVector)
122 | {
123 | Vector3 v1 = CubeToLocal(p1);
124 | Vector3 v2 = CubeToLocal(p2);
125 | VertexList.Add(v1);
126 | VertexList.Add(v2);
127 | LastVertexList.Add(v1);
128 | LastVertexList.Add(v2);
129 | NextVertexList.Add(v1);
130 | NextVertexList.Add(v2);
131 |
132 | //绘制四边形
133 | if (i < Xsize)
134 | {
135 | int j = i * 2;
136 | Indexes.Add(j);
137 | Indexes.Add(j + 1);
138 | Indexes.Add(j + 3);
139 | Indexes.Add(j);
140 | Indexes.Add(j + 3);
141 | Indexes.Add(j + 2);
142 | }
143 | }
144 | }
145 |
146 | private void FixedUpdate()
147 | {
148 | //公式来源 Mathematics for 3D Game Programming and Computer Graphics(third Edition)
149 | for (int i = 1; i < Xsize; i++)
150 | {
151 | float cy = VertexList[i * 2 + 1].y;
152 | float ly = LastVertexList[i * 2 + 1].y;
153 | float cy1 = VertexList[(i - 1) * 2 + 1].y;
154 | float cy2 = VertexList[(i + 1) * 2 + 1].y;
155 |
156 | float ny = cy * K1 + ly * K2 + (cy1 + cy2) * K3;
157 |
158 | Vector3 p = NextVertexList[i * 2 + 1];
159 | p.y = ny;
160 | NextVertexList[i * 2 + 1] = p;
161 | }
162 |
163 | for (int i = 0; i <= Xsize; i++)
164 | {
165 | int j = i * 2 + 1;
166 | LastVertexList[j] = VertexList[j];
167 | VertexList[j] = NextVertexList[j];
168 | }
169 | mesh.Clear();
170 | mesh.SetVertices(VertexList);
171 | mesh.SetTriangles(Indexes, 0);
172 |
173 | }
174 |
175 | private void RandomWave()
176 | {
177 |
178 | //速度
179 | c = UnityEngine.Random.Range(-10f, 10f);
180 |
181 | //液体粘稠度大于0
182 | u = Mathf.Clamp(u, 0.00000001f, float.MaxValue);
183 |
184 | //约束速度
185 | float cmax = d / 2 / Time.fixedDeltaTime * Mathf.Sqrt(u * Time.fixedDeltaTime + 2);
186 | c = Mathf.Clamp(c, -cmax, cmax);
187 |
188 | //约束时间间隔
189 | float tmax = (u - Mathf.Sqrt(u * u + 32 * c * c / d / d)) / (8 * c * c / d / d);
190 | if(tmax <= 0)
191 | {
192 | tmax = (u + Mathf.Sqrt(u * u + 32 * c * c / d / d)) / (8 * c * c / d / d);
193 | }
194 | if (tmax < Time.fixedDeltaTime)
195 | {
196 | RandomWave();
197 | return;
198 | }
199 |
200 | K3 = 2 * c * c * Time.fixedDeltaTime * Time.fixedDeltaTime / (d * d);
201 |
202 | K1 = (4 - 2 * K3)/(u * Time.fixedDeltaTime + 2);
203 |
204 | K2 = (u * Time.fixedDeltaTime - 2) / (u * Time.fixedDeltaTime + 2);
205 |
206 | K3 = K3/ (u * Time.fixedDeltaTime + 2);
207 | }
208 | void Update()
209 | {
210 | if (Input.GetMouseButton(0))
211 | {
212 | Vector3 worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
213 | AddWave(worldPos);
214 | }
215 | }
216 | private void AddWave(Vector3 pos)
217 | {
218 | Vector3 localPos = transform.worldToLocalMatrix.MultiplyPoint(pos);
219 |
220 | int hit = Mathf.RoundToInt((localPos.x - minX) / d);
221 | if (hit >= 0 && hit <= Xsize)
222 | {
223 | Vector3 p = VertexList[hit * 2 + 1];
224 | float force = UnityEngine.Random.Range(-0.1f, 0.2f);
225 | p.y += force;
226 | VertexList[hit * 2 + 1] = p;
227 | }
228 | }
229 |
230 | }
231 | }
232 |
233 |
--------------------------------------------------------------------------------
/Assets/Scripts/core/WaterCamera.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.Rendering;
4 |
5 | namespace LinHowe.WaterRender
6 | {
7 | ///
8 | /// 用以获取水面的各种信息
9 | ///
10 |
11 | public class WaterCamera:MonoBehaviour
12 | {
13 | private Camera m_Camera;
14 | private RenderTexture CurTexture;//当前渲染纹理
15 | private RenderTexture HeightMap;//高度纹理贴图
16 | private RenderTexture NormalMap;//法线纹理贴图
17 |
18 | private Material waveEquationMat;//波动方程材质
19 | private Material normalGenerateMat;//法线生成材质
20 | private Material forceMat;//力的材质
21 | private CommandBuffer m_CommandBuffer;
22 |
23 | private IWaveComponent waveComponent;
24 | public void InitMat(Shader waveEquationShader, Shader normalGenerateShader, Shader forceShader)
25 | {
26 | if (waveEquationShader) waveEquationMat = new Material(waveEquationShader);
27 | else waveEquationMat = new Material(Shader.Find("LinHowe/WaveEquation"));
28 |
29 | if (normalGenerateShader) normalGenerateMat = new Material(normalGenerateShader);
30 | else normalGenerateMat = new Material(Shader.Find("LinHowe/NormalGenerate"));
31 |
32 | if (forceShader) forceMat = new Material(forceShader);
33 | else forceMat = new Material(Shader.Find("LinHowe/Force"));
34 | }
35 |
36 | public void Init(float width, float height, float depth, int texSize, IWaveComponent waveComponent)
37 | {
38 | this.waveComponent = waveComponent;
39 | waveComponent.InitWaterCamera(texSize,waveEquationMat);
40 |
41 |
42 | m_Camera = gameObject.AddComponent();
43 | m_Camera.aspect = width / height;
44 | m_Camera.backgroundColor = Color.black;
45 | m_Camera.cullingMask = 0;
46 | m_Camera.depth = 0;
47 | m_Camera.farClipPlane = depth;
48 | m_Camera.nearClipPlane = 0;
49 | m_Camera.orthographic = true;
50 | m_Camera.orthographicSize = height * 0.5f;
51 | m_Camera.clearFlags = CameraClearFlags.Depth;
52 | m_Camera.allowHDR = false;
53 | m_CommandBuffer = new CommandBuffer();
54 | m_Camera.AddCommandBuffer(CameraEvent.AfterImageEffectsOpaque, m_CommandBuffer);
55 |
56 | RenderTexture tmp = RenderTexture.active;
57 |
58 | CurTexture = RenderTexture.GetTemporary(texSize, texSize, 16);
59 | CurTexture.name = "[CurTex]";
60 | RenderTexture.active = CurTexture;
61 | GL.Clear(false, true, new Color(0, 0, 0, 0));
62 |
63 | //PreTexture = RenderTexture.GetTemporary(texSize, texSize, 16);
64 | //PreTexture.name = "[PreTex]";
65 | //RenderTexture.active = PreTexture;
66 | //GL.Clear(false, true, new Color(0, 0, 0, 0));
67 |
68 | HeightMap = RenderTexture.GetTemporary(texSize, texSize, 16);
69 | HeightMap.name = "[HeightMap]";
70 | RenderTexture.active = HeightMap;
71 | GL.Clear(false, true, new Color(0, 0, 0, 0));
72 |
73 | NormalMap = RenderTexture.GetTemporary(texSize, texSize, 16);
74 | //NormalMap.format = RenderTextureFormat.ARGB32;
75 | NormalMap.name = "[NormalMap]";
76 |
77 | RenderTexture.active = tmp;
78 | m_Camera.targetTexture = CurTexture;
79 | }
80 |
81 | public void ForceDrawMesh(Mesh mesh, Matrix4x4 matrix)
82 | {
83 | if (null == mesh || null == m_CommandBuffer)
84 | return;
85 | m_CommandBuffer.DrawMesh(mesh, matrix, forceMat);
86 | }
87 |
88 | public void ForceDrawRenderer(Renderer renderer)
89 | {
90 | if (!renderer)
91 | return;
92 | if (IsBoundsInCamera(renderer.bounds, m_Camera))
93 | m_CommandBuffer.DrawRenderer(renderer, forceMat);
94 | }
95 |
96 | ///
97 | /// 判断包围盒是否被相机裁剪
98 | ///
99 | ///
100 | ///
101 | ///
102 | private static bool IsBoundsInCamera(Bounds bounds, Camera camera)
103 | {
104 |
105 | Matrix4x4 matrix = camera.projectionMatrix * camera.worldToCameraMatrix;
106 |
107 | int code =
108 | ComputeOutCode(new Vector4(bounds.center.x + bounds.size.x / 2, bounds.center.y + bounds.size.y / 2,
109 | bounds.center.z + bounds.size.z / 2, 1), matrix);
110 |
111 |
112 | code &=
113 | ComputeOutCode(new Vector4(bounds.center.x - bounds.size.x / 2, bounds.center.y + bounds.size.y / 2,
114 | bounds.center.z + bounds.size.z / 2, 1), matrix);
115 |
116 | code &=
117 | ComputeOutCode(new Vector4(bounds.center.x + bounds.size.x / 2, bounds.center.y - bounds.size.y / 2,
118 | bounds.center.z + bounds.size.z / 2, 1), matrix);
119 |
120 | code &=
121 | ComputeOutCode(new Vector4(bounds.center.x - bounds.size.x / 2, bounds.center.y - bounds.size.y / 2,
122 | bounds.center.z + bounds.size.z / 2, 1), matrix);
123 |
124 | code &=
125 | ComputeOutCode(new Vector4(bounds.center.x + bounds.size.x / 2, bounds.center.y + bounds.size.y / 2,
126 | bounds.center.z - bounds.size.z / 2, 1), matrix);
127 |
128 | code &=
129 | ComputeOutCode(new Vector4(bounds.center.x - bounds.size.x / 2, bounds.center.y + bounds.size.y / 2,
130 | bounds.center.z - bounds.size.z / 2, 1), matrix);
131 |
132 | code &=
133 | ComputeOutCode(new Vector4(bounds.center.x + bounds.size.x / 2, bounds.center.y - bounds.size.y / 2,
134 | bounds.center.z - bounds.size.z / 2, 1), matrix);
135 |
136 | code &=
137 | ComputeOutCode(new Vector4(bounds.center.x - bounds.size.x / 2, bounds.center.y - bounds.size.y / 2,
138 | bounds.center.z - bounds.size.z / 2, 1), matrix);
139 |
140 |
141 | if (code != 0) return false;
142 |
143 | return true;
144 | }
145 |
146 | private static int ComputeOutCode(Vector4 pos, Matrix4x4 projection)
147 | {
148 | pos = projection * pos;
149 | int code = 0;
150 | if (pos.x < -pos.w) code |= 0x01;
151 | if (pos.x > pos.w) code |= 0x02;
152 | if (pos.y < -pos.w) code |= 0x04;
153 | if (pos.y > pos.w) code |= 0x08;
154 | if (pos.z < -pos.w) code |= 0x10;
155 | if (pos.z > pos.w) code |= 0x20;
156 | return code;
157 | }
158 |
159 | void OnRenderImage(RenderTexture src, RenderTexture dst)
160 | {
161 | if(waveComponent!=null)
162 | waveComponent.OnRenderImage(src, dst, waveEquationMat);
163 | //waveEquationMat.SetTexture("_PreTex", PreTexture);
164 |
165 | //Graphics.Blit(src, dst, waveEquationMat);
166 |
167 | //Graphics.Blit(src, PreTexture);
168 | Graphics.Blit(dst, HeightMap);
169 |
170 | Graphics.Blit(HeightMap, NormalMap, normalGenerateMat);
171 |
172 |
173 | }
174 |
175 | void OnPostRender()
176 | {
177 | m_CommandBuffer.Clear();
178 | m_CommandBuffer.ClearRenderTarget(true, false, Color.black);
179 | m_CommandBuffer.SetRenderTarget(CurTexture);
180 |
181 | if (waveComponent!=null)
182 | waveComponent.OnPostRender();
183 |
184 | Shader.SetGlobalTexture("_WaterHeightMap", HeightMap);
185 | Shader.SetGlobalTexture("_WaterNormalMap", NormalMap);
186 |
187 | }
188 |
189 | private void OnDestroy()
190 | {
191 | if (HeightMap)
192 | RenderTexture.ReleaseTemporary(HeightMap);
193 | if (NormalMap)
194 | RenderTexture.ReleaseTemporary(NormalMap);
195 | if (CurTexture)
196 | RenderTexture.ReleaseTemporary(CurTexture);
197 | if (waveEquationMat)
198 | Destroy(waveEquationMat);
199 | if (forceMat)
200 | Destroy(forceMat);
201 | if (normalGenerateMat)
202 | Destroy(normalGenerateMat);
203 | if (null != waveComponent)
204 | waveComponent.OnDestroy();
205 | }
206 | }
207 | }
208 |
209 |
--------------------------------------------------------------------------------
/Assets/Scenes/00-WaveEquation.unity:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!29 &1
4 | OcclusionCullingSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_OcclusionBakeSettings:
8 | smallestOccluder: 5
9 | smallestHole: 0.25
10 | backfaceThreshold: 100
11 | m_SceneGUID: 00000000000000000000000000000000
12 | m_OcclusionCullingData: {fileID: 0}
13 | --- !u!104 &2
14 | RenderSettings:
15 | m_ObjectHideFlags: 0
16 | serializedVersion: 9
17 | m_Fog: 0
18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19 | m_FogMode: 3
20 | m_FogDensity: 0.01
21 | m_LinearFogStart: 0
22 | m_LinearFogEnd: 300
23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
26 | m_AmbientIntensity: 1
27 | m_AmbientMode: 0
28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
30 | m_HaloStrength: 0.5
31 | m_FlareStrength: 1
32 | m_FlareFadeSpeed: 3
33 | m_HaloTexture: {fileID: 0}
34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
35 | m_DefaultReflectionMode: 0
36 | m_DefaultReflectionResolution: 128
37 | m_ReflectionBounces: 1
38 | m_ReflectionIntensity: 1
39 | m_CustomReflection: {fileID: 0}
40 | m_Sun: {fileID: 0}
41 | m_IndirectSpecularColor: {r: 0.44657868, g: 0.49641263, b: 0.57481706, a: 1}
42 | m_UseRadianceAmbientProbe: 0
43 | --- !u!157 &3
44 | LightmapSettings:
45 | m_ObjectHideFlags: 0
46 | serializedVersion: 11
47 | m_GIWorkflowMode: 0
48 | m_GISettings:
49 | serializedVersion: 2
50 | m_BounceScale: 1
51 | m_IndirectOutputScale: 1
52 | m_AlbedoBoost: 1
53 | m_TemporalCoherenceThreshold: 1
54 | m_EnvironmentLightingMode: 0
55 | m_EnableBakedLightmaps: 1
56 | m_EnableRealtimeLightmaps: 1
57 | m_LightmapEditorSettings:
58 | serializedVersion: 10
59 | m_Resolution: 2
60 | m_BakeResolution: 40
61 | m_AtlasSize: 1024
62 | m_AO: 0
63 | m_AOMaxDistance: 1
64 | m_CompAOExponent: 1
65 | m_CompAOExponentDirect: 0
66 | m_Padding: 2
67 | m_LightmapParameters: {fileID: 0}
68 | m_LightmapsBakeMode: 1
69 | m_TextureCompression: 1
70 | m_FinalGather: 0
71 | m_FinalGatherFiltering: 1
72 | m_FinalGatherRayCount: 256
73 | m_ReflectionCompression: 2
74 | m_MixedBakeMode: 2
75 | m_BakeBackend: 0
76 | m_PVRSampling: 1
77 | m_PVRDirectSampleCount: 32
78 | m_PVRSampleCount: 500
79 | m_PVRBounces: 2
80 | m_PVRFilterTypeDirect: 0
81 | m_PVRFilterTypeIndirect: 0
82 | m_PVRFilterTypeAO: 0
83 | m_PVRFilteringMode: 1
84 | m_PVRCulling: 1
85 | m_PVRFilteringGaussRadiusDirect: 1
86 | m_PVRFilteringGaussRadiusIndirect: 5
87 | m_PVRFilteringGaussRadiusAO: 2
88 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5
89 | m_PVRFilteringAtrousPositionSigmaIndirect: 2
90 | m_PVRFilteringAtrousPositionSigmaAO: 1
91 | m_ShowResolutionOverlay: 1
92 | m_LightingDataAsset: {fileID: 0}
93 | m_UseShadowmask: 1
94 | --- !u!196 &4
95 | NavMeshSettings:
96 | serializedVersion: 2
97 | m_ObjectHideFlags: 0
98 | m_BuildSettings:
99 | serializedVersion: 2
100 | agentTypeID: 0
101 | agentRadius: 0.5
102 | agentHeight: 2
103 | agentSlope: 45
104 | agentClimb: 0.4
105 | ledgeDropHeight: 0
106 | maxJumpAcrossDistance: 0
107 | minRegionArea: 2
108 | manualCellSize: 0
109 | cellSize: 0.16666667
110 | manualTileSize: 0
111 | tileSize: 256
112 | accuratePlacement: 0
113 | debug:
114 | m_Flags: 0
115 | m_NavMeshData: {fileID: 0}
116 | --- !u!1 &568742295
117 | GameObject:
118 | m_ObjectHideFlags: 0
119 | m_PrefabParentObject: {fileID: 0}
120 | m_PrefabInternal: {fileID: 0}
121 | serializedVersion: 5
122 | m_Component:
123 | - component: {fileID: 568742297}
124 | - component: {fileID: 568742296}
125 | m_Layer: 0
126 | m_Name: Directional Light
127 | m_TagString: Untagged
128 | m_Icon: {fileID: 0}
129 | m_NavMeshLayer: 0
130 | m_StaticEditorFlags: 0
131 | m_IsActive: 1
132 | --- !u!108 &568742296
133 | Light:
134 | m_ObjectHideFlags: 0
135 | m_PrefabParentObject: {fileID: 0}
136 | m_PrefabInternal: {fileID: 0}
137 | m_GameObject: {fileID: 568742295}
138 | m_Enabled: 1
139 | serializedVersion: 8
140 | m_Type: 1
141 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
142 | m_Intensity: 1
143 | m_Range: 10
144 | m_SpotAngle: 30
145 | m_CookieSize: 10
146 | m_Shadows:
147 | m_Type: 2
148 | m_Resolution: -1
149 | m_CustomResolution: -1
150 | m_Strength: 1
151 | m_Bias: 0.05
152 | m_NormalBias: 0.4
153 | m_NearPlane: 0.2
154 | m_Cookie: {fileID: 0}
155 | m_DrawHalo: 0
156 | m_Flare: {fileID: 0}
157 | m_RenderMode: 0
158 | m_CullingMask:
159 | serializedVersion: 2
160 | m_Bits: 4294967295
161 | m_Lightmapping: 4
162 | m_AreaSize: {x: 1, y: 1}
163 | m_BounceIntensity: 1
164 | m_ColorTemperature: 6570
165 | m_UseColorTemperature: 0
166 | m_ShadowRadius: 0
167 | m_ShadowAngle: 0
168 | --- !u!4 &568742297
169 | Transform:
170 | m_ObjectHideFlags: 0
171 | m_PrefabParentObject: {fileID: 0}
172 | m_PrefabInternal: {fileID: 0}
173 | m_GameObject: {fileID: 568742295}
174 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
175 | m_LocalPosition: {x: 0, y: 3, z: 0}
176 | m_LocalScale: {x: 1, y: 1, z: 1}
177 | m_Children: []
178 | m_Father: {fileID: 0}
179 | m_RootOrder: 0
180 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
181 | --- !u!1 &1575682406
182 | GameObject:
183 | m_ObjectHideFlags: 0
184 | m_PrefabParentObject: {fileID: 0}
185 | m_PrefabInternal: {fileID: 0}
186 | serializedVersion: 5
187 | m_Component:
188 | - component: {fileID: 1575682408}
189 | - component: {fileID: 1575682407}
190 | m_Layer: 0
191 | m_Name: Wave
192 | m_TagString: Untagged
193 | m_Icon: {fileID: 0}
194 | m_NavMeshLayer: 0
195 | m_StaticEditorFlags: 0
196 | m_IsActive: 1
197 | --- !u!114 &1575682407
198 | MonoBehaviour:
199 | m_ObjectHideFlags: 0
200 | m_PrefabParentObject: {fileID: 0}
201 | m_PrefabInternal: {fileID: 0}
202 | m_GameObject: {fileID: 1575682406}
203 | m_Enabled: 1
204 | m_EditorHideFlags: 0
205 | m_Script: {fileID: 11500000, guid: 22166a5df2111114c88c083b9de03d08, type: 3}
206 | m_Name:
207 | m_EditorClassIdentifier:
208 | Xsize: 40
209 | mat: {fileID: 0}
210 | u: 0.894
211 | c: 2
212 | d: 2
213 | --- !u!4 &1575682408
214 | Transform:
215 | m_ObjectHideFlags: 0
216 | m_PrefabParentObject: {fileID: 0}
217 | m_PrefabInternal: {fileID: 0}
218 | m_GameObject: {fileID: 1575682406}
219 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
220 | m_LocalPosition: {x: 0, y: 0, z: 0}
221 | m_LocalScale: {x: 1, y: 1, z: 1}
222 | m_Children: []
223 | m_Father: {fileID: 0}
224 | m_RootOrder: 1
225 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
226 | --- !u!1 &1746999053
227 | GameObject:
228 | m_ObjectHideFlags: 0
229 | m_PrefabParentObject: {fileID: 0}
230 | m_PrefabInternal: {fileID: 0}
231 | serializedVersion: 5
232 | m_Component:
233 | - component: {fileID: 1746999057}
234 | - component: {fileID: 1746999056}
235 | - component: {fileID: 1746999055}
236 | - component: {fileID: 1746999054}
237 | m_Layer: 0
238 | m_Name: Camera
239 | m_TagString: MainCamera
240 | m_Icon: {fileID: 0}
241 | m_NavMeshLayer: 0
242 | m_StaticEditorFlags: 0
243 | m_IsActive: 1
244 | --- !u!81 &1746999054
245 | AudioListener:
246 | m_ObjectHideFlags: 0
247 | m_PrefabParentObject: {fileID: 0}
248 | m_PrefabInternal: {fileID: 0}
249 | m_GameObject: {fileID: 1746999053}
250 | m_Enabled: 1
251 | --- !u!124 &1746999055
252 | Behaviour:
253 | m_ObjectHideFlags: 0
254 | m_PrefabParentObject: {fileID: 0}
255 | m_PrefabInternal: {fileID: 0}
256 | m_GameObject: {fileID: 1746999053}
257 | m_Enabled: 1
258 | --- !u!20 &1746999056
259 | Camera:
260 | m_ObjectHideFlags: 0
261 | m_PrefabParentObject: {fileID: 0}
262 | m_PrefabInternal: {fileID: 0}
263 | m_GameObject: {fileID: 1746999053}
264 | m_Enabled: 1
265 | serializedVersion: 2
266 | m_ClearFlags: 1
267 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
268 | m_NormalizedViewPortRect:
269 | serializedVersion: 2
270 | x: 0
271 | y: 0
272 | width: 1
273 | height: 1
274 | near clip plane: 0.3
275 | far clip plane: 1000
276 | field of view: 60
277 | orthographic: 0
278 | orthographic size: 5
279 | m_Depth: 0
280 | m_CullingMask:
281 | serializedVersion: 2
282 | m_Bits: 4294967295
283 | m_RenderingPath: -1
284 | m_TargetTexture: {fileID: 0}
285 | m_TargetDisplay: 0
286 | m_TargetEye: 3
287 | m_HDR: 1
288 | m_AllowMSAA: 1
289 | m_AllowDynamicResolution: 0
290 | m_ForceIntoRT: 0
291 | m_OcclusionCulling: 1
292 | m_StereoConvergence: 10
293 | m_StereoSeparation: 0.022
294 | --- !u!4 &1746999057
295 | Transform:
296 | m_ObjectHideFlags: 0
297 | m_PrefabParentObject: {fileID: 0}
298 | m_PrefabInternal: {fileID: 0}
299 | m_GameObject: {fileID: 1746999053}
300 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
301 | m_LocalPosition: {x: 0, y: 0, z: 0}
302 | m_LocalScale: {x: 1, y: 1, z: 1}
303 | m_Children: []
304 | m_Father: {fileID: 0}
305 | m_RootOrder: 2
306 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
307 |
--------------------------------------------------------------------------------