[A] ocean shader add light
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -94,3 +94,4 @@ crashlytics-build.properties
|
|||||||
/Assets/StreamingAssets/*.bundle
|
/Assets/StreamingAssets/*.bundle
|
||||||
/Assets/StreamingAssets/*.bundle.meta
|
/Assets/StreamingAssets/*.bundle.meta
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.vscode
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class FPS : MonoBehaviour
|
|||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
Application.targetFrameRate = 60;
|
Application.targetFrameRate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnGUI()
|
void OnGUI()
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ RenderSettings:
|
|||||||
m_ReflectionIntensity: 1
|
m_ReflectionIntensity: 1
|
||||||
m_CustomReflection: {fileID: 0}
|
m_CustomReflection: {fileID: 0}
|
||||||
m_Sun: {fileID: 0}
|
m_Sun: {fileID: 0}
|
||||||
m_IndirectSpecularColor: {r: 0.1779636, g: 0.2227953, b: 0.30491212, a: 1}
|
m_IndirectSpecularColor: {r: 0.17885353, g: 0.22394334, b: 0.3057996, a: 1}
|
||||||
m_UseRadianceAmbientProbe: 0
|
m_UseRadianceAmbientProbe: 0
|
||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
@@ -200,7 +200,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 77912383}
|
m_GameObject: {fileID: 77912383}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: -2.5, z: 50}
|
m_LocalPosition: {x: 24, y: -2.4, z: 56}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
@@ -250,6 +250,111 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &351026839
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 351026843}
|
||||||
|
- component: {fileID: 351026842}
|
||||||
|
- component: {fileID: 351026841}
|
||||||
|
- component: {fileID: 351026840}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Cube
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!65 &351026840
|
||||||
|
BoxCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 351026839}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_ProvidesContacts: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 3
|
||||||
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!23 &351026841
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 351026839}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!33 &351026842
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 351026839}
|
||||||
|
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!4 &351026843
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 351026839}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 2, y: -3.26, z: 20}
|
||||||
|
m_LocalScale: {x: 4, y: 1, z: 4}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &580598698
|
--- !u!1 &580598698
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -656,6 +761,56 @@ PrefabInstance:
|
|||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4065199434944052237, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Color.b
|
||||||
|
value: 0.78431374
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4065199434944052237, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Color.g
|
||||||
|
value: 0.9309294
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4065199434944052237, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_Color.r
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4075022403846284307, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 0.8862036
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4075022403846284307, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0.46329606
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4075022403846284307, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4075022403846284307, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4075022403846284307, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
|
value: 55.2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4075022403846284307, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4075022403846284307, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6931138432903229757, guid: 47f79802adc54954898ae8c7d6a674e9,
|
- target: {fileID: 6931138432903229757, guid: 47f79802adc54954898ae8c7d6a674e9,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
@@ -720,3 +875,4 @@ SceneRoots:
|
|||||||
- {fileID: 580598701}
|
- {fileID: 580598701}
|
||||||
- {fileID: 1632218256}
|
- {fileID: 1632218256}
|
||||||
- {fileID: 77912386}
|
- {fileID: 77912386}
|
||||||
|
- {fileID: 351026843}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ MonoBehaviour:
|
|||||||
m_RendererDataList:
|
m_RendererDataList:
|
||||||
- {fileID: 11400000, guid: e634585d5c4544dd297acaee93dc2beb, type: 2}
|
- {fileID: 11400000, guid: e634585d5c4544dd297acaee93dc2beb, type: 2}
|
||||||
m_DefaultRendererIndex: 0
|
m_DefaultRendererIndex: 0
|
||||||
m_RequireDepthTexture: 0
|
m_RequireDepthTexture: 1
|
||||||
m_RequireOpaqueTexture: 0
|
m_RequireOpaqueTexture: 1
|
||||||
m_OpaqueDownsampling: 1
|
m_OpaqueDownsampling: 0
|
||||||
m_SupportsTerrainHoles: 1
|
m_SupportsTerrainHoles: 1
|
||||||
m_SupportsHDR: 1
|
m_SupportsHDR: 1
|
||||||
m_HDRColorBufferPrecision: 0
|
m_HDRColorBufferPrecision: 0
|
||||||
@@ -30,7 +30,7 @@ MonoBehaviour:
|
|||||||
m_UpscalingFilter: 0
|
m_UpscalingFilter: 0
|
||||||
m_FsrOverrideSharpness: 0
|
m_FsrOverrideSharpness: 0
|
||||||
m_FsrSharpness: 0.92
|
m_FsrSharpness: 0.92
|
||||||
m_EnableLODCrossFade: 1
|
m_EnableLODCrossFade: 0
|
||||||
m_LODCrossFadeDitheringType: 1
|
m_LODCrossFadeDitheringType: 1
|
||||||
m_ShEvalMode: 0
|
m_ShEvalMode: 0
|
||||||
m_MainLightRenderingMode: 1
|
m_MainLightRenderingMode: 1
|
||||||
@@ -62,7 +62,7 @@ MonoBehaviour:
|
|||||||
m_AdditionalLightsCookieFormat: 1
|
m_AdditionalLightsCookieFormat: 1
|
||||||
m_UseSRPBatcher: 1
|
m_UseSRPBatcher: 1
|
||||||
m_SupportsDynamicBatching: 0
|
m_SupportsDynamicBatching: 0
|
||||||
m_MixedLightingSupported: 1
|
m_MixedLightingSupported: 0
|
||||||
m_SupportsLightCookies: 1
|
m_SupportsLightCookies: 1
|
||||||
m_SupportsLightLayers: 0
|
m_SupportsLightLayers: 0
|
||||||
m_DebugLevel: 0
|
m_DebugLevel: 0
|
||||||
|
|||||||
@@ -21,16 +21,16 @@ MonoBehaviour:
|
|||||||
m_DefaultRendererIndex: 0
|
m_DefaultRendererIndex: 0
|
||||||
m_RequireDepthTexture: 1
|
m_RequireDepthTexture: 1
|
||||||
m_RequireOpaqueTexture: 1
|
m_RequireOpaqueTexture: 1
|
||||||
m_OpaqueDownsampling: 0
|
m_OpaqueDownsampling: 1
|
||||||
m_SupportsTerrainHoles: 1
|
m_SupportsTerrainHoles: 1
|
||||||
m_SupportsHDR: 0
|
m_SupportsHDR: 1
|
||||||
m_HDRColorBufferPrecision: 0
|
m_HDRColorBufferPrecision: 0
|
||||||
m_MSAA: 1
|
m_MSAA: 1
|
||||||
m_RenderScale: 1
|
m_RenderScale: 0.8
|
||||||
m_UpscalingFilter: 0
|
m_UpscalingFilter: 0
|
||||||
m_FsrOverrideSharpness: 0
|
m_FsrOverrideSharpness: 0
|
||||||
m_FsrSharpness: 0.92
|
m_FsrSharpness: 0.92
|
||||||
m_EnableLODCrossFade: 1
|
m_EnableLODCrossFade: 0
|
||||||
m_LODCrossFadeDitheringType: 1
|
m_LODCrossFadeDitheringType: 1
|
||||||
m_ShEvalMode: 0
|
m_ShEvalMode: 0
|
||||||
m_MainLightRenderingMode: 1
|
m_MainLightRenderingMode: 1
|
||||||
@@ -62,7 +62,7 @@ MonoBehaviour:
|
|||||||
m_AdditionalLightsCookieFormat: 3
|
m_AdditionalLightsCookieFormat: 3
|
||||||
m_UseSRPBatcher: 1
|
m_UseSRPBatcher: 1
|
||||||
m_SupportsDynamicBatching: 0
|
m_SupportsDynamicBatching: 0
|
||||||
m_MixedLightingSupported: 1
|
m_MixedLightingSupported: 0
|
||||||
m_SupportsLightCookies: 1
|
m_SupportsLightCookies: 1
|
||||||
m_SupportsLightLayers: 0
|
m_SupportsLightLayers: 0
|
||||||
m_DebugLevel: 0
|
m_DebugLevel: 0
|
||||||
|
|||||||
@@ -8,3 +8,11 @@ ScriptedImporter:
|
|||||||
assetBundleName:
|
assetBundleName:
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
script: {fileID: 11500000, guid: eb1723d9808f34b8fa4c8c24d2a380d9, type: 3}
|
script: {fileID: 11500000, guid: eb1723d9808f34b8fa4c8c24d2a380d9, type: 3}
|
||||||
|
waterMesh:
|
||||||
|
shape: 0
|
||||||
|
scale: 100
|
||||||
|
vertexDistance: 1
|
||||||
|
UVTiling: 2
|
||||||
|
noise: 0
|
||||||
|
boundsPadding: 4
|
||||||
|
mesh: {fileID: -8670151273213183110, guid: 154c6496b574b495eaf1e56696d041c5, type: 3}
|
||||||
|
|||||||
@@ -90,16 +90,18 @@ Material:
|
|||||||
- _ClearCoatSmoothness: 0
|
- _ClearCoatSmoothness: 0
|
||||||
- _Cull: 2
|
- _Cull: 2
|
||||||
- _Cutoff: 0.5
|
- _Cutoff: 0.5
|
||||||
- _DepthHorizontal: 1.39
|
- _DepthHorizontal: 1.34
|
||||||
- _DepthVertical: 3.69
|
- _DepthVertical: 10.83
|
||||||
- _DetailAlbedoMapScale: 1
|
- _DetailAlbedoMapScale: 1
|
||||||
- _DetailNormalMapScale: 1
|
- _DetailNormalMapScale: 1
|
||||||
- _DstBlend: 0
|
- _DstBlend: 0
|
||||||
- _DstBlendAlpha: 0
|
- _DstBlendAlpha: 0
|
||||||
|
- _EdgeFade: 8.34
|
||||||
- _EnvironmentReflections: 1
|
- _EnvironmentReflections: 1
|
||||||
- _GlossMapScale: 0
|
- _GlossMapScale: 0
|
||||||
- _Glossiness: 0
|
- _Glossiness: 0
|
||||||
- _GlossyReflections: 0
|
- _GlossyReflections: 0
|
||||||
|
- _HorizonDistance: 21.27
|
||||||
- _Metallic: 0
|
- _Metallic: 0
|
||||||
- _OcclusionStrength: 1
|
- _OcclusionStrength: 1
|
||||||
- _Parallax: 0.005
|
- _Parallax: 0.005
|
||||||
@@ -112,23 +114,29 @@ Material:
|
|||||||
- _SrcBlend: 1
|
- _SrcBlend: 1
|
||||||
- _SrcBlendAlpha: 1
|
- _SrcBlendAlpha: 1
|
||||||
- _Surface: 0
|
- _Surface: 0
|
||||||
- _WaveCount: 2
|
- _TranslucencyCurvatureMask: 0.584
|
||||||
- _WaveDistance: 0.8
|
- _TranslucencyExp: 15.3
|
||||||
- _WaveHeight: 0.25
|
- _TranslucencyReflectionMask: 0.747
|
||||||
|
- _TranslucencyStrength: 1.03
|
||||||
|
- _TranslucencyStrengthDirect: 0.07
|
||||||
|
- _WaveCount: 3
|
||||||
|
- _WaveDistance: 0.747
|
||||||
|
- _WaveHeight: 0.46
|
||||||
- _WaveNormalStr: 0.5
|
- _WaveNormalStr: 0.5
|
||||||
- _WaveSpeed: 2
|
- _WaveSpeed: 1
|
||||||
- _WaveSteepness: 0.1
|
- _WaveSteepness: 2.24
|
||||||
- _WorkflowMode: 1
|
- _WorkflowMode: 1
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 0.024964403, g: 0.23726082, b: 0.4811321, a: 0.8862745}
|
- _BaseColor: {r: 0.0133944545, g: 0.20659995, b: 0.4056604, a: 0.84705883}
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _Direction: {r: 0, g: -1, b: 0, a: 0}
|
- _Direction: {r: 1, g: 1, b: 0, a: 0}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _ShallowColor: {r: 0.06430225, g: 0.8018868, b: 0.79103994, a: 0.27450982}
|
- _HorizonColor: {r: 0.09376113, g: 0.18046764, b: 0.46226418, a: 0.95686275}
|
||||||
|
- _ShallowColor: {r: 0.07943218, g: 0.5314412, b: 0.8018868, a: 0.79607844}
|
||||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||||
- _WaveDirection: {r: 1, g: 1, b: 1, a: 1}
|
- _WaveDirection: {r: 1, g: 1, b: 1, a: 2}
|
||||||
- _WaveFadeDistance: {r: 150, g: 300, b: 0, a: 0}
|
- _WaveFadeDistance: {r: 50, g: 81.68, b: 0, a: 0}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
--- !u!114 &1635733923474585344
|
--- !u!114 &1635733923474585344
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
|||||||
@@ -21,11 +21,14 @@ struct WaterSurface
|
|||||||
|
|
||||||
//Normal from the base geometry, in world-space
|
//Normal from the base geometry, in world-space
|
||||||
float3 vertexNormal;
|
float3 vertexNormal;
|
||||||
|
float3 tangentNormal;
|
||||||
|
float3 tangentWorldNormal;
|
||||||
|
|
||||||
float3 albedo;
|
float3 albedo;
|
||||||
float3 offset;
|
float3 offset;
|
||||||
float alpha;
|
float alpha;
|
||||||
float fog;
|
float fog;
|
||||||
|
float edgeFade;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SceneDepth
|
struct SceneDepth
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ struct SceneData
|
|||||||
float4 positionNDC; //Unnormalized
|
float4 positionNDC; //Unnormalized
|
||||||
float2 screenPos; //Normalized and no refraction
|
float2 screenPos; //Normalized and no refraction
|
||||||
float3 positionWS;
|
float3 positionWS;
|
||||||
|
float3 color;
|
||||||
|
|
||||||
float viewDepth;
|
float viewDepth;
|
||||||
float verticalDepth;
|
float verticalDepth;
|
||||||
@@ -64,8 +65,24 @@ float4 ForwardPassFragment(Varyings input) : SV_Target
|
|||||||
water.viewDir = normalize(water.viewDelta);
|
water.viewDir = normalize(water.viewDelta);
|
||||||
water.vertexNormal = normalize(input.normalWS.xyz);
|
water.vertexNormal = normalize(input.normalWS.xyz);
|
||||||
|
|
||||||
|
//Normal
|
||||||
|
water.tangentNormal = float3(0.5, 0.5, 1);
|
||||||
|
water.tangentWorldNormal = normalWS;
|
||||||
|
|
||||||
|
//Tangent-space
|
||||||
|
//water.tangentNormal = SampleNormals(uv, _NormalTiling, _NormalSubTiling, positionWS, TIME, _NormalSpeed, _NormalSubSpeed, water.slope, water.vFace);
|
||||||
|
|
||||||
|
//Based on wave normal, makes it easier to create blend between the smooth wave normals and high-frequency normal maps
|
||||||
|
//water.tangentToWorldMatrix = half3x3(WorldTangent, WorldBiTangent, water.waveNormal);
|
||||||
|
|
||||||
|
//World-space
|
||||||
|
//water.tangentWorldNormal = normalize(TransformTangentToWorld(water.tangentNormal, water.tangentToWorldMatrix));
|
||||||
|
|
||||||
half VdotN = 1.0 - saturate(dot(water.viewDir, normalWS));
|
half VdotN = 1.0 - saturate(dot(water.viewDir, normalWS));
|
||||||
|
|
||||||
|
half4 shadowMask = 1.0;
|
||||||
|
float4 shadowCoords = float4(0, 0, 0, 0);
|
||||||
|
Light mainLight = GetMainLight(shadowCoords, water.positionWS, shadowMask);
|
||||||
|
|
||||||
PopulateSceneData(scene, input, water);
|
PopulateSceneData(scene, input, water);
|
||||||
|
|
||||||
@@ -75,5 +92,69 @@ float4 ForwardPassFragment(Varyings input) : SV_Target
|
|||||||
|
|
||||||
//Albedo
|
//Albedo
|
||||||
float4 baseColor = lerp(_ShallowColor, _BaseColor, water.fog);
|
float4 baseColor = lerp(_ShallowColor, _BaseColor, water.fog);
|
||||||
return baseColor;
|
|
||||||
|
water.fog *= baseColor.a;
|
||||||
|
water.alpha = baseColor.a;
|
||||||
|
|
||||||
|
float fresnel = saturate(pow(VdotN, _HorizonDistance)) * _HorizonColor.a;
|
||||||
|
|
||||||
|
water.albedo = lerp(baseColor.rgb, _HorizonColor.rgb, fresnel);
|
||||||
|
|
||||||
|
water.edgeFade = saturate(scene.verticalDepth / (_EdgeFade * 0.01));
|
||||||
|
|
||||||
|
water.alpha *= water.edgeFade;
|
||||||
|
|
||||||
|
|
||||||
|
/* ========
|
||||||
|
// TRANSLUCENCY
|
||||||
|
=========== */
|
||||||
|
TranslucencyData translucencyData = (TranslucencyData)0;
|
||||||
|
float scatteringMask = 1.0;
|
||||||
|
scatteringMask = saturate(water.fog + water.edgeFade);
|
||||||
|
//scatteringMask = saturate((water.fog + water.edgeFade) - (water.reflectionMask * water.vFace)) * water.shadowMask;
|
||||||
|
//scatteringMask -= water.foam;
|
||||||
|
//scatteringMask = saturate(scatteringMask);
|
||||||
|
translucencyData.subsurfaceColor = _ShallowColor.rgb;
|
||||||
|
//translucencyData.lightColor = mainLight.color;
|
||||||
|
//translucencyData.lightDir = mainLight.direction;
|
||||||
|
|
||||||
|
//translucencyData.normal = normalWS;
|
||||||
|
translucencyData.curvature = _TranslucencyCurvatureMask;
|
||||||
|
translucencyData.mask = scatteringMask;
|
||||||
|
translucencyData.strength = _TranslucencyStrength;
|
||||||
|
translucencyData.strengthIncident = _TranslucencyStrengthDirect;
|
||||||
|
//translucencyData.viewDir = water.viewDir;
|
||||||
|
translucencyData.exponent = _TranslucencyExp;
|
||||||
|
|
||||||
|
|
||||||
|
/* ========
|
||||||
|
// UNITY SURFACE & INPUT DATA
|
||||||
|
=========== */
|
||||||
|
SurfaceData surfaceData = (SurfaceData)0;
|
||||||
|
|
||||||
|
surfaceData.albedo = water.albedo.rgb;
|
||||||
|
surfaceData.specular = 0;// water.specular.rgb;
|
||||||
|
surfaceData.metallic = 0;
|
||||||
|
surfaceData.smoothness = 0;
|
||||||
|
surfaceData.normalTS = water.tangentNormal;
|
||||||
|
surfaceData.emission = 0; //To be populated with translucency+caustics
|
||||||
|
surfaceData.occlusion = 1.0;
|
||||||
|
surfaceData.alpha = water.alpha;
|
||||||
|
|
||||||
|
InputData inputData = (InputData)0;
|
||||||
|
inputData.positionWS = positionWS;
|
||||||
|
inputData.viewDirectionWS = water.viewDir;
|
||||||
|
inputData.shadowCoord = shadowCoords;
|
||||||
|
inputData.normalWS = water.tangentWorldNormal;
|
||||||
|
inputData.fogCoord = 0;//InitializeInputDataFog(float4(positionWS, 1.0), input.fogFactorAndVertexLight.x);
|
||||||
|
inputData.vertexLighting = 0;//input.fogFactorAndVertexLight.yzw;
|
||||||
|
inputData.bakedGI = 0;
|
||||||
|
inputData.shadowMask = 0;//shadowMask;
|
||||||
|
|
||||||
|
|
||||||
|
float4 finalColor = float4(ApplyLighting(surfaceData, scene.color, mainLight, inputData, water, translucencyData), water.alpha);
|
||||||
|
|
||||||
|
|
||||||
|
return finalColor;
|
||||||
|
// return float4(water.albedo, water.alpha);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,18 @@ CBUFFER_START(UnityPerMaterial)
|
|||||||
//Color + Transparency
|
//Color + Transparency
|
||||||
half4 _BaseColor;
|
half4 _BaseColor;
|
||||||
half4 _ShallowColor;
|
half4 _ShallowColor;
|
||||||
|
float4 _HorizonColor;
|
||||||
|
half _HorizonDistance;
|
||||||
float _DepthVertical;
|
float _DepthVertical;
|
||||||
float _DepthHorizontal;
|
float _DepthHorizontal;
|
||||||
|
half _EdgeFade;
|
||||||
|
|
||||||
|
half _TranslucencyStrength;
|
||||||
|
half _TranslucencyStrengthDirect;
|
||||||
|
half _TranslucencyExp;
|
||||||
|
half _TranslucencyCurvatureMask;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Waves
|
//Waves
|
||||||
float _WaveSpeed;
|
float _WaveSpeed;
|
||||||
|
|||||||
45
Packages/zzwater/shaders/libs/Light.hlsl
Normal file
45
Packages/zzwater/shaders/libs/Light.hlsl
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
struct TranslucencyData
|
||||||
|
{
|
||||||
|
float3 subsurfaceColor;
|
||||||
|
float curvature;
|
||||||
|
float mask; //Actually the 'thickness'
|
||||||
|
float strength;
|
||||||
|
float strengthIncident;
|
||||||
|
float exponent;
|
||||||
|
};
|
||||||
|
|
||||||
|
void ApplyTranslucency(float3 subsurfaceColor, float3 lightDir, float3 lightColor, float3 viewDir, float3 normal, float occlusion, float strength, float incidentStrength, float exponent, float offset, inout float3 emission)
|
||||||
|
{
|
||||||
|
//Coefficient describing how much the surface orientation is between the camera and the direction of/to the light
|
||||||
|
half transmittance = saturate(dot(-viewDir, lightDir));
|
||||||
|
//Exponentiate to tighten the falloff
|
||||||
|
transmittance = saturate(pow(transmittance, exponent)) * strength;
|
||||||
|
|
||||||
|
half incident = saturate(dot(lightDir, normal)) * incidentStrength;
|
||||||
|
|
||||||
|
//Mask by normals facing away from the light (backfaces, in light-space)
|
||||||
|
const half curvature = saturate(lerp(1.0, dot(normal, -lightDir), offset));
|
||||||
|
transmittance *= curvature;
|
||||||
|
|
||||||
|
const float lightIntensity = lightColor.r * 0.3 + lightColor.g * 0.59 + lightColor.b * 0.11;
|
||||||
|
|
||||||
|
half attenuation = (transmittance + incident) * occlusion * lightIntensity;
|
||||||
|
|
||||||
|
emission += lerp(emission, subsurfaceColor, attenuation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Based on UniversalFragmentBlinnPhong (no BRDF)
|
||||||
|
float3 ApplyLighting(inout SurfaceData surfaceData, inout float3 sceneColor, Light mainLight, InputData inputData, WaterSurface water, TranslucencyData translucencyData)
|
||||||
|
{
|
||||||
|
ApplyTranslucency(translucencyData.subsurfaceColor, mainLight.direction, mainLight.color, water.viewDir, water.vertexNormal, translucencyData.mask, translucencyData.strength, translucencyData.strengthIncident, translucencyData.exponent, translucencyData.curvature, surfaceData.emission.rgb );
|
||||||
|
|
||||||
|
half3 attenuatedLightColor = mainLight.color * (mainLight.distanceAttenuation * mainLight.shadowAttenuation);
|
||||||
|
half3 diffuseColor = inputData.bakedGI + LightingLambert(attenuatedLightColor, mainLight.direction, water.vertexNormal);
|
||||||
|
|
||||||
|
float3 color = (surfaceData.albedo.rgb * diffuseColor) + surfaceData.emission.rgb + surfaceData.specular;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
7
Packages/zzwater/shaders/libs/Light.hlsl.meta
Normal file
7
Packages/zzwater/shaders/libs/Light.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cf5941ae7f85e4b30bab818d47e3a79b
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -62,7 +62,7 @@ Varyings LitPassVertex(Attributes input)
|
|||||||
ndc.zw = positionCS.zw;
|
ndc.zw = positionCS.zw;
|
||||||
output.positionNDC = ndc;
|
output.positionNDC = ndc;
|
||||||
|
|
||||||
output.normalWS = float4(normalInput.normalWS, positionWS.x);
|
output.normalWS = float4(waves.normal, positionWS.x);
|
||||||
output.tangent = float4(normalInput.tangentWS, positionWS.y);
|
output.tangent = float4(normalInput.tangentWS, positionWS.y);
|
||||||
output.bitangent = float4(normalInput.bitangentWS, positionWS.z);
|
output.bitangent = float4(normalInput.bitangentWS, positionWS.z);
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,18 @@ Shader "zzwater/ocean"
|
|||||||
//Color + Transparency
|
//Color + Transparency
|
||||||
[HDR]_BaseColor("Deep", Color) = (0, 0.44, 0.62, 1)
|
[HDR]_BaseColor("Deep", Color) = (0, 0.44, 0.62, 1)
|
||||||
[HDR]_ShallowColor("Shallow", Color) = (0.1, 0.9, 0.89, 0.02)
|
[HDR]_ShallowColor("Shallow", Color) = (0.1, 0.9, 0.89, 0.02)
|
||||||
|
[HDR]_HorizonColor("Horizon", Color) = (0.84, 1, 1, 0.15)
|
||||||
|
_HorizonDistance("Horizon Distance", Range(0.01 , 32)) = 8
|
||||||
_DepthVertical("View Depth", Range(0.01 , 16)) = 4
|
_DepthVertical("View Depth", Range(0.01 , 16)) = 4
|
||||||
_DepthHorizontal("Vertical Height Depth", Range(0.01 , 8)) = 1
|
_DepthHorizontal("Vertical Height Depth", Range(0.01 , 8)) = 1
|
||||||
|
_EdgeFade("Edge Fade", Float) = 0.1
|
||||||
|
|
||||||
|
_TranslucencyStrength("Translucency Strength", Range(0 , 3)) = 1
|
||||||
|
_TranslucencyStrengthDirect("Translucency Strength (Direct)", Range(0 , 0.5)) = 0.05
|
||||||
|
_TranslucencyExp("Translucency Exponent", Range(1 , 32)) = 4
|
||||||
|
_TranslucencyCurvatureMask("Translucency Curvature mask", Range(0, 1)) = 0.75
|
||||||
|
_TranslucencyReflectionMask("Translucency Reflection mask", Range(0, 1)) = 1
|
||||||
|
|
||||||
|
|
||||||
//waves
|
//waves
|
||||||
_WaveSpeed("Speed", Float) = 2
|
_WaveSpeed("Speed", Float) = 2
|
||||||
@@ -58,6 +68,7 @@ Shader "zzwater/ocean"
|
|||||||
#include "Packages/zzwater/shaders/libs/Input.hlsl"
|
#include "Packages/zzwater/shaders/libs/Input.hlsl"
|
||||||
#include "Packages/zzwater/shaders/libs/Waves.hlsl"
|
#include "Packages/zzwater/shaders/libs/Waves.hlsl"
|
||||||
#include "Packages/zzwater/shaders/libs/Vertex.hlsl"
|
#include "Packages/zzwater/shaders/libs/Vertex.hlsl"
|
||||||
|
#include "Packages/zzwater/shaders/libs/Light.hlsl"
|
||||||
|
|
||||||
#pragma vertex Vertex
|
#pragma vertex Vertex
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ QualitySettings:
|
|||||||
realtimeGICPUUsage: 25
|
realtimeGICPUUsage: 25
|
||||||
lodBias: 0.4
|
lodBias: 0.4
|
||||||
maximumLODLevel: 0
|
maximumLODLevel: 0
|
||||||
enableLODCrossFade: 1
|
enableLODCrossFade: 0
|
||||||
streamingMipmapsActive: 0
|
streamingMipmapsActive: 0
|
||||||
streamingMipmapsAddAllCameras: 1
|
streamingMipmapsAddAllCameras: 1
|
||||||
streamingMipmapsMemoryBudget: 512
|
streamingMipmapsMemoryBudget: 512
|
||||||
|
|||||||
Reference in New Issue
Block a user