升级6.4.升级水,升级天气

This commit is contained in:
2026-04-05 00:26:54 +08:00
parent 63bc9b5536
commit 5f7cbfb713
635 changed files with 34718 additions and 22567 deletions

View File

@@ -3,16 +3,26 @@
// Solves 2D wave equation
#pragma exclude_renderers glcore gles3
#pragma kernel CrestUpdateDynamicWaves
#pragma multi_compile _ CREST_FLOW_ON_INTERNAL
#include "HLSLSupport.cginc"
// Cascade macros expect this to be available.
#define g_Crest_CascadeDynamicWavesSource _Crest_Source
Texture2DArray _Crest_Source;
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Keywords.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Constants.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Globals.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/InputsDriven.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Cascade.hlsl"
RWTexture2DArray<float2> _Crest_Target;
RWTexture2DArray<m_Float2> _Crest_Target;
CBUFFER_START(CrestPerMaterial)
float _Crest_Damping;
@@ -37,15 +47,15 @@ float ComputeWaveSpeed(float wavelength, float g)
void UpdateDynamicWaves(uint3 id)
{
// Slice to sample previous frames data from. LOD change takes into account shifting of the cascades in scale.
const float sliceIndexSource = id.z + _Crest_LodChange;
const uint sliceIndexSource = id.z + _Crest_LodChange;
const Cascade cascadeSource = Cascade::MakeDynamicWavesSource(sliceIndexSource);
// Off either end of the cascade. Not useful to sample anything from previous
// frame, as we do not produce any new data from sources of waves.
if (sliceIndexSource < 0.0 || sliceIndexSource >= cascadeSource._Count)
if (sliceIndexSource < 0 || sliceIndexSource >= g_Crest_LodCount)
{
// Always initialise with 0 values.
_Crest_Target[id] = (float2)0;
_Crest_Target[id] = 0.0;
return;
}
@@ -72,12 +82,17 @@ void UpdateDynamicWaves(uint3 id)
// Wave reflections off geometry.
if (waterDepth <= 0.0)
{
_Crest_Target[id] = float2(0.0, 0.0);
_Crest_Target[id] = 0.0;
return;
}
float2 worldPosXZFlowed = worldPosXZ;
#if d_Crest_FlowLod
const half2 velocity = Cascade::MakeFlow(sliceIndex).SampleFlow(worldPosXZ);
const float2 worldPosXZFlowed = worldPosXZ - dt * velocity;
worldPosXZFlowed -= velocity * dt;
#endif
const float3 uv_source = cascadeSource.WorldToUV(worldPosXZFlowed);
// weighting for source position - weight 0 for off texture accesses to stop streaky artifacts
@@ -142,7 +157,7 @@ void UpdateDynamicWaves(uint3 id)
vtp = 0.0;
}
_Crest_Target[id] = float2(ftp, vtp);
_Crest_Target[id] = m_Float2Constructor(ftp, vtp);
}
m_CrestNameSpaceEnd