浏览代码

Updated Shadegraphs, Vegetation and WaterFX shaders to new API

/main
Andre McGrail 6 年前
当前提交
62ad6831
共有 8 个文件被更改,包括 165 次插入162 次删除
  1. 11
      Assets/Data/LightweightAsset.asset
  2. 2
      Assets/Shaders/Graphs/PackedPBR.ShaderGraph
  3. 16
      Assets/Shaders/Graphs/RaceBoats.ShaderGraph
  4. 101
      Assets/Shaders/Vegetation/LWVegetationShader.shader
  5. 36
      Assets/Shaders/Vegetation/ShadowPassVegetation.hlsl
  6. 10
      Assets/Shaders/Vegetation/Vegetation.hlsl
  7. 94
      Assets/scenes/Island.unity
  8. 57
      Packages/com.verasl.water-system/Shaders/WaterFXShader.shader

11
Assets/Data/LightweightAsset.asset


m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: LightweightAsset
m_EditorClassIdentifier:
m_DirectionalShadowsSupported: 1
m_PunctualLightsSupport: 2
m_LocalShadowsSupported: 0
m_SoftShadowsSupported: 1
m_MixedLightingSupported: 1
m_SupportsVertexLight: 0
m_RequireDepthTexture: 1
m_RequireSoftParticles: 0
m_RequireOpaqueTexture: 1

m_RenderScale: 1.15
m_SupportsDynamicBatching: 1
m_DirectionalShadowsSupported: 1
m_LocalShadowsSupported: 0
m_SoftShadowsSupported: 1
m_ResourcesAsset: {fileID: 11400000, guid: aac5a08c32552a14c89394b703f1978a, type: 2}
m_SavedXRConfig:
renderScale: 1.15

showDeviceView: 1
gameViewRenderMode: 3
m_ShadowType: 2

2
Assets/Shaders/Graphs/PackedPBR.ShaderGraph
文件差异内容过多而无法显示
查看文件

16
Assets/Shaders/Graphs/RaceBoats.ShaderGraph
文件差异内容过多而无法显示
查看文件

101
Assets/Shaders/Vegetation/LWVegetationShader.shader


// -------------------------------------
// Lightweight Pipeline keywords
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile _ _DIRECTIONAL_SHADOWS
#pragma multi_compile _ _DIRECTIONAL_SHADOWS_CASCADE
#pragma multi_compile _ _PUNCTUAL_LIGHTS_VERTEX _PUNCTUAL_LIGHTS
#pragma multi_compile _ _PUNCTUAL_LIGHT_SHADOWS
#pragma multi_compile _ _SHADOWS_SOFT
#pragma multi_compile _ _SHADOWS_ENABLED
#pragma multi_compile _ _LOCAL_SHADOWS_ENABLED
#pragma multi_compile _ _SHADOWS_SOFT
#pragma multi_compile _ _SHADOWS_CASCADE
// -------------------------------------
// Unity defined keywords

#endif
inputData.viewDirectionWS = FragmentViewDirWS(viewDir);
#ifdef _SHADOWS_ENABLED
#if defined(_DIRECTIONAL_SHADOWS)
inputData.shadowCoord = IN.shadowCoord;
#else
inputData.shadowCoord = float4(0, 0, 0, 0);

}
//vert
VegetationVertexOutput VegetationVertex(VegetationVertexInput v)
VegetationVertexOutput VegetationVertex(VegetationVertexInput input)
VegetationVertexOutput o = (VegetationVertexOutput)0;
VegetationVertexOutput output = (VegetationVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
o.uv.xy = v.texcoord;
float3 posWS = TransformObjectToWorld(v.position.xyz);
o.clipPos = TransformWorldToHClip(posWS);
output.uv.xy = input.texcoord;
v.position.xyz = VegetationDeformation(v.position.xyz, objectOrigin, v.normal, v.color.x, v.color.z, v.color.y);
input.positionOS = VegetationDeformation(input.positionOS, objectOrigin, input.normalOS, input.color.x, input.color.z, input.color.y);
posWS = TransformObjectToWorld(v.position.xyz);
o.clipPos = TransformWorldToHClip(posWS);
half3 viewDir = VertexViewDirWS(GetCameraPositionWS() - posWS);
VertexPosition vertexPosition = GetVertexPosition(input.positionOS);
VertexTBN vertexTBN = GetVertexTBN(input.normalOS, input.tangentOS);
half3 vertexLight = VertexLighting(vertexPosition.worldSpace, output.normal.xyz);
half fogFactor = ComputeFogFactor(vertexPosition.hclipSpace.z);
half3 viewDir = VertexViewDirWS(GetCameraPositionWS() - vertexPosition.worldSpace);
output.clipPos = vertexPosition.hclipSpace;
#ifdef _NORMALMAP
o.normal.w = viewDir.x;
o.tangent.w = viewDir.y;
o.binormal.w = viewDir.z;
#else
o.viewDir = viewDir;
#endif
// initializes o.normal and if _NORMALMAP also o.tangent and o.binormal
OUTPUT_NORMAL(v, o);
#ifdef _NORMALMAP
output.normal = half4(vertexTBN.normalWS, viewDir.x);
output.tangent = half4(vertexTBN.tangentWS, viewDir.y);
output.binormal = half4(vertexTBN.binormalWS, viewDir.z);
#else
output.normal = vertexTBN.normalWS;
output.viewDir = viewDir;
#endif
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.lightmapUV);
OUTPUT_SH(o.normal.xyz, o.vertexSH);
OUTPUT_LIGHTMAP_UV(input.lightmapUV, unity_LightmapST, output.lightmapUV);
OUTPUT_SH(output.normal.xyz, output.vertexSH);
output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
half3 vertexLight = VertexLighting(o.posWS, o.normal.xyz);
#if defined(FOG_EXP)
half fogFactor = ComputeGlobalFogFactor(posWS);
#else
half fogFactor = ComputeFogFactor(o.clipPos.z);
#endif
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
#ifdef _SHADOWS_ENABLED
#if SHADOWS_SCREEN
o.shadowCoord = ComputeShadowCoord(o.clipPos);
#else
o.shadowCoord = TransformWorldToShadowCoord(posWS);
#endif
#if defined(_DIRECTIONAL_SHADOWS) && !defined(_RECEIVE_SHADOWS_OFF)
output.shadowCoord = GetShadowCoord(vertexPosition);
o.occlusion = v.color.a;
output.occlusion = input.color.a;
return o;
return output;
}
//frag

// -------------------------------------
// Material Keywords
#define _ALPHATEST_ON 1
#pragma shader_feature _VERTEXANIMATION
//--------------------------------------
// GPU Instancing

#pragma fragment ShadowPassVegetationFragment
#include "Vegetation.hlsl"
#include "InputSurfaceVegetation.hlsl"
#include "ShadowPassVegetation.hlsl"

#include "LWRP/ShaderLibrary/Core.hlsl"
#include "Vegetation.hlsl"
VegetationVertexOutput DepthOnlyVertex(VegetationVertexInput v)
VegetationVertexOutput DepthOnlyVertex(VegetationVertexInput input)
VegetationVertexOutput o = (VegetationVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
VegetationVertexOutput output = (VegetationVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(input);
#if _VERTEXANIMATION
/////////////////////////////////////vegetation stuff//////////////////////////////////////////////////

v.position.xyz = VegetationDeformation(v.position.xyz, objectOrigin, v.normal, v.color.x, v.color.z, v.color.y);
input.positionOS = VegetationDeformation(input.positionOS, objectOrigin, input.normalOS, input.color.x, input.color.z, input.color.y);
VertexPosition vertexPosition = GetVertexPosition(input.positionOS);
o.uv.xy = v.texcoord;
o.clipPos = TransformObjectToHClip(v.position.xyz);
return o;
output.uv.xy = input.texcoord;
output.clipPos = vertexPosition.hclipSpace;
return output;
}
half4 DepthOnlyFragment(VegetationVertexOutput IN) : SV_TARGET

36
Assets/Shaders/Vegetation/ShadowPassVegetation.hlsl


struct VertexInput
{
float4 position : POSITION;
float3 normal : NORMAL;
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
half3 color : COLOR;
UNITY_VERTEX_INPUT_INSTANCE_ID
};

float4 clipPos : SV_POSITION;
};
float4 GetShadowPositionHClip(VertexInput v)
float4 GetShadowPositionHClip(VertexInput input)
float3 positionWS = TransformObjectToWorld(v.position.xyz);
float3 normalWS = TransformObjectToWorldDir(v.normal);
VertexPosition vertexPosition = GetVertexPosition(input.positionOS);
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
positionWS = normalWS * scale.xxx + positionWS;
float3 positionWS = normalWS * scale.xxx + vertexPosition.worldSpace;
float4 clipPos = TransformWorldToHClip(positionWS);
// _ShadowBias.x sign depens on if platform has reversed z buffer

return clipPos;
}
VertexOutput ShadowPassVegetationVertex(VertexInput v)
VertexOutput ShadowPassVegetationVertex(VertexInput input)
VertexOutput o;
UNITY_SETUP_INSTANCE_ID(v);
o.uv = v.texcoord;
o.clipPos = GetShadowPositionHClip(v);
return o;
VertexOutput output;
UNITY_SETUP_INSTANCE_ID(input);
#if _VERTEXANIMATION
/////////////////////////////////////vegetation stuff//////////////////////////////////////////////////
float3 objectOrigin = UNITY_ACCESS_INSTANCED_PROP(Props, _Position).xyz;
input.positionOS.xyz = VegetationDeformation(input.positionOS, objectOrigin, input.normalOS, input.color.x, input.color.z, input.color.y);
//////////////////////////////////////////////////////////////////////////////////////////////////////
#endif
output.uv = input.texcoord;
output.clipPos = GetShadowPositionHClip(input);
return output;
}
half4 ShadowPassVegetationFragment(VertexOutput IN) : SV_TARGET

10
Assets/Shaders/Vegetation/Vegetation.hlsl


struct VegetationVertexInput
{
float4 position : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float3 positionOS : POSITION;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
float4 color : COLOR;
half4 color : COLOR;
UNITY_VERTEX_INPUT_INSTANCE_ID
};

half4 fogFactorAndVertexLight : TEXCOORD6; // x: fogFactor, yzw: vertex light
#ifdef _SHADOWS_ENABLED
#ifdef _DIRECTIONAL_SHADOWS
float4 shadowCoord : TEXCOORD7;
#endif

94
Assets/scenes/Island.unity


m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 153441711}
m_LocalRotation: {x: 0.027335119, y: -0.9252545, z: 0.17501126, w: 0.33545187}
m_LocalRotation: {x: 0.027335458, y: -0.9252539, z: 0.17501108, w: 0.33545363}
m_LocalPosition: {x: -30.551498, y: 3.6019359, z: -57.88359}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:

m_Modifications:
- target: {fileID: 400000, guid: 074aa8ca109924e18baf19f3e26665b6, type: 3}
propertyPath: m_LocalPosition.x
value: -31.25
value: -43.75
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 074aa8ca109924e18baf19f3e26665b6, type: 3}
propertyPath: m_LocalPosition.y

propertyPath: m_LocalPosition.z
value: -62.5
value: -50
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 074aa8ca109924e18baf19f3e26665b6, type: 3}
propertyPath: m_LocalRotation.x

m_Name:
m_EditorClassIdentifier:
computeOverride: 1
_rampTexture: {fileID: 1043443325}
_rampTexture: {fileID: 1757511939}
_waves:
- amplitude: 0.30540264
direction: -166.8483

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1017609894}
m_LocalRotation: {x: 0.027335119, y: -0.9252545, z: 0.17501126, w: 0.33545187}
m_LocalRotation: {x: 0.027335458, y: -0.9252539, z: 0.17501108, w: 0.33545363}
m_LocalPosition: {x: -30.551498, y: 3.6019359, z: -57.88359}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1037858265}
m_CullTransparentMesh: 0
--- !u!28 &1043443325
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
m_Width: 128
m_Height: 4
m_CompleteImageSize: 2048
m_TextureFormat: 5
m_MipCount: 1
m_IsReadable: 1
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 1
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_LightmapFormat: 0
m_ColorSpace: 1
image data: 2048
_typelessdata: ffcfffffffb6fafaff9cf5f5ff83f0f0ff69ebebff50e6e6ff36e1e1ff22ddddff21dadaff21d7d7ff20d4d5ff1fd1d2ff1ececfff1dcccdff1cc9caff1bc6c7ff1bc3c4ff1ac0c2ff19bdbfff18bbbcff17b8baff16b5b7ff15b2b4ff15afb2ff14acafff13aaacff12a7a9ff11a4a7ff10a1a4ff0f9ea1ff0f9b9fff0e999cff0d9699ff0c9397ff0b9094ff0a8d91ff098a8eff09878cff088589ff078286ff067f84ff057d82ff057b81ff057a81ff057981ff057880ff057680ff05757fff05747fff04737fff04727eff04707eff046f7dff046e7dff046d7dff046b7cff046a7cff03697bff03687bff03667bff03657aff03647aff036379ff036179ff036079ff025f78ff025e78ff025d77ff025b77ff025a77ff025976ff025876ff025675ff025575ff015475ff015374ff015174ff015073ff014f73ff014e73ff014c72ff014b72ff004a71ff004971ff004871ff004670ff00456eff00436bff004169ff004066ff003e63ff003d61ff003b5eff00395cff003859ff003656ff003454ff003351ff00314eff002f4cff002e49ff002c47ff002b44ff002941ff00273fff00263cff00243aff002237ff002134ff001f32ff001d2fff001c2cff001a2aff001927ff001725ff001522ff00141fff00121dff00101aff000f18ff000d15ff000b12ff000a10ff00080dff00070aff000508ff000305ff000203ff000000ff010505ff020b09ff03100eff041612ff051b17ff06211bff072620ff092c24ff0a3129ff0b362dff0c3c32ff0d4136ff0e473bff0f4c3fff105244ff115748ff125d4dff136251ff146756ff156957ff156957ff156a58ff156a58ff166a58ff166b58ff166b59ff166c59ff176c59ff176c5aff176d5aff176d5aff186d5bff186e5bff186e5bff196f5cff196f5cff196f5cff19705cff1a705dff1a715dff1a715dff1a715eff1b725eff1b725eff1b725fff1b735fff1c735fff1c745fff1c7460ff1c7460ff1d7560ff1d7561ff1d7661ff1d7662ff1d7863ff1d7965ff1c7b66ff1c7c68ff1c7e6aff1b7f6bff1b816dff1b826eff1a8470ff1a8572ff198773ff198975ff198a76ff188c78ff188d7aff188f7bff17907dff17927eff179380ff169582ff169683ff169885ff159986ff159b88ff149c8aff149e8bff149f8dff13a18eff13a290ff13a492ff12a593ff12a795ff12a996ff11aa98ff11ac9aff11ad9bff10af9dff10b09eff0fb2a0ff0fb3a2ff0fb5a3ff0eb6a5ff0eb8a6ff0eb9a8ff0dbbaaff0dbcabff0dbeadff0cbfaeff0cc1b0ff0cc2b2ff0bc4b3ff0bc5b5ff0ac7b6ff0ac9b8ff0acab9ff09ccbbff09cdbdff09cfbeff08d0c0ff08d2c1ff08d3c3ff07d5c5ff07d6c6ff07d8c8ff06d9c9ff06dbcbff05dccdff05deceff05dfd0ff04e1d1ff04e2d3ff04e4d5ff03e5d6ff000000ff000001ff000001ff000002ff000003ff000004ff000005ff000006ff000007ff000008ff000009ff00000bff00000cff00000dff00000fff000011ff000012ff000013ff000015ff000017ff000019ff00001cff00001dff00001fff000021ff000024ff000026ff000029ff00002bff00002eff000031ff000034ff000037ff00003aff00003dff000040ff000043ff000047ff00004bff00004eff000052ff000056ff00005aff00005eff000063ff000067ff00006cff000070ff000075ff00007aff00007fff000084ff000089ff00008eff000094ff000099ff00009fff0000a4ff0000aaff0000afff0003b5ff0006bbff0009c1ff000dc7ff0010cdff0014d3ff0018d9ff001cdeff0021e4ff0025e9ff0029efff002ef4ff0033faff0038feff003efeff0043faff0049f7ff004ef3ff0054eeff005aebff0060e6ff0067e1ff006edcff0075d7ff007cd1ff0084cbff008cc5ff0094bfff009cb7ff00a5b0ff00ada8ff00b6a1ff00be99ff00c790ff04cf88ff0cd880ff14e177ff1ce96eff24f165ff2df85cff36ff54ff40fb4bff4af643ff53f13aff5deb32ff68e52aff72df23ff7dd81bff87d214ff91cb0dff9bc507ffa5be01ffaeb800ffb6b200ffbeae00ffc5a800ffcca300ffd29f00ffd89b00ffdd9800ffe39400ffe89000ffec8d00fff08b00fff48800fff68600fff98500fffc82000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
m_StreamData:
offset: 0
size: 0
path:
--- !u!1001 &1046596217
PrefabInstance:
m_ObjectHideFlags: 0

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1143740434}
m_LocalRotation: {x: -0.0019885907, y: 0.95968765, z: -0.0067912596, w: -0.28097975}
m_LocalRotation: {x: -0.0019885874, y: 0.9596878, z: -0.0067912606, w: -0.28097922}
m_LocalPosition: {x: 42, y: 2.51, z: 62.1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:

objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 372c59520c69cff4498f2d5d0e7b6c7c, type: 3}
--- !u!28 &1757511939
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
m_Width: 128
m_Height: 4
m_CompleteImageSize: 2048
m_TextureFormat: 5
m_MipCount: 1
m_IsReadable: 1
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 1
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_LightmapFormat: 0
m_ColorSpace: 1
image data: 2048
_typelessdata: ffcfffffffb6fafaff9cf5f5ff83f0f0ff69ebebff50e6e6ff36e1e1ff22ddddff21dadaff21d7d7ff20d4d5ff1fd1d2ff1ececfff1dcccdff1cc9caff1bc6c7ff1bc3c4ff1ac0c2ff19bdbfff18bbbcff17b8baff16b5b7ff15b2b4ff15afb2ff14acafff13aaacff12a7a9ff11a4a7ff10a1a4ff0f9ea1ff0f9b9fff0e999cff0d9699ff0c9397ff0b9094ff0a8d91ff098a8eff09878cff088589ff078286ff067f84ff057d82ff057b81ff057a81ff057981ff057880ff057680ff05757fff05747fff04737fff04727eff04707eff046f7dff046e7dff046d7dff046b7cff046a7cff03697bff03687bff03667bff03657aff03647aff036379ff036179ff036079ff025f78ff025e78ff025d77ff025b77ff025a77ff025976ff025876ff025675ff025575ff015475ff015374ff015174ff015073ff014f73ff014e73ff014c72ff014b72ff004a71ff004971ff004871ff004670ff00456eff00436bff004169ff004066ff003e63ff003d61ff003b5eff00395cff003859ff003656ff003454ff003351ff00314eff002f4cff002e49ff002c47ff002b44ff002941ff00273fff00263cff00243aff002237ff002134ff001f32ff001d2fff001c2cff001a2aff001927ff001725ff001522ff00141fff00121dff00101aff000f18ff000d15ff000b12ff000a10ff00080dff00070aff000508ff000305ff000203ff000000ff010505ff020b09ff03100eff041612ff051b17ff06211bff072620ff092c24ff0a3129ff0b362dff0c3c32ff0d4136ff0e473bff0f4c3fff105244ff115748ff125d4dff136251ff146756ff156957ff156957ff156a58ff156a58ff166a58ff166b58ff166b59ff166c59ff176c59ff176c5aff176d5aff176d5aff186d5bff186e5bff186e5bff196f5cff196f5cff196f5cff19705cff1a705dff1a715dff1a715dff1a715eff1b725eff1b725eff1b725fff1b735fff1c735fff1c745fff1c7460ff1c7460ff1d7560ff1d7561ff1d7661ff1d7662ff1d7863ff1d7965ff1c7b66ff1c7c68ff1c7e6aff1b7f6bff1b816dff1b826eff1a8470ff1a8572ff198773ff198975ff198a76ff188c78ff188d7aff188f7bff17907dff17927eff179380ff169582ff169683ff169885ff159986ff159b88ff149c8aff149e8bff149f8dff13a18eff13a290ff13a492ff12a593ff12a795ff12a996ff11aa98ff11ac9aff11ad9bff10af9dff10b09eff0fb2a0ff0fb3a2ff0fb5a3ff0eb6a5ff0eb8a6ff0eb9a8ff0dbbaaff0dbcabff0dbeadff0cbfaeff0cc1b0ff0cc2b2ff0bc4b3ff0bc5b5ff0ac7b6ff0ac9b8ff0acab9ff09ccbbff09cdbdff09cfbeff08d0c0ff08d2c1ff08d3c3ff07d5c5ff07d6c6ff07d8c8ff06d9c9ff06dbcbff05dccdff05deceff05dfd0ff04e1d1ff04e2d3ff04e4d5ff03e5d6ff000000ff000001ff000001ff000002ff000003ff000004ff000005ff000006ff000007ff000008ff000009ff00000bff00000cff00000dff00000fff000011ff000012ff000013ff000015ff000017ff000019ff00001cff00001dff00001fff000021ff000024ff000026ff000029ff00002bff00002eff000031ff000034ff000037ff00003aff00003dff000040ff000043ff000047ff00004bff00004eff000052ff000056ff00005aff00005eff000063ff000067ff00006cff000070ff000075ff00007aff00007fff000084ff000089ff00008eff000094ff000099ff00009fff0000a4ff0000aaff0000afff0003b5ff0006bbff0009c1ff000dc7ff0010cdff0014d3ff0018d9ff001cdeff0021e4ff0025e9ff0029efff002ef4ff0033faff0038feff003efeff0043faff0049f7ff004ef3ff0054eeff005aebff0060e6ff0067e1ff006edcff0075d7ff007cd1ff0084cbff008cc5ff0094bfff009cb7ff00a5b0ff00ada8ff00b6a1ff00be99ff00c790ff04cf88ff0cd880ff14e177ff1ce96eff24f165ff2df85cff36ff54ff40fb4bff4af643ff53f13aff5deb32ff68e52aff72df23ff7dd81bff87d214ff91cb0dff9bc507ffa5be01ffaeb800ffb6b200ffbeae00ffc5a800ffcca300ffd29f00ffd89b00ffdd9800ffe39400ffe89000ffec8d00fff08b00fff48800fff68600fff98500fffc82000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
m_StreamData:
offset: 0
size: 0
path:
--- !u!1001 &1757670560
PrefabInstance:
m_ObjectHideFlags: 0

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1768035350}
m_LocalRotation: {x: 0.0016203898, y: 0.998335, z: -0.035774864, w: 0.04521867}
m_LocalRotation: {x: 0.0016203917, y: 0.998335, z: -0.035774883, w: 0.045218702}
m_LocalPosition: {x: -44.930405, y: 6.7507715, z: 30.635294}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:

57
Packages/com.verasl.water-system/Shaders/WaterFXShader.shader


Name "WaterFX"
Tags{"LightMode" = "WaterFX"}
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma vertex WaterFXVertex
#pragma fragment WaterFXFragment
#define _NORMALMAP 1
struct appdata
struct Attributes
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float3 positionOS : POSITION;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
struct v2f
struct Varyings
{
float2 uv : TEXCOORD0;
half4 normal : TEXCOORD1; // xyz: normal, w: viewDir.x

sampler2D _MainTex;
v2f vert (appdata v)
Varyings WaterFXVertex (Attributes input)
v2f o;
half3 posWS = TransformObjectToWorld(v.vertex.xyz);
o.vertex = TransformWorldToHClip(posWS);
o.uv = v.uv;
Varyings output = (Varyings)0;
VertexPosition vertexPosition = GetVertexPosition(input.positionOS.xyz);
VertexTBN vertexTBN = GetVertexTBN(input.normalOS, input.tangentOS);
output.vertex = vertexPosition.hclipSpace;
output.uv = input.uv;
o.color = v.color;
output.color = input.color;
half3 viewDir = VertexViewDirWS(GetCameraPositionWS() - posWS);
o.normal.w = viewDir.x;
o.tangent.w = viewDir.y;
o.binormal.w = viewDir.z;
half3 viewDir = VertexViewDirWS(GetCameraPositionWS() - vertexPosition.worldSpace);
OUTPUT_NORMAL(v, o);
output.normal = half4(vertexTBN.normalWS, viewDir.x);
output.tangent = half4(vertexTBN.tangentWS, viewDir.y);
output.binormal = half4(vertexTBN.binormalWS, viewDir.z);
return o;
return output;
half4 frag (v2f i) : SV_Target
half4 WaterFXFragment (Varyings input) : SV_Target
half4 col = tex2D(_MainTex, i.uv);
half4 col = tex2D(_MainTex, input.uv);
half foamMask = col.r * i.color.r;
half foamMask = col.r * input.color.r;
disp *= i.color.a;
disp *= input.color.a;
half3 viewDir = half3(i.normal.w, i.tangent.w, i.binormal.w);
half3 normalWS = TangentToWorldNormal(tNorm, i.tangent.xyz, i.binormal.xyz, i.normal.xyz);
half3 viewDir = half3(input.normal.w, input.tangent.w, input.binormal.w);
half3 normalWS = TangentToWorldNormal(tNorm, input.tangent.xyz, input.binormal.xyz, input.normal.xyz);
normalWS = lerp(half3(0, 1, 0), normalWS, i.color.g);
normalWS = lerp(half3(0, 1, 0), normalWS, input.color.g);
half4 comp = half4(foamMask, normalWS.xz, disp);
#ifdef _INVERT_ON

正在加载...
取消
保存