备份CatanBuilding瘦身独立工程
This commit is contained in:
74
LocalPackages/zzwater/shaders/FSBlur.shader
Normal file
74
LocalPackages/zzwater/shaders/FSBlur.shader
Normal file
@@ -0,0 +1,74 @@
|
||||
Shader "zzwater/FSBlur"
|
||||
{
|
||||
|
||||
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_DepthThreshold ("Depth Threshold", Range(0, 200)) = 50
|
||||
//_BlurRadius ("Blur Radius", Range(1, 10)) = 3
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline"}
|
||||
LOD 100
|
||||
ZWrite Off Cull Off
|
||||
Pass
|
||||
{
|
||||
Name "FSBlur"
|
||||
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
// The Blit.hlsl file provides the vertex shader (Vert),
|
||||
// the input structure (Attributes) and the output structure (Varyings)
|
||||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
|
||||
#pragma vertex Vert
|
||||
#pragma fragment frag
|
||||
|
||||
|
||||
float _DepthThreshold;
|
||||
SAMPLER(sampler_BlitTexture);
|
||||
float4 _BlitTexture_TexelSize;
|
||||
|
||||
|
||||
half4 frag (Varyings input) : SV_Target
|
||||
{
|
||||
// Sample depth
|
||||
float deviceDepth = SampleSceneDepth(input.texcoord);
|
||||
float linearDepth = LinearEyeDepth(deviceDepth, _ZBufferParams);
|
||||
float _BlurRadius = 5;
|
||||
|
||||
// Original color
|
||||
half4 originalColor = SAMPLE_TEXTURE2D(_BlitTexture, sampler_BlitTexture, input.texcoord);
|
||||
|
||||
// If depth is less than threshold, return original color
|
||||
if (linearDepth < _DepthThreshold)
|
||||
return originalColor;
|
||||
|
||||
// Simple box blur (much faster than Gaussian)
|
||||
half4 blurredColor = half4(0, 0, 0, 0);
|
||||
int samples = 0;
|
||||
|
||||
// Use fixed radius for simplicity
|
||||
for (int x = -_BlurRadius; x <= _BlurRadius; x++)
|
||||
{
|
||||
for (int y = -_BlurRadius; y <= _BlurRadius; y++)
|
||||
{
|
||||
float2 offset = float2(x, y) * _BlitTexture_TexelSize;
|
||||
blurredColor += SAMPLE_TEXTURE2D(_BlitTexture, sampler_BlitTexture, input.texcoord + offset);
|
||||
samples++;
|
||||
}
|
||||
}
|
||||
|
||||
// Average the samples
|
||||
return blurredColor / samples;
|
||||
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
9
LocalPackages/zzwater/shaders/FSBlur.shader.meta
Normal file
9
LocalPackages/zzwater/shaders/FSBlur.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4cb3a33af23f76541a3829b6fe8b4bed
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
537
LocalPackages/zzwater/shaders/FSWave.shadergraph
Normal file
537
LocalPackages/zzwater/shaders/FSWave.shadergraph
Normal file
@@ -0,0 +1,537 @@
|
||||
{
|
||||
"m_SGVersion": 3,
|
||||
"m_Type": "UnityEditor.ShaderGraph.GraphData",
|
||||
"m_ObjectId": "97bdc616974748949d3e85eeb6169cf6",
|
||||
"m_Properties": [],
|
||||
"m_Keywords": [],
|
||||
"m_Dropdowns": [],
|
||||
"m_CategoryData": [
|
||||
{
|
||||
"m_Id": "251c23702d974aa796acbd724c029af7"
|
||||
}
|
||||
],
|
||||
"m_Nodes": [
|
||||
{
|
||||
"m_Id": "c8cf96b42c3741b387dfa4b89feb535e"
|
||||
},
|
||||
{
|
||||
"m_Id": "5a910df6760f4b52bb844107735592de"
|
||||
},
|
||||
{
|
||||
"m_Id": "b89dacbc48004a04b9c7e7ff73a91785"
|
||||
},
|
||||
{
|
||||
"m_Id": "b6a10604d3b64469942aefb11ca3202e"
|
||||
},
|
||||
{
|
||||
"m_Id": "735bf3b859f5434b9171d848935b49bf"
|
||||
}
|
||||
],
|
||||
"m_GroupDatas": [],
|
||||
"m_StickyNoteDatas": [],
|
||||
"m_Edges": [
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "735bf3b859f5434b9171d848935b49bf"
|
||||
},
|
||||
"m_SlotId": 0
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "b6a10604d3b64469942aefb11ca3202e"
|
||||
},
|
||||
"m_SlotId": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "b6a10604d3b64469942aefb11ca3202e"
|
||||
},
|
||||
"m_SlotId": 1
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "b89dacbc48004a04b9c7e7ff73a91785"
|
||||
},
|
||||
"m_SlotId": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "b89dacbc48004a04b9c7e7ff73a91785"
|
||||
},
|
||||
"m_SlotId": 2
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "c8cf96b42c3741b387dfa4b89feb535e"
|
||||
},
|
||||
"m_SlotId": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"m_VertexContext": {
|
||||
"m_Position": {
|
||||
"x": -0.00001239776611328125,
|
||||
"y": -0.0000286102294921875
|
||||
},
|
||||
"m_Blocks": []
|
||||
},
|
||||
"m_FragmentContext": {
|
||||
"m_Position": {
|
||||
"x": 0.0,
|
||||
"y": 200.0
|
||||
},
|
||||
"m_Blocks": [
|
||||
{
|
||||
"m_Id": "c8cf96b42c3741b387dfa4b89feb535e"
|
||||
},
|
||||
{
|
||||
"m_Id": "5a910df6760f4b52bb844107735592de"
|
||||
}
|
||||
]
|
||||
},
|
||||
"m_PreviewData": {
|
||||
"serializedMesh": {
|
||||
"m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}",
|
||||
"m_Guid": ""
|
||||
},
|
||||
"preventRotation": false
|
||||
},
|
||||
"m_Path": "zzwater",
|
||||
"m_GraphPrecision": 1,
|
||||
"m_PreviewMode": 2,
|
||||
"m_OutputNode": {
|
||||
"m_Id": ""
|
||||
},
|
||||
"m_SubDatas": [],
|
||||
"m_ActiveTargets": [
|
||||
{
|
||||
"m_Id": "59f0b9eed4544b4f8a44a9bf01cab21e"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
|
||||
"m_ObjectId": "251c23702d974aa796acbd724c029af7",
|
||||
"m_Name": "",
|
||||
"m_ChildObjectList": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.Rendering.Fullscreen.ShaderGraph.FullscreenData",
|
||||
"m_ObjectId": "3cec1ba0bc4c4781ad9b8bf02a2920b1",
|
||||
"m_Version": 0,
|
||||
"m_fullscreenMode": 0,
|
||||
"m_BlendMode": 0,
|
||||
"m_SrcColorBlendMode": 0,
|
||||
"m_DstColorBlendMode": 1,
|
||||
"m_ColorBlendOperation": 0,
|
||||
"m_SrcAlphaBlendMode": 0,
|
||||
"m_DstAlphaBlendMode": 1,
|
||||
"m_AlphaBlendOperation": 0,
|
||||
"m_EnableStencil": false,
|
||||
"m_StencilReference": 0,
|
||||
"m_StencilReadMask": 255,
|
||||
"m_StencilWriteMask": 255,
|
||||
"m_StencilCompareFunction": 8,
|
||||
"m_StencilPassOperation": 0,
|
||||
"m_StencilFailOperation": 0,
|
||||
"m_StencilDepthFailOperation": 0,
|
||||
"m_DepthWrite": false,
|
||||
"m_depthWriteMode": 0,
|
||||
"m_AllowMaterialOverride": false,
|
||||
"m_DepthTestMode": 0
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
|
||||
"m_ObjectId": "46b8622de7be4068b625bd4bc04be38f",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "Out",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Out",
|
||||
"m_StageCapability": 3,
|
||||
"m_Value": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"w": 0.0
|
||||
},
|
||||
"m_DefaultValue": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"w": 0.0
|
||||
},
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
"m_ObjectId": "4e74e98b104e41aaa8adc8c67f972ed9",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "Alpha",
|
||||
"m_SlotType": 0,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Alpha",
|
||||
"m_StageCapability": 2,
|
||||
"m_Value": 1.0,
|
||||
"m_DefaultValue": 1.0,
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot",
|
||||
"m_ObjectId": "4fbd2a02b6e44e95a5f1531a7e35678e",
|
||||
"m_Id": 1,
|
||||
"m_DisplayName": "Out",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Out",
|
||||
"m_StageCapability": 3,
|
||||
"m_Value": {
|
||||
"x": 0.0,
|
||||
"y": 0.0
|
||||
},
|
||||
"m_DefaultValue": {
|
||||
"x": 0.0,
|
||||
"y": 0.0
|
||||
},
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget",
|
||||
"m_ObjectId": "59f0b9eed4544b4f8a44a9bf01cab21e",
|
||||
"m_Datas": [
|
||||
{
|
||||
"m_Id": "3cec1ba0bc4c4781ad9b8bf02a2920b1"
|
||||
}
|
||||
],
|
||||
"m_ActiveSubTarget": {
|
||||
"m_Id": "bd0ea81575d74b88aaf8b3e9f283476d"
|
||||
},
|
||||
"m_AllowMaterialOverride": false,
|
||||
"m_SurfaceType": 0,
|
||||
"m_ZTestMode": 4,
|
||||
"m_ZWriteControl": 0,
|
||||
"m_AlphaMode": 0,
|
||||
"m_RenderFace": 2,
|
||||
"m_AlphaClip": false,
|
||||
"m_CastShadows": true,
|
||||
"m_ReceiveShadows": true,
|
||||
"m_SupportsLODCrossFade": false,
|
||||
"m_CustomEditorGUI": "",
|
||||
"m_SupportVFX": false
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
|
||||
"m_ObjectId": "5a910df6760f4b52bb844107735592de",
|
||||
"m_Group": {
|
||||
"m_Id": ""
|
||||
},
|
||||
"m_Name": "SurfaceDescription.Alpha",
|
||||
"m_DrawState": {
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"width": 0.0,
|
||||
"height": 0.0
|
||||
}
|
||||
},
|
||||
"m_Slots": [
|
||||
{
|
||||
"m_Id": "4e74e98b104e41aaa8adc8c67f972ed9"
|
||||
}
|
||||
],
|
||||
"synonyms": [],
|
||||
"m_Precision": 0,
|
||||
"m_PreviewExpanded": true,
|
||||
"m_DismissedVersion": 0,
|
||||
"m_PreviewMode": 0,
|
||||
"m_CustomColors": {
|
||||
"m_SerializableColors": []
|
||||
},
|
||||
"m_SerializedDescriptor": "SurfaceDescription.Alpha"
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot",
|
||||
"m_ObjectId": "6fb8fe7b25b24856b766270254888f90",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "uv",
|
||||
"m_SlotType": 0,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "uv",
|
||||
"m_StageCapability": 3,
|
||||
"m_Value": {
|
||||
"x": 0.0,
|
||||
"y": 0.0
|
||||
},
|
||||
"m_DefaultValue": {
|
||||
"x": 0.0,
|
||||
"y": 0.0
|
||||
},
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.UVNode",
|
||||
"m_ObjectId": "735bf3b859f5434b9171d848935b49bf",
|
||||
"m_Group": {
|
||||
"m_Id": ""
|
||||
},
|
||||
"m_Name": "UV",
|
||||
"m_DrawState": {
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": -868.0,
|
||||
"y": -21.999984741210939,
|
||||
"width": 145.0,
|
||||
"height": 128.99993896484376
|
||||
}
|
||||
},
|
||||
"m_Slots": [
|
||||
{
|
||||
"m_Id": "46b8622de7be4068b625bd4bc04be38f"
|
||||
}
|
||||
],
|
||||
"synonyms": [
|
||||
"texcoords",
|
||||
"coords",
|
||||
"coordinates"
|
||||
],
|
||||
"m_Precision": 0,
|
||||
"m_PreviewExpanded": false,
|
||||
"m_DismissedVersion": 0,
|
||||
"m_PreviewMode": 0,
|
||||
"m_CustomColors": {
|
||||
"m_SerializableColors": []
|
||||
},
|
||||
"m_OutputChannel": 0
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.ColorRGBAMaterialSlot",
|
||||
"m_ObjectId": "874211ead7b44611aadbb9aa5338fea4",
|
||||
"m_Id": 2,
|
||||
"m_DisplayName": "Output",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Output",
|
||||
"m_StageCapability": 2,
|
||||
"m_Value": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"w": 1.0
|
||||
},
|
||||
"m_DefaultValue": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"w": 0.0
|
||||
},
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
|
||||
"m_ObjectId": "b6a10604d3b64469942aefb11ca3202e",
|
||||
"m_Group": {
|
||||
"m_Id": ""
|
||||
},
|
||||
"m_Name": "SCWave (Custom Function)",
|
||||
"m_DrawState": {
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": -663.0,
|
||||
"y": -21.999984741210939,
|
||||
"width": 208.0,
|
||||
"height": 245.99998474121095
|
||||
}
|
||||
},
|
||||
"m_Slots": [
|
||||
{
|
||||
"m_Id": "6fb8fe7b25b24856b766270254888f90"
|
||||
},
|
||||
{
|
||||
"m_Id": "4fbd2a02b6e44e95a5f1531a7e35678e"
|
||||
}
|
||||
],
|
||||
"synonyms": [
|
||||
"code",
|
||||
"HLSL"
|
||||
],
|
||||
"m_Precision": 0,
|
||||
"m_PreviewExpanded": false,
|
||||
"m_DismissedVersion": 0,
|
||||
"m_PreviewMode": 0,
|
||||
"m_CustomColors": {
|
||||
"m_SerializableColors": []
|
||||
},
|
||||
"m_SourceType": 1,
|
||||
"m_FunctionName": "SCWave",
|
||||
"m_FunctionSource": "",
|
||||
"m_FunctionBody": "//waveSize = 5\r\n// _Amplitude = 0.005\r\r\nfloat X = uv.x * 5 + _Time.y;\r\nfloat Y = uv.y * 5 + _Time.y;\r\nfloat Xoffset = cos(X-Y)* 0.005 *cos(Y);\r\nfloat Yoffset = sin(X+Y)* 0.005 * sin(Y);\r\nOut = uv + float2(Xoffset, Yoffset);\r\n"
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.Rendering.Universal.UniversalSampleBufferNode",
|
||||
"m_ObjectId": "b89dacbc48004a04b9c7e7ff73a91785",
|
||||
"m_Group": {
|
||||
"m_Id": ""
|
||||
},
|
||||
"m_Name": "URP Sample Buffer",
|
||||
"m_DrawState": {
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": -384.0,
|
||||
"y": 0.0,
|
||||
"width": 208.0,
|
||||
"height": 313.0
|
||||
}
|
||||
},
|
||||
"m_Slots": [
|
||||
{
|
||||
"m_Id": "e02e445989c2407d9c765ef29b91a743"
|
||||
},
|
||||
{
|
||||
"m_Id": "874211ead7b44611aadbb9aa5338fea4"
|
||||
}
|
||||
],
|
||||
"synonyms": [
|
||||
"normal",
|
||||
"motion vector",
|
||||
"blit"
|
||||
],
|
||||
"m_Precision": 0,
|
||||
"m_PreviewExpanded": false,
|
||||
"m_DismissedVersion": 0,
|
||||
"m_PreviewMode": 0,
|
||||
"m_CustomColors": {
|
||||
"m_SerializableColors": []
|
||||
},
|
||||
"m_BufferType": 2
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalFullscreenSubTarget",
|
||||
"m_ObjectId": "bd0ea81575d74b88aaf8b3e9f283476d"
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
|
||||
"m_ObjectId": "c8cf96b42c3741b387dfa4b89feb535e",
|
||||
"m_Group": {
|
||||
"m_Id": ""
|
||||
},
|
||||
"m_Name": "SurfaceDescription.BaseColor",
|
||||
"m_DrawState": {
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"width": 0.0,
|
||||
"height": 0.0
|
||||
}
|
||||
},
|
||||
"m_Slots": [
|
||||
{
|
||||
"m_Id": "e8b57279c0424bbea4332f3396bf8da8"
|
||||
}
|
||||
],
|
||||
"synonyms": [],
|
||||
"m_Precision": 0,
|
||||
"m_PreviewExpanded": true,
|
||||
"m_DismissedVersion": 0,
|
||||
"m_PreviewMode": 0,
|
||||
"m_CustomColors": {
|
||||
"m_SerializableColors": []
|
||||
},
|
||||
"m_SerializedDescriptor": "SurfaceDescription.BaseColor"
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.ScreenPositionMaterialSlot",
|
||||
"m_ObjectId": "e02e445989c2407d9c765ef29b91a743",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "UV",
|
||||
"m_SlotType": 0,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "UV",
|
||||
"m_StageCapability": 3,
|
||||
"m_Value": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"w": 0.0
|
||||
},
|
||||
"m_DefaultValue": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"w": 0.0
|
||||
},
|
||||
"m_Labels": [],
|
||||
"m_ScreenSpaceType": 0
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot",
|
||||
"m_ObjectId": "e8b57279c0424bbea4332f3396bf8da8",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "Base Color",
|
||||
"m_SlotType": 0,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "BaseColor",
|
||||
"m_StageCapability": 2,
|
||||
"m_Value": {
|
||||
"x": 0.5,
|
||||
"y": 0.5,
|
||||
"z": 0.5
|
||||
},
|
||||
"m_DefaultValue": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"m_Labels": [],
|
||||
"m_ColorMode": 0,
|
||||
"m_DefaultColor": {
|
||||
"r": 0.5,
|
||||
"g": 0.5,
|
||||
"b": 0.5,
|
||||
"a": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
10
LocalPackages/zzwater/shaders/FSWave.shadergraph.meta
Normal file
10
LocalPackages/zzwater/shaders/FSWave.shadergraph.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 427374d7de305424bbe241d698028a64
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
1936
LocalPackages/zzwater/shaders/WaterPlantG.shadergraph
Normal file
1936
LocalPackages/zzwater/shaders/WaterPlantG.shadergraph
Normal file
File diff suppressed because it is too large
Load Diff
10
LocalPackages/zzwater/shaders/WaterPlantG.shadergraph.meta
Normal file
10
LocalPackages/zzwater/shaders/WaterPlantG.shadergraph.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 746c94d4092dee3428d2f89537482562
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
97
LocalPackages/zzwater/shaders/horizon_ocean.shader
Normal file
97
LocalPackages/zzwater/shaders/horizon_ocean.shader
Normal file
@@ -0,0 +1,97 @@
|
||||
Shader "zzwater/horizon_ocean"
|
||||
{
|
||||
|
||||
Properties
|
||||
{
|
||||
[HDR]_Color("Color", Color) = (0, 0.44, 0.62, 1)
|
||||
_ReflectionStrength("Reflection Strength", Range(0, 2)) = 1
|
||||
_ReflectionBlur("Probe Blur Factor", Range(0, 1)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
"UniversalMaterialType" = "Unlit"
|
||||
"IgnoreProjector" = "True"
|
||||
"Queue" = "Transparent+0"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode"="UniversalForward" }
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
||||
ZWrite On
|
||||
Cull Back
|
||||
ZTest LEqual
|
||||
ZClip On
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
//Fog rendering (integration)
|
||||
#define UnityFog
|
||||
#pragma multi_compile_fog
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
|
||||
float _ReflectionBlur;
|
||||
float _ReflectionStrength;
|
||||
half4 _Color;
|
||||
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float3 positionWS : TEXCOORD0;
|
||||
float4 positionNDC : TEXCOORD1;
|
||||
float fogFactor : TEXCOORD2;
|
||||
};
|
||||
|
||||
Varyings vert(Attributes IN)
|
||||
{
|
||||
Varyings OUT;
|
||||
|
||||
// Get the position of the vertex in different spaces
|
||||
VertexPositionInputs positions = GetVertexPositionInputs(IN.positionOS);
|
||||
|
||||
OUT.positionCS = positions.positionCS;
|
||||
OUT.positionWS = positions.positionWS.xyz;
|
||||
OUT.positionNDC = positions.positionNDC;
|
||||
OUT.fogFactor = ComputeFogFactor(positions.positionCS.z);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
half4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
float3 viewDir = normalize(_WorldSpaceCameraPos - IN.positionWS);
|
||||
half3 reflectionVector = reflect(-viewDir, float3(0, 1, 0));
|
||||
float2 screenPos = IN.positionNDC.xy / IN.positionNDC.w;
|
||||
float3 reflections = GlossyEnvironmentReflection(reflectionVector, IN.positionWS, _ReflectionBlur, 1 ,screenPos) * _ReflectionStrength;
|
||||
|
||||
//Apply fog
|
||||
half fogCoord = InitializeInputDataFog(float4(IN.positionWS,1), IN.fogFactor);
|
||||
half3 finalColor = MixFog(_Color.rgb * reflections, fogCoord);
|
||||
return half4(finalColor, _Color.a);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
9
LocalPackages/zzwater/shaders/horizon_ocean.shader.meta
Normal file
9
LocalPackages/zzwater/shaders/horizon_ocean.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 838018c478c7946c7a600a5350e7d4e1
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
LocalPackages/zzwater/shaders/libs.meta
Normal file
8
LocalPackages/zzwater/shaders/libs.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eee4bbf1e344f4122b2c5beb05048c2d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
LocalPackages/zzwater/shaders/libs/Common.hlsl
Normal file
64
LocalPackages/zzwater/shaders/libs/Common.hlsl
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
#ifndef WATER_COMMON_INCLUDED
|
||||
#define WATER_COMMON_INCLUDED
|
||||
|
||||
//As per the "Shader" section of the documentation, this is primarily used for synchronizing animations in networked applications.
|
||||
//#define TIME_FRAG_INPUT input.uv.z
|
||||
//#define TIME_VERTEX_OUTPUT output.uv.z
|
||||
|
||||
//#define TIME ((TIME_FRAG_INPUT * _Speed) * -_Direction.xy)
|
||||
//#define TIME_VERTEX ((TIME_VERTEX_OUTPUT * _Speed) * -_Direction.xy)
|
||||
#define TIME_VERTEX ((_TimeParameters.x * _Speed) * -_Direction.xy)
|
||||
|
||||
#define HORIZONTAL_DISPLACEMENT_SCALAR 0.01
|
||||
#define UP_VECTOR float3(0,1,0)
|
||||
#define RAD2DEGREE 57.29578
|
||||
|
||||
struct WaterSurface
|
||||
{
|
||||
float3 positionWS;
|
||||
float3 viewDelta; //Un-normalized view direction,
|
||||
float3 viewDir;
|
||||
|
||||
//Normal from the base geometry, in world-space
|
||||
float3 vertexNormal;
|
||||
float3 tangentNormal;
|
||||
float3 tangentWorldNormal;
|
||||
|
||||
float3 albedo;
|
||||
float3 offset;
|
||||
float alpha;
|
||||
float fog;
|
||||
float edgeFade;
|
||||
float intersection;
|
||||
|
||||
float3 reflections;
|
||||
float reflectionMask;
|
||||
};
|
||||
|
||||
struct SceneDepth
|
||||
{
|
||||
float raw;
|
||||
float linear01;
|
||||
float eye;
|
||||
};
|
||||
|
||||
#define FAR_CLIP _ProjectionParams.z
|
||||
#define NEAR_CLIP _ProjectionParams.y
|
||||
//Scale linear values to the clipping planes for orthographic projection (unity_OrthoParams.w = 1 = orthographic)
|
||||
#define DEPTH_SCALAR (FAR_CLIP - NEAR_CLIP)
|
||||
|
||||
//Return depth based on the used technique (buffer, vertex color, baked texture)
|
||||
SceneDepth SampleDepth(float2 uv)
|
||||
{
|
||||
SceneDepth depth = (SceneDepth)0;
|
||||
|
||||
float raw = SampleSceneDepth(uv);
|
||||
depth.raw = raw;
|
||||
depth.eye = LinearEyeDepth(raw, _ZBufferParams);
|
||||
depth.linear01 = Linear01Depth(raw, _ZBufferParams) * DEPTH_SCALAR;
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
||||
#endif
|
||||
7
LocalPackages/zzwater/shaders/libs/Common.hlsl.meta
Normal file
7
LocalPackages/zzwater/shaders/libs/Common.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d21056e9736804a9ba0680085db36f45
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
235
LocalPackages/zzwater/shaders/libs/ForwardPass.hlsl
Normal file
235
LocalPackages/zzwater/shaders/libs/ForwardPass.hlsl
Normal file
@@ -0,0 +1,235 @@
|
||||
|
||||
struct SceneData
|
||||
{
|
||||
float4 positionNDC; //Unnormalized
|
||||
float2 screenPos; //Normalized and no refraction
|
||||
float3 positionWS;
|
||||
float3 color;
|
||||
float refractionMask;
|
||||
|
||||
float viewDepth;
|
||||
float verticalDepth;
|
||||
};
|
||||
|
||||
// Project from eye space to world space
|
||||
#define WorldPosFromDepth(NDCw, depth, viewDir) -(depth.eye * (viewDir/NDCw) - _WorldSpaceCameraPos)
|
||||
//Linear depth difference between scene and current (transparent) geometry pixel
|
||||
#define SurfaceDepth(depth, positionCS) depth.eye - LinearEyeDepth(positionCS.z, _ZBufferParams)
|
||||
|
||||
|
||||
void PopulateSceneData(inout SceneData scene, in Varyings input, in WaterSurface water)
|
||||
{
|
||||
const float2 screenPos = input.positionNDC.xy / input.positionNDC.w;
|
||||
scene.positionNDC = input.positionNDC;
|
||||
scene.screenPos = screenPos;
|
||||
|
||||
//Default for disabled depth texture scene.viewDepth = 1;
|
||||
scene.verticalDepth = 1;
|
||||
|
||||
#ifdef _REFRACTION
|
||||
SceneDepth depth = SampleDepth(screenPos);
|
||||
float3 positionWS = WorldPosFromDepth(input.positionNDC.w, depth, water.viewDelta);
|
||||
float viewDepth = SurfaceDepth(depth, input.positionCS);
|
||||
|
||||
const float2 refractionOffset = input.normalWS.xz * 0.5 * _RefractionStrength;
|
||||
SceneDepth depthRefract = SampleDepth(screenPos + refractionOffset);
|
||||
float3 positionWSRefract = WorldPosFromDepth(input.positionNDC.w, depthRefract, water.viewDelta);
|
||||
float viewDepthRefract = SurfaceDepth(depthRefract, input.positionCS);
|
||||
|
||||
float mask = saturate(viewDepth) * saturate(viewDepthRefract);
|
||||
|
||||
scene.positionWS = lerp(positionWS, positionWSRefract, mask);
|
||||
scene.viewDepth = lerp(viewDepth, viewDepthRefract, mask);
|
||||
//Distance to opaque geometry in normal direction
|
||||
scene.verticalDepth = length((water.positionWS - scene.positionWS) * water.vertexNormal);
|
||||
scene.color = SampleSceneColor(screenPos + refractionOffset * mask);
|
||||
scene.refractionMask = mask;
|
||||
#else
|
||||
SceneDepth depth = SampleDepth(screenPos);
|
||||
scene.positionWS = WorldPosFromDepth(input.positionNDC.w, depth, water.viewDelta);
|
||||
scene.viewDepth = SurfaceDepth(depth, input.positionCS);
|
||||
scene.verticalDepth = length((water.positionWS - scene.positionWS) * water.vertexNormal);
|
||||
scene.color = SampleSceneColor(screenPos);
|
||||
scene.refractionMask = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
float GetWaterDensity(SceneData scene, float heightScalar, float viewDepthScalar)
|
||||
{
|
||||
const float viewDepth = scene.viewDepth;
|
||||
const float verticalDepth = scene.verticalDepth;
|
||||
|
||||
const float depthAttenuation = 1.0 - exp(-viewDepth * viewDepthScalar * 0.1);
|
||||
const float heightAttenuation = saturate(verticalDepth * heightScalar);
|
||||
|
||||
return max(depthAttenuation, heightAttenuation);
|
||||
}
|
||||
|
||||
float4 ForwardPassFragment(Varyings input) : SV_Target
|
||||
{
|
||||
WaterSurface water = (WaterSurface)0;
|
||||
SceneData scene = (SceneData)0;
|
||||
|
||||
float3 normalWS = normalize(input.normalWS.xyz);
|
||||
float3 WorldTangent = input.tangent.xyz;
|
||||
float3 WorldBiTangent = input.bitangent.xyz;
|
||||
//wPos.x in w-component
|
||||
float3 positionWS = float3(input.normalWS.w, input.tangent.w, input.bitangent.w);
|
||||
|
||||
water.alpha = 1.0;
|
||||
water.positionWS = positionWS;
|
||||
water.viewDelta = _WorldSpaceCameraPos - positionWS;
|
||||
float3 viewDir = normalize(water.viewDelta);
|
||||
water.viewDir = viewDir;
|
||||
water.vertexNormal = normalize(input.normalWS.xyz);
|
||||
|
||||
//Normal
|
||||
water.tangentNormal = float3(0.5, 0.5, 1);
|
||||
water.tangentWorldNormal = normalWS;
|
||||
|
||||
half VdotN = 1.0 - saturate(dot(viewDir, normalWS));
|
||||
half4 shadowMask = 1.0;
|
||||
float4 shadowCoords = float4(0, 0, 0, 0);
|
||||
Light mainLight = GetMainLight(shadowCoords, water.positionWS, shadowMask);
|
||||
|
||||
PopulateSceneData(scene, input, water);
|
||||
|
||||
//return float4(scene.verticalDepth.xxx, 1);
|
||||
//return float4(saturate(scene.viewDepth).xxx, 1);
|
||||
//return float4(scene.color, 1);
|
||||
|
||||
water.fog = GetWaterDensity(scene, _DepthHorizontal, _DepthVertical);
|
||||
|
||||
//Albedo
|
||||
float4 baseColor = lerp(_ShallowColor, _BaseColor, water.fog);
|
||||
|
||||
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;
|
||||
|
||||
|
||||
// Wave Mesure
|
||||
|
||||
#if _INTERSECTION || _WAVE_FOAM
|
||||
float waveMesure = (positionWS.y - _WaveMesureMin) / (_WaveMesureMax - _WaveMesureMin);
|
||||
|
||||
float2 nUV = positionWS.xz * _IntersectionTiling;
|
||||
float foamTexNoise = SAMPLE_TEXTURE2D(_IntersectionNoise, sampler_IntersectionNoise, nUV + TIME_VERTEX/_IntersectionTiling * _IntersectionSpeed).r;
|
||||
|
||||
float interSecGradient = 1-saturate(exp(scene.verticalDepth) / _IntersectionLength);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WAVE_FOAM
|
||||
// remap wave from [_WaveFoamClipping,1] to [0,1]
|
||||
//float waveFoamNoise = (waveMesure - _WaveFoamClipping) / (1 - _WaveFoamClipping) * foamTexNoise;
|
||||
float waveFoamNoise = smoothstep(_WaveFoamClipping.x, _WaveFoamClipping.y, waveMesure * foamTexNoise);
|
||||
//return float4(waveFoamNoise.xxx, 1);
|
||||
#else
|
||||
float waveFoamNoise = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/* ========
|
||||
// Intercection
|
||||
=========== */
|
||||
#ifdef _INTERSECTION
|
||||
float intersecMesure = waveMesure * interSecGradient;
|
||||
float dist = saturate(interSecGradient / _IntersectionFalloff);
|
||||
float intersecNoise = saturate(foamTexNoise + intersecMesure) * dist + dist;
|
||||
intersecNoise = smoothstep(_IntersectionClipping, 1, intersecNoise);
|
||||
#else
|
||||
float intersecNoise = 0;
|
||||
#endif
|
||||
|
||||
|
||||
#if _INTERSECTION || _WAVE_FOAM
|
||||
float noise = saturate(intersecNoise + waveFoamNoise);
|
||||
water.albedo.rgb = lerp(water.albedo.rgb, _IntersectionColor.rgb, noise);
|
||||
water.alpha = saturate(water.alpha + interSecGradient);
|
||||
#else
|
||||
float noise = 0;
|
||||
#endif
|
||||
|
||||
/* ========
|
||||
// Causitcs
|
||||
=========== */
|
||||
|
||||
#ifdef _CAUSTICS
|
||||
float2 cuv = positionWS.xz * _CausticsTiling;
|
||||
float coffset = TIME_VERTEX/_CausticsTiling * _CausticsSpeed;
|
||||
float3 caustics1 = SAMPLE_TEXTURE2D(_CausticsTex, sampler_CausticsTex, cuv + coffset).rgb;
|
||||
float3 caustics2 = SAMPLE_TEXTURE2D(_CausticsTex, sampler_CausticsTex, cuv*0.8 - coffset).rgb;
|
||||
// Limit distance from cam and verticalDepth
|
||||
float3 causticsDensity = saturate((1-length(water.viewDelta) / _CausticsClipping.x) * smoothstep(_CausticsClipping.y,1, scene.verticalDepth));
|
||||
float3 caustics = min(caustics1, caustics2) * _CausticsBrightness * causticsDensity;
|
||||
#endif
|
||||
|
||||
/* ========
|
||||
// Reflection Prob
|
||||
=========== */
|
||||
|
||||
half3 reflectionVector = reflect(-viewDir, normalWS);
|
||||
water.reflections = GlossyEnvironmentReflection(reflectionVector, water.positionWS, _ReflectionBlur, 1 ,scene.screenPos.xy);
|
||||
|
||||
//Schlick's BRDF fresnel AIR_RI = 1.000293
|
||||
float cosTheta = saturate(dot(normalWS, viewDir));
|
||||
water.reflectionMask = pow(max(0.0, 1.000293 - cosTheta), _ReflectionFresnel) * _ReflectionStrength;
|
||||
|
||||
water.albedo = lerp(water.albedo, water.reflections.rgb, water.reflectionMask - noise);
|
||||
|
||||
|
||||
// =================== Make ApplyLight simple =========================
|
||||
|
||||
// =====Translucency Begin========
|
||||
float3 lightDir = mainLight.direction;
|
||||
float3 lightColor = mainLight.color;
|
||||
float3 emission = 0;
|
||||
float3 specular = 0;
|
||||
|
||||
float scatteringMask = saturate(water.fog + water.edgeFade);
|
||||
|
||||
half incident = saturate(dot(lightDir, normalWS)) * _TranslucencyStrengthDirect;
|
||||
|
||||
const float lightIntensity = lightColor.r * 0.3 + lightColor.g * 0.59 + lightColor.b * 0.11;
|
||||
|
||||
half attenuation = incident * scatteringMask * lightIntensity;
|
||||
|
||||
#ifdef _CAUSTICS
|
||||
emission += lerp(caustics * lightIntensity, _ShallowColor.rgb, attenuation) * mainLight.distanceAttenuation;
|
||||
#else
|
||||
emission = lerp(0, _ShallowColor.rgb, attenuation) * mainLight.distanceAttenuation;
|
||||
#endif
|
||||
|
||||
// =====Translucency End========
|
||||
|
||||
|
||||
#ifdef _LIGHT_COLOR
|
||||
// LightingLambert Light applied here
|
||||
half3 attenuatedLightColor = lightColor * (mainLight.distanceAttenuation * mainLight.shadowAttenuation);
|
||||
half3 diffuseColor = LightingLambert(attenuatedLightColor, lightDir, normalWS) + _GlossyEnvironmentColor.rgb * _AmbientStrength;
|
||||
float3 finalColor = (water.albedo * diffuseColor ) + emission + specular;
|
||||
#else
|
||||
float3 finalColor = (water.albedo ) + emission + specular;
|
||||
#endif
|
||||
|
||||
|
||||
finalColor = lerp(finalColor, _IntersectionColor.rgb, noise);
|
||||
|
||||
// =================== Make ApplyLight simple end =========================
|
||||
|
||||
finalColor = lerp(scene.color, finalColor, water.fog + noise);
|
||||
|
||||
//Apply fog
|
||||
|
||||
half fogCoord = InitializeInputDataFog(float4(positionWS,1), input.fogFactor);
|
||||
finalColor = MixFog(finalColor, fogCoord);
|
||||
|
||||
return float4(finalColor, water.alpha);
|
||||
}
|
||||
7
LocalPackages/zzwater/shaders/libs/ForwardPass.hlsl.meta
Normal file
7
LocalPackages/zzwater/shaders/libs/ForwardPass.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95ba63cd357fb4f8f9c245d81f3e78a3
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
69
LocalPackages/zzwater/shaders/libs/Input.hlsl
Normal file
69
LocalPackages/zzwater/shaders/libs/Input.hlsl
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
|
||||
TEXTURE2D(_IntersectionNoise);
|
||||
SAMPLER(sampler_IntersectionNoise);
|
||||
|
||||
TEXTURE2D(_CausticsTex);
|
||||
SAMPLER(sampler_CausticsTex);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
|
||||
float2 _Direction;
|
||||
float _Speed;
|
||||
half _AmbientStrength;
|
||||
|
||||
#ifdef TESSELLATION_ON
|
||||
float _TessValue;
|
||||
float _TessMin;
|
||||
float _TessMax;
|
||||
#endif
|
||||
|
||||
//Color + Transparency
|
||||
half4 _BaseColor;
|
||||
half4 _ShallowColor;
|
||||
float4 _HorizonColor;
|
||||
half _HorizonDistance;
|
||||
float _DepthVertical;
|
||||
float _DepthHorizontal;
|
||||
half _EdgeFade;
|
||||
|
||||
half _TranslucencyStrengthDirect;
|
||||
|
||||
//Reflection + Refraction
|
||||
float _ReflectionBlur;
|
||||
float _ReflectionFresnel;
|
||||
float _ReflectionStrength;
|
||||
|
||||
float _RefractionStrength;
|
||||
|
||||
//Intercection
|
||||
float4 _IntersectionColor;
|
||||
float _IntersectionLength;
|
||||
half _IntersectionTiling;
|
||||
half _IntersectionSpeed;
|
||||
half2 _IntersectionClipping;
|
||||
half _IntersectionFalloff;
|
||||
|
||||
// Wave foam
|
||||
half _WaveMesureMin;
|
||||
half _WaveMesureMax;
|
||||
half2 _WaveFoamClipping;
|
||||
|
||||
// Caustics
|
||||
half _CausticsBrightness;
|
||||
float _CausticsTiling;
|
||||
half _CausticsSpeed;
|
||||
half2 _CausticsClipping;
|
||||
|
||||
|
||||
//Waves
|
||||
float _WaveSpeed;
|
||||
half _WaveHeight;
|
||||
half _WaveNormalStr;
|
||||
float _WaveDistance;
|
||||
half2 _WaveFadeDistance;
|
||||
float _WaveSteepness;
|
||||
uint _WaveCount;
|
||||
half4 _WaveDirection;
|
||||
|
||||
CBUFFER_END
|
||||
7
LocalPackages/zzwater/shaders/libs/Input.hlsl.meta
Normal file
7
LocalPackages/zzwater/shaders/libs/Input.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95a615afb06ca4ffdba1edec02894c54
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
168
LocalPackages/zzwater/shaders/libs/Tesselation.hlsl
Normal file
168
LocalPackages/zzwater/shaders/libs/Tesselation.hlsl
Normal file
@@ -0,0 +1,168 @@
|
||||
|
||||
//Stylized Water 2
|
||||
//Staggart Creations (http://staggart.xyz)
|
||||
//Copyright protected under Unity Asset Store EULA
|
||||
|
||||
#if defined(SHADER_API_XBOXONE) || defined(SHADER_API_PSSL)
|
||||
// AMD recommends this value for GCN http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/05/GCNPerformanceTweets.pdf
|
||||
#define MAX_TESSELLATION_FACTORS 15.0
|
||||
#else
|
||||
#define MAX_TESSELLATION_FACTORS 64.0
|
||||
#endif
|
||||
|
||||
#if defined(SHADER_API_GLES2)
|
||||
#warning Current graphics API does not support tessellation, falling back to non-tessellated shader automatically.
|
||||
#else
|
||||
#define UNITY_CAN_COMPILE_TESSELLATION
|
||||
#endif
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float4 normalOS : NORMAL;
|
||||
float4 tangentOS : TANGENT;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
half fogFactor : TEXCOORD1;
|
||||
|
||||
//wPos.x in w-component
|
||||
float4 normalWS : NORMAL;
|
||||
//wPos.y in w-component
|
||||
float4 tangent : TANGENT;
|
||||
//wPos.z in w-component
|
||||
float4 bitangent : TEXCOORD4;
|
||||
|
||||
float4 positionNDC : TEXCOORD5;
|
||||
|
||||
float4 positionCS : SV_POSITION;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct TessellationFactors
|
||||
{
|
||||
float edge[3] : SV_TessFactor;
|
||||
float inside : SV_InsideTessFactor;
|
||||
};
|
||||
|
||||
struct VertexControl
|
||||
{
|
||||
float4 positionOS : INTERNALTESSPOS;
|
||||
float4 normalOS : NORMAL;
|
||||
float4 tangentOS : TANGENT;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
VertexControl VertexTessellation(Attributes input)
|
||||
{
|
||||
VertexControl output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
|
||||
output.positionOS = input.positionOS;
|
||||
output.normalOS = input.normalOS;
|
||||
output.tangentOS = input.tangentOS;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float CalcDistanceTessFactor(float4 positionOS, float minDist, float maxDist, float tess)
|
||||
{
|
||||
float3 positionWS = TransformObjectToWorld(positionOS.xyz).xyz;
|
||||
float dist = distance(positionWS, GetCurrentViewPosition());
|
||||
float f = (1.0-saturate((dist - minDist) / (maxDist - minDist)) + 0.001) * tess;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
|
||||
{
|
||||
float4 tess;
|
||||
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
|
||||
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
|
||||
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
|
||||
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
|
||||
return tess;
|
||||
}
|
||||
|
||||
float4 DistanceBasedTess(float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist)
|
||||
{
|
||||
float3 f;
|
||||
f.x = CalcDistanceTessFactor(v0, minDist, maxDist, tess);
|
||||
f.y = CalcDistanceTessFactor(v1, minDist, maxDist, tess);
|
||||
f.z = CalcDistanceTessFactor(v2, minDist, maxDist, tess);
|
||||
|
||||
//Don't use the Core RP version, creates cracks on edges
|
||||
return CalcTriEdgeTessFactors(f);
|
||||
}
|
||||
|
||||
TessellationFactors HullConstant(InputPatch<VertexControl, 3> patch)
|
||||
{
|
||||
TessellationFactors output;
|
||||
|
||||
float4 tf = DistanceBasedTess(patch[0].positionOS, patch[1].positionOS, patch[2].positionOS, _TessValue, _TessMin, _TessMax);
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(patch[0]);
|
||||
|
||||
output.edge[0] = tf.x;
|
||||
output.edge[1] = tf.y;
|
||||
output.edge[2] = tf.z;
|
||||
output.inside = tf.w;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[maxtessfactor(MAX_TESSELLATION_FACTORS)]
|
||||
[domain("tri")]
|
||||
[partitioning("fractional_odd")]
|
||||
[outputtopology("triangle_cw")]
|
||||
[patchconstantfunc("HullConstant")]
|
||||
[outputcontrolpoints(3)]
|
||||
VertexControl Hull(InputPatch<VertexControl, 3> input, uint id : SV_OutputControlPointID)
|
||||
{
|
||||
return input[id];
|
||||
}
|
||||
|
||||
#define TESSELLATION_INTERPOLATE_BARY_URP(name, bary) IN.name = input[0].name * bary.x + input[1].name * bary.y + input[2].name * bary.z
|
||||
|
||||
[domain("tri")]
|
||||
Varyings Domain(TessellationFactors factors, OutputPatch<VertexControl, 3> input, float3 baryCoords : SV_DomainLocation)
|
||||
{
|
||||
Attributes IN = (Attributes)0;
|
||||
Varyings output = (Varyings)0;
|
||||
|
||||
TESSELLATION_INTERPOLATE_BARY_URP(positionOS, baryCoords);
|
||||
TESSELLATION_INTERPOLATE_BARY_URP(normalOS, baryCoords);
|
||||
TESSELLATION_INTERPOLATE_BARY_URP(tangentOS, baryCoords);
|
||||
|
||||
//Tessellation does not work entirely correct with GPU instancing
|
||||
UNITY_TRANSFER_INSTANCE_ID(input[0], output);
|
||||
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(IN.normalOS.xyz, IN.tangentOS);
|
||||
float3 positionWS = TransformObjectToWorld(IN.positionOS.xyz);
|
||||
|
||||
WaveInfo waves = GetWaveInfo(positionWS.xz, TIME_VERTEX * _WaveSpeed, _WaveHeight, 1, _WaveFadeDistance.x, _WaveFadeDistance.y);
|
||||
|
||||
positionWS += waves.position;
|
||||
|
||||
float4 positionCS = TransformWorldToHClip(positionWS);
|
||||
|
||||
output.positionCS = positionCS;
|
||||
|
||||
float4 ndc = positionCS * 0.5f;
|
||||
ndc.xy = float2(ndc.x, ndc.y * _ProjectionParams.x) + ndc.w;
|
||||
ndc.zw = positionCS.zw;
|
||||
output.positionNDC = ndc;
|
||||
|
||||
output.normalWS = float4(waves.normal, positionWS.x);
|
||||
output.tangent = float4(normalInput.tangentWS, positionWS.y);
|
||||
output.bitangent = float4(normalInput.bitangentWS, positionWS.z);
|
||||
output.fogFactor = ComputeFogFactor(positionCS.z);
|
||||
|
||||
return output;
|
||||
}
|
||||
7
LocalPackages/zzwater/shaders/libs/Tesselation.hlsl.meta
Normal file
7
LocalPackages/zzwater/shaders/libs/Tesselation.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 997d96eeb92684567bef3d090a4b62f4
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
LocalPackages/zzwater/shaders/libs/URP.hlsl
Normal file
35
LocalPackages/zzwater/shaders/libs/URP.hlsl
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
//Stylized Water 2
|
||||
//Staggart Creations (http://staggart.xyz)
|
||||
//Copyright protected under Unity Asset Store EULA
|
||||
|
||||
#ifndef PIPELINE_INCLUDED
|
||||
#define PIPELINE_INCLUDED
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderVariablesFunctions.hlsl"
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
|
||||
#ifdef POST_PROCESSING //These would have the core blit library included
|
||||
#define UNITY_CORE_SAMPLERS_INCLUDED
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_CORE_SAMPLERS_INCLUDED //Backwards compatibility for <2023.1+
|
||||
#define UNITY_CORE_SAMPLERS_INCLUDED
|
||||
|
||||
SamplerState sampler_LinearClamp;
|
||||
SamplerState sampler_PointClamp;
|
||||
SamplerState sampler_PointRepeat;
|
||||
SamplerState sampler_LinearRepeat;
|
||||
#endif
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareOpaqueTexture.hlsl"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
7
LocalPackages/zzwater/shaders/libs/URP.hlsl.meta
Normal file
7
LocalPackages/zzwater/shaders/libs/URP.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4cafd3b397c0142d8a82101a49d68e45
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
LocalPackages/zzwater/shaders/libs/Vertex.hlsl
Normal file
64
LocalPackages/zzwater/shaders/libs/Vertex.hlsl
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float4 normalOS : NORMAL;
|
||||
float4 tangentOS : TANGENT;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
half fogFactor : TEXCOORD1;
|
||||
//wPos.x in w-component
|
||||
float4 normalWS : NORMAL;
|
||||
//wPos.y in w-component
|
||||
float4 tangent : TANGENT;
|
||||
//wPos.z in w-component
|
||||
float4 bitangent : TEXCOORD4;
|
||||
|
||||
float4 positionNDC : TEXCOORD5;
|
||||
|
||||
float4 positionCS : SV_POSITION;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
|
||||
Varyings LitPassVertex(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
|
||||
float3 positionWS = TransformObjectToWorld(input.positionOS.xyz);
|
||||
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS.xyz, input.tangentOS);
|
||||
|
||||
//WaveInfo waves = GetWaveInfo(uv, TIME_VERTEX * _WaveSpeed, _WaveHeight, lerp(1, 0, vertexColor.b), _WaveFadeDistance.x, _WaveFadeDistance.y);
|
||||
WaveInfo waves = GetWaveInfo(positionWS.xz, TIME_VERTEX * _WaveSpeed, _WaveHeight, 1, _WaveFadeDistance.x, _WaveFadeDistance.y);
|
||||
|
||||
//waves.normal = normalInput.normalWS;
|
||||
//waves.position = 0;
|
||||
|
||||
//Apply vertex displacements
|
||||
positionWS += waves.position.xyz;
|
||||
|
||||
float4 positionCS = TransformWorldToHClip(positionWS);
|
||||
|
||||
output.positionCS = positionCS;
|
||||
|
||||
float4 ndc = positionCS * 0.5f;
|
||||
ndc.xy = float2(ndc.x, ndc.y * _ProjectionParams.x) + ndc.w;
|
||||
ndc.zw = positionCS.zw;
|
||||
output.positionNDC = ndc;
|
||||
|
||||
output.normalWS = float4(waves.normal, positionWS.x);
|
||||
output.tangent = float4(normalInput.tangentWS, positionWS.y);
|
||||
output.bitangent = float4(normalInput.bitangentWS, positionWS.z);
|
||||
output.fogFactor = ComputeFogFactor(positionCS.z);
|
||||
|
||||
return output;
|
||||
}
|
||||
7
LocalPackages/zzwater/shaders/libs/Vertex.hlsl.meta
Normal file
7
LocalPackages/zzwater/shaders/libs/Vertex.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b8012d27dd264d5b8cdfb43d1dd1998
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
LocalPackages/zzwater/shaders/libs/WaveObj.hlsl
Normal file
28
LocalPackages/zzwater/shaders/libs/WaveObj.hlsl
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
//UNITY_SHADER_NO_UPGRADE
|
||||
#ifndef WATER_OBJ_INCLUDE
|
||||
#define WATER_OBJ_INCLUDE
|
||||
|
||||
#ifndef GET_TF_FROM_M
|
||||
#define GET_TF_FROM_M(m) dot(float3(m[0].w, m[1].w, m[2].w),1)
|
||||
#endif
|
||||
|
||||
inline float3 GetObjWaveDisplacement(float3 positionOS, float4 waterDir, float freq, float intensity, float factor)
|
||||
{
|
||||
float3 positionWS = TransformObjectToWorld(positionOS);
|
||||
float objFreq = _Time.y * freq + positionWS.y ;
|
||||
float objPhase = objFreq + GET_TF_FROM_M(GetObjectToWorldMatrix()) * waterDir.w;
|
||||
|
||||
float branchPhase = objPhase + dot(positionOS.xyz,1);
|
||||
|
||||
float offset = sin(objPhase) + cos(branchPhase);
|
||||
|
||||
return normalize(waterDir.xyz) * offset * factor * intensity;
|
||||
}
|
||||
|
||||
void GGetObjWaveDisplacement_float(float3 positionOS, float4 waterDir, float freq, float intensity, float factor, out float3 Out)
|
||||
{
|
||||
Out = GetObjWaveDisplacement(positionOS, waterDir, freq, intensity, factor);
|
||||
}
|
||||
|
||||
#endif //WATER_OBJ_INCLUDE
|
||||
7
LocalPackages/zzwater/shaders/libs/WaveObj.hlsl.meta
Normal file
7
LocalPackages/zzwater/shaders/libs/WaveObj.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a46a1e71fdaff524b9227e1bb5d54401
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
102
LocalPackages/zzwater/shaders/libs/Waves.hlsl
Normal file
102
LocalPackages/zzwater/shaders/libs/Waves.hlsl
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
|
||||
struct WaveInfo
|
||||
{
|
||||
float3 position;
|
||||
float3 normal;
|
||||
};
|
||||
|
||||
float3 GerstnerOffset4(float2 xzVtx, float4 steepness, float4 amp, float4 freq, float4 speed, float4 dirAB, float4 dirCD)
|
||||
{
|
||||
float3 offsets;
|
||||
|
||||
float4 AB = steepness.xxyy * dirAB.xyzw * amp.xxyy;
|
||||
float4 CD = steepness.zzww * dirCD.xyzw * amp.zzww;
|
||||
|
||||
float4 dotABCD = freq.xyzw * float4(dot(dirAB.xy, xzVtx), dot(dirAB.zw, xzVtx), dot(dirCD.xy, xzVtx), dot(dirCD.zw, xzVtx));
|
||||
|
||||
float4 COS = cos(dotABCD + speed); float4 SIN = sin(dotABCD + speed);
|
||||
|
||||
offsets.x = dot(COS, float4(AB.xz, CD.xz));
|
||||
offsets.z = dot(COS, float4(AB.yw, CD.yw));
|
||||
offsets.y = dot(SIN, amp); //Remap to only positive values;
|
||||
|
||||
return offsets;
|
||||
}
|
||||
|
||||
float3 GerstnerNormal4(float2 xzVtx, float4 amp, float4 freq, float4 speed, float4 dirAB, float4 dirCD)
|
||||
{
|
||||
float3 nrml = float3(0, 2.0, 0);
|
||||
|
||||
float4 AB = freq.xxyy * amp.xxyy * dirAB.xyzw;
|
||||
float4 CD = freq.zzww * amp.zzww * dirCD.xyzw;
|
||||
|
||||
float4 dotABCD = freq.xyzw * float4(dot(dirAB.xy, xzVtx), dot(dirAB.zw, xzVtx), dot(dirCD.xy, xzVtx), dot(dirCD.zw, xzVtx));
|
||||
|
||||
float4 COS = cos(dotABCD + speed);
|
||||
|
||||
nrml.x -= dot(COS, float4(AB.xz, CD.xz));
|
||||
nrml.z -= dot(COS, float4(AB.yw, CD.yw));
|
||||
|
||||
nrml.xz *= _WaveNormalStr;
|
||||
nrml = normalize(nrml);
|
||||
|
||||
return nrml;
|
||||
}
|
||||
|
||||
void Gerstner(inout float3 offs, inout float3 nrml,
|
||||
float2 position,
|
||||
float4 amplitude, float4 frequency, float4 steepness,
|
||||
float4 speed, float4 directionAB, float4 directionCD)
|
||||
{
|
||||
offs += GerstnerOffset4(position, steepness, amplitude, frequency, speed, directionAB, directionCD);
|
||||
nrml += GerstnerNormal4(position, amplitude, frequency, speed, directionAB, directionCD);
|
||||
}
|
||||
|
||||
#define WAVE_COUNT _WaveCount
|
||||
#define MAX_WAVE_COUNT 5
|
||||
|
||||
|
||||
#define STEEPNESS_SCALE 0.01
|
||||
|
||||
//v1.1.8+
|
||||
WaveInfo GetWaveInfo(float2 position, float2 time, float height, float mask, float fadeStart, float fadeEnd)
|
||||
{
|
||||
WaveInfo waves = (WaveInfo)0;
|
||||
|
||||
float4 amp = float4(0.3, 0.35, 0.25, 0.25);
|
||||
float4 freq = float4(1.3, 1.35, 1.25, 1.25) * (1-_WaveDistance) * 3.0;
|
||||
const float4 speed = float4(1.2* time.x, 1.375* time.y, 1.1 * time.x, time.y) ; //Pre-multiplied with time
|
||||
const float4 dir1 = float4(0.3, 0.85, 0.85, 0.25) * _WaveDirection;
|
||||
const float4 dir2 = float4(0.1, 0.9, -0.5, -0.5) * _WaveDirection;
|
||||
const float4 steepness = float4(12.0, 12.0, 12.0, 12.0) * _WaveSteepness * lerp(1.0, MAX_WAVE_COUNT, 1/WAVE_COUNT);
|
||||
|
||||
//Distance based scalar
|
||||
float pixelDist = length(GetCurrentViewPosition().xz - position.xy);
|
||||
float fadeFactor = saturate((fadeEnd - pixelDist ) / (fadeEnd-fadeStart));
|
||||
|
||||
for (uint i = 0; i <= WAVE_COUNT; i++)
|
||||
{
|
||||
float t = 1+((float)i / (float)WAVE_COUNT);
|
||||
freq *= t;
|
||||
amp *= fadeFactor;
|
||||
|
||||
Gerstner(/*out*/ waves.position, /*out*/ waves.normal, position, amp, freq, steepness, speed, dir1, dir2);
|
||||
}
|
||||
|
||||
waves.normal = normalize(waves.normal);
|
||||
//Average
|
||||
waves.position.y /= WAVE_COUNT;
|
||||
//waves.normal.xz *= WAVE_COUNT;
|
||||
|
||||
waves.position.xz *= STEEPNESS_SCALE * height * mask;
|
||||
waves.position.y *= height * mask;
|
||||
|
||||
return waves;
|
||||
}
|
||||
|
||||
//Depricated
|
||||
WaveInfo GetWaveInfo(float2 position, float2 time, float fadeStart, float fadeEnd)
|
||||
{
|
||||
return GetWaveInfo(position, time, 1.0, 1.0, fadeStart, fadeEnd);
|
||||
}
|
||||
7
LocalPackages/zzwater/shaders/libs/Waves.hlsl.meta
Normal file
7
LocalPackages/zzwater/shaders/libs/Waves.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9f90fe52c92f4d888cec5bf14c4cb9f
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
LocalPackages/zzwater/shaders/libs/WindAnim.hlsl
Normal file
56
LocalPackages/zzwater/shaders/libs/WindAnim.hlsl
Normal file
@@ -0,0 +1,56 @@
|
||||
//UNITY_SHADER_NO_UPGRADE
|
||||
#ifndef WIND_ANIM_INCLUDE
|
||||
#define WIND_ANIM_INCLUDE
|
||||
|
||||
inline float4 SmoothCurve( float4 x ) {
|
||||
return x * x *( 3.0 - 2.0 * x );
|
||||
}
|
||||
|
||||
inline float4 TriangleWave( float4 x ) {
|
||||
return abs( frac( x + 0.5 ) * 2.0 - 1.0 );
|
||||
}
|
||||
|
||||
inline float4 SmoothTriangleWave( float4 x ) {
|
||||
return SmoothCurve( TriangleWave( x ) );
|
||||
}
|
||||
|
||||
|
||||
inline float4 ClothWindAnim(float4 pos, float3 normal, float4 animParams,float4 wind,float2 time)
|
||||
{
|
||||
// animParams.x = branch phase
|
||||
// animParams.y = edge flutter factor
|
||||
// animParams.z = primary factor
|
||||
// animParams.w = secondary factor
|
||||
|
||||
|
||||
float fDetailAmp = 0.1f;
|
||||
float fBranchAmp = 0.3f;
|
||||
|
||||
// Phases (object, vertex, branch)
|
||||
float fObjPhase = dot(unity_ObjectToWorld[3].xyz, 1);
|
||||
float fBranchPhase = fObjPhase + animParams.x;
|
||||
|
||||
float fVtxPhase = dot(pos.xyz, animParams.y + fBranchPhase);
|
||||
|
||||
// x is used for edges; y is used for branches
|
||||
float2 vWavesIn = time + float2(fVtxPhase, fBranchPhase );
|
||||
|
||||
// 1.975, 0.793, 0.375, 0.193 are good frequencies
|
||||
float4 vWaves = (frac( vWavesIn.xxyy * float4(1.975, 0.793, 0.375, 0.193) ) * 2.0 - 1.0);
|
||||
|
||||
vWaves = SmoothTriangleWave( vWaves );
|
||||
float2 vWavesSum = vWaves.xz + vWaves.yw;
|
||||
|
||||
// Edge (xz) and branch bending (y)
|
||||
float3 bend = animParams.y * fDetailAmp * normal.xyz;
|
||||
bend.y = animParams.w * fBranchAmp;
|
||||
pos.xyz += ((vWavesSum.xyx * bend)*wind.w + (wind.xyz * vWavesSum.y * animParams.w)) * wind.w;
|
||||
|
||||
// Primary bending
|
||||
// Displace position
|
||||
pos.xyz += animParams.z * wind.xyz;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
#endif //WIND_ANIM_INCLUDE
|
||||
7
LocalPackages/zzwater/shaders/libs/WindAnim.hlsl.meta
Normal file
7
LocalPackages/zzwater/shaders/libs/WindAnim.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 418d88a69b1774954ace0d91b8c685d7
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
119
LocalPackages/zzwater/shaders/ocean.shader
Normal file
119
LocalPackages/zzwater/shaders/ocean.shader
Normal file
@@ -0,0 +1,119 @@
|
||||
Shader "zzwater/ocean"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Direction("Animation direction", Vector) = (0,-1,0,0)
|
||||
_Speed("Animation Speed", Float) = 1
|
||||
_AmbientStrength("Ambient strength", Range(0, 1)) = 0.5
|
||||
|
||||
//Color + Transparency
|
||||
[Toggle(_LIGHT_COLOR)] _LightColorOn("Main Light Color On", float) = 0
|
||||
[HDR]_BaseColor("Deep", Color) = (0, 0.44, 0.62, 1)
|
||||
[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
|
||||
_DepthHorizontal("Vertical Height Depth", Range(0.01 , 8)) = 1
|
||||
_EdgeFade("Edge Fade", Float) = 0.1
|
||||
_TranslucencyStrengthDirect("Translucency Strength (Direct)", Range(0 , 0.5)) = 0.05
|
||||
|
||||
//Reflection + Refraction
|
||||
[Toggle(_REFRACTION)] _RefractionOn("Refraction On", float) = 0
|
||||
_ReflectionStrength("Reflection Strength", Range(0, 1)) = 1
|
||||
_ReflectionBlur("Probe Blur Factor", Range(0, 1)) = 0
|
||||
_ReflectionFresnel("Reflection Curvature mask", Range(0.01, 20)) = 5
|
||||
_RefractionStrength("Refraction Strength", Range(0, 1)) = 0.1
|
||||
|
||||
//Intersection
|
||||
[Toggle(_INTERSECTION)] _IntersectionOn("Intersection On", float) = 0
|
||||
[NoScaleOffset][SingleLineTexture]_IntersectionNoise("Intersection noise", 2D) = "white" {}
|
||||
_IntersectionTiling("Noise Tiling", float) = 0.2
|
||||
_IntersectionColor("Foam Color", Color) = (1,1,1,1)
|
||||
_IntersectionSpeed("Intersection Speed Multi", Float) = 1
|
||||
_IntersectionClipping("Intersection Cutoff", Vector) = (0.5, 1, 0, 0)
|
||||
_IntersectionFalloff("Intersection Falloff", Range(0.01 , 1)) = 0.5
|
||||
_IntersectionLength("Intersection Distance", Range(0.01 , 5)) = 2
|
||||
|
||||
// Wave foam
|
||||
[Toggle(_WAVE_FOAM)] _WaveFoamOn("Wave Foam On", float) = 0
|
||||
_WaveMesureMin("Wave Mesure Min", float) = 0
|
||||
_WaveMesureMax("Wave Mesure Max", float) = 0.3
|
||||
_WaveFoamClipping("Wave Cutoff", Vector) = (0.9, 1, 0, 0)
|
||||
|
||||
// Caustics
|
||||
[Toggle(_CAUSTICS)] _CausticsOn("Caustics On", float) = 0
|
||||
_CausticsBrightness("Brightness", Float) = 2
|
||||
_CausticsTiling("Tiling", Float) = 0.5
|
||||
_CausticsSpeed("Speed multiplier", Float) = 0.1
|
||||
_CausticsClipping("Caustics Cutoff (Y)dis (X)dep", Vector) = (6,0.3, 0, 0)
|
||||
|
||||
|
||||
//waves
|
||||
_WaveSpeed("Wave Speed", Float) = 2
|
||||
_WaveHeight("Wave Height", Range(0 , 10)) = 0.25
|
||||
|
||||
_WaveNormalStr("Normal Strength", Range(0 , 32)) = 0.5
|
||||
_WaveDistance("Distance", Range(0 , 1)) = 0.8
|
||||
_WaveFadeDistance("Wave fade distance (Start/End)", Vector) = (150, 300, 0, 0)
|
||||
|
||||
_WaveSteepness("Steepness", Range(0 , 5)) = 0.1
|
||||
_WaveCount("Count", Range(1 , 5)) = 1
|
||||
_WaveDirection("Direction", vector) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
"UniversalMaterialType" = "Lit"
|
||||
"IgnoreProjector" = "True"
|
||||
"Queue" = "Transparent+0"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode"="UniversalForward" }
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
||||
ZWrite On
|
||||
Cull Back
|
||||
ZTest LEqual
|
||||
ZClip On
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/URP.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/Common.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/Input.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/Waves.hlsl"
|
||||
|
||||
#pragma shader_feature_local_fragment _LIGHT_COLOR
|
||||
#pragma shader_feature_local_fragment _REFRACTION
|
||||
#pragma shader_feature_local_fragment _INTERSECTION
|
||||
#pragma shader_feature_local_fragment _WAVE_FOAM
|
||||
#pragma shader_feature_local_fragment _CAUSTICS
|
||||
|
||||
//Fog rendering (integration)
|
||||
#define UnityFog
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#pragma vertex LitPassVertex
|
||||
#include "Packages/zzwater/shaders/libs/Vertex.hlsl"
|
||||
|
||||
#pragma fragment ForwardPassFragment
|
||||
#include "Packages/zzwater/shaders/libs/ForwardPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
9
LocalPackages/zzwater/shaders/ocean.shader.meta
Normal file
9
LocalPackages/zzwater/shaders/ocean.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e52380eaa118b4aa7adc141fb339553b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
LocalPackages/zzwater/shaders/ocean_tess.shader
Normal file
135
LocalPackages/zzwater/shaders/ocean_tess.shader
Normal file
@@ -0,0 +1,135 @@
|
||||
Shader "zzwater/ocean_tess"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Direction("Animation direction", Vector) = (0,-1,0,0)
|
||||
_Speed("Animation Speed", Float) = 1
|
||||
_AmbientStrength("Ambient strength", Range(0, 1)) = 0.5
|
||||
|
||||
//Tessellation
|
||||
_TessValue("Max subdivisions", Range(1, 64)) = 16
|
||||
_TessMin("Start Distance", Float) = 0
|
||||
_TessMax("End Distance", Float) = 15
|
||||
|
||||
//Color + Transparency
|
||||
[Toggle(_LIGHT_COLOR)] _LightColorOn("Main Light Color On", float) = 0
|
||||
[HDR]_BaseColor("Deep", Color) = (0, 0.44, 0.62, 1)
|
||||
[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
|
||||
_DepthHorizontal("Vertical Height Depth", Range(0.01 , 8)) = 1
|
||||
_EdgeFade("Edge Fade", Float) = 0.1
|
||||
_TranslucencyStrengthDirect("Translucency Strength (Direct)", Range(0 , 0.5)) = 0.05
|
||||
|
||||
|
||||
//Reflection + Refraction
|
||||
[Toggle(_REFRACTION)] _RefractionOn("Refraction On", float) = 0
|
||||
_ReflectionStrength("Reflection Strength", Range(0, 2)) = 1
|
||||
_ReflectionBlur("Probe Blur Factor", Range(0, 1)) = 0
|
||||
_ReflectionFresnel("Reflection Curvature mask", Range(0.01, 20)) = 5
|
||||
_RefractionStrength("Refraction Strength", Range(0, 1)) = 0.1
|
||||
|
||||
//Intersection
|
||||
[Toggle(_INTERSECTION)] _IntersectionOn("Intersection On", float) = 0
|
||||
[NoScaleOffset][SingleLineTexture]_IntersectionNoise("Intersection noise", 2D) = "white" {}
|
||||
_IntersectionTiling("Noise Tiling", float) = 0.2
|
||||
_IntersectionColor("Foam Color", Color) = (1,1,1,1)
|
||||
_IntersectionSpeed("Intersection Speed Multi", Float) = 1
|
||||
_IntersectionClipping("Intersection Cutoff", Vector) = (0.5, 1, 0, 0)
|
||||
_IntersectionFalloff("Intersection Falloff", Range(0.01 , 1)) = 0.5
|
||||
_IntersectionLength("Intersection Distance", Range(0.01 , 5)) = 2
|
||||
|
||||
// Wave foam
|
||||
[Toggle(_WAVE_FOAM)] _WaveFoamOn("Wave Foam On", float) = 0
|
||||
_WaveMesureMin("Wave Mesure Min", float) = 0
|
||||
_WaveMesureMax("Wave Mesure Max", float) = 0.3
|
||||
_WaveFoamClipping("Wave Cutoff", Vector) = (0.9, 1, 0, 0)
|
||||
|
||||
|
||||
// Caustics
|
||||
[Toggle(_CAUSTICS)] _CausticsOn("Caustics On", float) = 0
|
||||
[NoScaleOffset][SingleLineTexture]_CausticsTex("Caustics RGB", 2D) = "black" {}
|
||||
_CausticsBrightness("Brightness", Float) = 2
|
||||
_CausticsTiling("Tiling", Float) = 0.5
|
||||
_CausticsSpeed("Speed multiplier", Float) = 0.1
|
||||
_CausticsClipping("Caustics Cutoff (Y)dis (X)dep", Vector) = (6,0.3,0,0)
|
||||
|
||||
|
||||
//waves
|
||||
_WaveSpeed("Wave Speed", Float) = 2
|
||||
_WaveHeight("Wave Height", Range(0 , 10)) = 0.25
|
||||
|
||||
_WaveNormalStr("Normal Strength", Range(0 , 32)) = 0.5
|
||||
_WaveDistance("Distance", Range(0 , 1)) = 0.8
|
||||
_WaveFadeDistance("Wave fade distance (Start/End)", Vector) = (150, 300, 0, 0)
|
||||
|
||||
_WaveSteepness("Steepness", Range(0 , 5)) = 0.1
|
||||
_WaveCount("Count", Range(1 , 5)) = 1
|
||||
_WaveDirection("Direction", vector) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
"UniversalMaterialType" = "Lit"
|
||||
"IgnoreProjector" = "True"
|
||||
"Queue" = "Transparent+0"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode"="UniversalForward" }
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
||||
ZWrite On
|
||||
Cull Back
|
||||
ZTest LEqual
|
||||
ZClip On
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma target 4.6
|
||||
#pragma exclude_renderers gles
|
||||
|
||||
#define TESSELLATION_ON
|
||||
#pragma require tessellation tessHW
|
||||
#pragma hull Hull
|
||||
#pragma domain Domain
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/URP.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/Common.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/Input.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/Waves.hlsl"
|
||||
|
||||
|
||||
#pragma shader_feature_local_fragment _LIGHT_COLOR
|
||||
#pragma shader_feature_local_fragment _REFRACTION
|
||||
#pragma shader_feature_local_fragment _INTERSECTION
|
||||
#pragma shader_feature_local_fragment _WAVE_FOAM
|
||||
#pragma shader_feature_local_fragment _CAUSTICS
|
||||
|
||||
//Fog rendering (integration)
|
||||
#define UnityFog
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#pragma vertex VertexTessellation
|
||||
#include "Packages/zzwater/shaders/libs/Tesselation.hlsl"
|
||||
|
||||
|
||||
#pragma fragment ForwardPassFragment
|
||||
#include "Packages/zzwater/shaders/libs/ForwardPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
9
LocalPackages/zzwater/shaders/ocean_tess.shader.meta
Normal file
9
LocalPackages/zzwater/shaders/ocean_tess.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e1bb555fbe9641c1b49b207771e3641
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
LocalPackages/zzwater/shaders/water_plant.shader
Normal file
93
LocalPackages/zzwater/shaders/water_plant.shader
Normal file
@@ -0,0 +1,93 @@
|
||||
Shader "zzwater/waterPlant"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_TineColor("Tine color", Color) = (1,1,1)
|
||||
_SwayFreq("Sway Frequency", Range(0,5)) = 1.0
|
||||
_SwayIntensity("Sway Intensity", Range(0.05,0.5)) = 0.1
|
||||
_WaterDir("Water Direction", Vector) = (1,0,0,0)
|
||||
// _waterDir.w for wave diff from each other
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
"RenderType"="Opaque"
|
||||
"UniversalMaterialType" = "Unlit"
|
||||
"Queue"="Geometry"
|
||||
"DisableBatching"="False"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Universal Forward"
|
||||
|
||||
Tags
|
||||
{
|
||||
// LightMode: <None>
|
||||
}
|
||||
|
||||
// Render State
|
||||
Cull Back
|
||||
Blend One Zero
|
||||
ZTest LEqual
|
||||
ZWrite On
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/WaveObj.hlsl"
|
||||
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionHCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainTex_ST;
|
||||
float3 _TineColor;
|
||||
half _SwayFreq;
|
||||
half _SwayIntensity;
|
||||
float4 _WaterDir;
|
||||
CBUFFER_END
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
|
||||
|
||||
Varyings vert (Attributes v)
|
||||
{
|
||||
Varyings o;
|
||||
float3 displacement;
|
||||
v.positionOS.xyz += GetObjWaveDisplacement(v.positionOS, _WaterDir, _SwayFreq, _SwayIntensity, v.color.a);
|
||||
|
||||
o.positionHCS = TransformObjectToHClip(v.positionOS.xyz);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.color = v.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (Varyings i) : SV_Target
|
||||
{
|
||||
half4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
clip(albedo.a - 0.5);
|
||||
return half4(albedo.rgb * _TineColor, 1.0);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
9
LocalPackages/zzwater/shaders/water_plant.shader.meta
Normal file
9
LocalPackages/zzwater/shaders/water_plant.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1f0cdff4e5484686a1fd600c2d2c6b1
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
105
LocalPackages/zzwater/shaders/wind_cloth.shader
Normal file
105
LocalPackages/zzwater/shaders/wind_cloth.shader
Normal file
@@ -0,0 +1,105 @@
|
||||
Shader "zzwind/WindClothUnlit"
|
||||
{
|
||||
|
||||
Properties
|
||||
{
|
||||
|
||||
[MainTexture] _BaseMap("Texture", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1)
|
||||
_Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5
|
||||
_Wind("Wind params",Vector) = (1,1,1,1)
|
||||
_WindAmplitude("Wind Amplitude", float) = 0.5
|
||||
_WindSpeed("Wind Speed",float) = 0.5
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Opaque"
|
||||
"IgnoreProjector" = "True"
|
||||
"UniversalMaterialType" = "Unlit"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Unlit"
|
||||
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
||||
ZWrite On
|
||||
Cull Back
|
||||
ZTest LEqual
|
||||
ZClip On
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/WindAnim.hlsl"
|
||||
|
||||
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float _Cutoff;
|
||||
half4 _BaseColor;
|
||||
half4 _BaseMap_ST;
|
||||
half4 _Wind;
|
||||
float _WindAmplitude;
|
||||
float _WindSpeed;
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float4 tangentOS : TANGENT;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 normalOS : NORMAL;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : TEXCOORD2;
|
||||
};
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
|
||||
float bendingFact = input.color.a;
|
||||
float4 wind;
|
||||
wind.xyz = _Wind.xyz;
|
||||
wind.w = _Wind.w * bendingFact.x;
|
||||
|
||||
float4 windParams = float4(0,_WindAmplitude,bendingFact,0);
|
||||
float windTime = _Time.y * _WindSpeed;
|
||||
float4 VertexInWndPos = ClothWindAnim(input.positionOS,input.normalOS,windParams,wind,windTime);
|
||||
|
||||
output.positionCS = TransformObjectToHClip(VertexInWndPos);
|
||||
output.uv = TRANSFORM_TEX(input.uv, _BaseMap);
|
||||
output.color = input.color;
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 frag(Varyings input) : SV_Target
|
||||
{
|
||||
half2 uv = input.uv;
|
||||
half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv);
|
||||
half3 color = texColor.rgb * _BaseColor.rgb;
|
||||
half alpha = texColor.a * _BaseColor.a;
|
||||
clip(alpha - _Cutoff);
|
||||
|
||||
return float4(color, alpha);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
9
LocalPackages/zzwater/shaders/wind_cloth.shader.meta
Normal file
9
LocalPackages/zzwater/shaders/wind_cloth.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbc110f6abccf47ada5a8569ec9eb889
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user