修改水

This commit is contained in:
2026-01-01 22:00:33 +08:00
parent 040a222bd6
commit 9ceffccd39
1800 changed files with 103929 additions and 139495 deletions

View File

@@ -0,0 +1,154 @@
// 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 "UnityCG.cginc"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Legacy/Core.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Legacy/InputsDriven.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
{
Cull Off ZWrite On ZTest Always
Pass
{
// Copies the color texture.
Name "Copy Color"
ZWrite Off
ZTest Always
Cull Off
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
ZTest Always
Cull Off
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
ZTest Always
Cull Off
HLSLPROGRAM
float Fragment(Varyings input) : SV_Depth
{
return 0.0;
}
ENDHLSL
}
Pass
{
// Clears the stencil buffer without clearing depth
Name "Clear Stencil"
ZWrite Off
ZTest Always
Cull Off
Blend Zero One
Stencil
{
Ref 0
Comp Always
Pass Replace
}
HLSLPROGRAM
float Fragment(Varyings input) : SV_Target
{
return 0.0;
}
ENDHLSL
}
Pass
{
Name "Copy"
Blend Off
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
}
}
}

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,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: