This commit is contained in:
zhangjiajia
2026-05-06 16:56:59 +08:00
parent 575626d3e1
commit 81ffaaeca6
1373 changed files with 145920 additions and 0 deletions

View File

@@ -0,0 +1,159 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
// Provides utility passes for rendering like clearing the stencil buffer.
Shader "Hidden/Crest/Utility/Blit"
{
HLSLINCLUDE
#pragma vertex Vertex
#pragma fragment Fragment
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Legacy/Core.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Depth.hlsl"
struct Attributes
{
uint id : SV_VertexID;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
Varyings Vertex(Attributes input)
{
// This will work for all pipelines.
Varyings output = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
output.positionCS = GetFullScreenTriangleVertexPosition(input.id);
output.uv = GetFullScreenTriangleTexCoord(input.id);
return output;
}
ENDHLSL
SubShader
{
Blend Off
Cull Off
ZTest Always
ZWrite Off
Pass
{
// Copies the color texture.
Name "Copy Color"
HLSLPROGRAM
TEXTURE2D_X(_CameraColorTexture);
float4 Fragment(Varyings input) : SV_Target
{
// We need this when sampling a screenspace texture.
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
return LOAD_TEXTURE2D_X(_CameraColorTexture, input.positionCS.xy);
}
ENDHLSL
}
Pass
{
// Copies the depth from the camera depth texture. Clears the stencil for convenience.
Name "Copy Depth / Clear Stencil"
ZWrite On
Stencil
{
Ref 0
Comp Always
Pass Replace
}
HLSLPROGRAM
TEXTURE2D_X(_CameraDepthTexture);
float Fragment(Varyings input) : SV_Depth
{
// We need this when sampling a screenspace texture.
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
return LOAD_DEPTH_TEXTURE_X(_CameraDepthTexture, input.positionCS.xy);
}
ENDHLSL
}
Pass
{
// Clears the depth buffer without clearing the stencil.
Name "Clear Depth"
ZWrite On
HLSLPROGRAM
float Fragment(Varyings input) : SV_Depth
{
return 0.0;
}
ENDHLSL
}
Pass
{
// Clears the stencil buffer without clearing depth
Name "Clear Stencil"
ColorMask 0
Stencil
{
Ref 0
Comp Always
Pass Replace
}
HLSLPROGRAM
float Fragment(Varyings input) : SV_Target
{
return 0.0;
}
ENDHLSL
}
Pass
{
Name "Copy"
HLSLPROGRAM
TEXTURE2D(_Utility_MainTexture);
SAMPLER(sampler_Utility_MainTexture);
float4 Fragment(Varyings input) : SV_Target
{
return SAMPLE_TEXTURE2D(_Utility_MainTexture, sampler_Utility_MainTexture, input.uv);
}
ENDHLSL
}
Pass
{
Name "Merge Depth"
// All is required to merge depth.
ZTest Less
ZWrite On
HLSLPROGRAM
TEXTURE2D_X(_Utility_MainTexture);
float Fragment(Varyings input) : SV_Depth
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
return LOAD_DEPTH_TEXTURE_X(_Utility_MainTexture, input.positionCS.xy);
}
ENDHLSL
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b9836aaab4b1f45e4bd4fc4e6bcc7e74
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
// Clear specific components using a mask.
#pragma kernel CrestClearTarget
#pragma kernel CrestClearTargetBoundaryX d_BoundaryX
#pragma kernel CrestClearTargetBoundaryY d_BoundaryY
#include "HLSLSupport.cginc"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Macros.hlsl"
RWTexture2DArray<float4> _Crest_Target;
CBUFFER_START(CrestPerMaterial)
float4 _Crest_ClearMask;
float4 _Crest_ClearColor;
uint _Crest_Resolution;
uint _Crest_TargetSlice;
CBUFFER_END
#if d_BoundaryX
#define d_Axis y
#else
#define d_Axis x
#endif
m_UtilityNameSpace
void ClearTarget(uint3 id)
{
_Crest_Target[id] *= 1.0 - _Crest_ClearMask;
_Crest_Target[id] += _Crest_ClearColor;
}
void ClearTargetBoundary(uint3 id)
{
id.z = _Crest_TargetSlice;
_Crest_Target[id] = _Crest_ClearColor;
// Opposite row/column.
id.d_Axis = _Crest_Resolution - 1;
_Crest_Target[id] = _Crest_ClearColor;
}
m_UtilityNameSpaceEnd
m_UtilityKernelDefault(ClearTarget)
[numthreads(8, 1, 1)]
m_UtilityKernelVariant(ClearTargetBoundary, X)
[numthreads(1, 8, 1)]
m_UtilityKernelVariant(ClearTargetBoundary, Y)

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2641e78378c244c2e8ac89563a8ec9af
ComputeShaderImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5801035604cb84ff5a9557a2173630cd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
Shader "Hidden/Crest/Legacy/CaptureShadowMatrices"
{
SubShader
{
Blend Off
ColorMask 0
Cull Off
ZTest Always
ZWrite Off
Pass
{
HLSLPROGRAM
#pragma target 4.5
#pragma vertex Vertex
#pragma fragment Fragment
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
RWStructuredBuffer<float4x4> _Crest_WorldToShadow;
float4x4 unity_WorldToShadow[4];
float4 Vertex(uint id : SV_VertexID) : SV_POSITION
{
return GetFullScreenTriangleVertexPosition(id);
}
float4 Fragment(float4 pos : SV_POSITION) : SV_Target
{
_Crest_WorldToShadow[0] = unity_WorldToShadow[0];
_Crest_WorldToShadow[1] = unity_WorldToShadow[1];
_Crest_WorldToShadow[2] = unity_WorldToShadow[2];
_Crest_WorldToShadow[3] = unity_WorldToShadow[3];
return 0;
}
ENDHLSL
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 17feb724c7e004b4e8e418931db7eff3
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
Shader "Hidden/Crest/Legacy/ForceShadows"
{
CGINCLUDE
#pragma vertex Vertex
#pragma fragment Fragment
fixed4 Vertex(fixed4 v : POSITION) : SV_POSITION
{
return 0;
}
fixed4 Fragment(fixed4 i : SV_POSITION) : SV_Target
{
return 0;
}
ENDCG
SubShader
{
ZTest Always
ZWrite Off
ColorMask 0
Pass
{
Tags
{
"LightMode" = "ForwardBase"
}
CGPROGRAM
#pragma multi_compile_fwdbase
ENDCG
}
Pass
{
Tags
{
"LightMode" = "ForwardAdd"
}
CGPROGRAM
#pragma multi_compile_fwdadd_fullshadows
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: c9f384b6b84e943ed83161cb82d95b2e
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
// Renders a specific slice of a 2D Texture Array
// https://docs.unity3d.com/Manual/SL-TextureArrays.html
Shader "Hidden/Crest/Debug/TextureArray"
{
SubShader
{
Tags { "RenderType"="Opaque" }
Cull Off
ZWrite Off
Pass
{
CGPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#pragma require 2darray
#include "UnityCG.cginc"
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float3 uv : TEXCOORD0;
};
UNITY_DECLARE_TEX2DARRAY(_MainTex);
uint _Depth;
float _Scale;
float _Bias;
Varyings Vert(Attributes input)
{
Varyings o;
o.positionCS = UnityObjectToClipPos(input.positionOS);
o.uv = float3(input.uv.xy, _Depth);
return o;
}
half4 Frag(Varyings input) : SV_TARGET
{
return _Scale * UNITY_SAMPLE_TEX2DARRAY(_MainTex, input.uv) + _Bias;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9984e3507dd424fd49ce01182989250a
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: