升级水插件
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Crest Water System
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
// Solves 2D wave equation
|
||||
@@ -40,10 +40,11 @@ void UpdateDynamicWaves(uint3 id)
|
||||
const float 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. Always initialise
|
||||
// with 0 values.
|
||||
if (sliceIndexSource < 0.0 || sliceIndexSource >= cascadeSource._Count - 1.0)
|
||||
// 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)
|
||||
{
|
||||
// Always initialise with 0 values.
|
||||
_Crest_Target[id] = (float2)0;
|
||||
return;
|
||||
}
|
||||
@@ -91,21 +92,14 @@ void UpdateDynamicWaves(uint3 id)
|
||||
const float3 X = float3(1.0, 0.0, 0.0);
|
||||
const float3 Y = float3(-X.y, X.x, 0.0);
|
||||
|
||||
// no border wrap mode for RTs in unity it seems,
|
||||
// so make any off-array reads 0 manually
|
||||
const bool insideTarget = sliceIndexSource <= cascadeSource._Count && sliceIndexSource >= 0;
|
||||
|
||||
float fxm, fym, fxp, fyp; float2 ft_v;
|
||||
ft_v = fxm = fym = fxp = fyp = 0.0;
|
||||
|
||||
if (insideTarget)
|
||||
{
|
||||
fxm = cascadeSource.SampleDynamicWaves(uv_source - e * X).x; // x minus
|
||||
fym = cascadeSource.SampleDynamicWaves(uv_source - e * Y).x; // y minus
|
||||
fxp = cascadeSource.SampleDynamicWaves(uv_source + e * X).x; // x plus
|
||||
fyp = cascadeSource.SampleDynamicWaves(uv_source + e * Y).x; // y plus
|
||||
ft_v = cascadeSource.SampleDynamicWaves(uv_source);
|
||||
}
|
||||
fxm = cascadeSource.SampleDynamicWaves(uv_source - e * X).x; // x minus
|
||||
fym = cascadeSource.SampleDynamicWaves(uv_source - e * Y).x; // y minus
|
||||
fxp = cascadeSource.SampleDynamicWaves(uv_source + e * X).x; // x plus
|
||||
fyp = cascadeSource.SampleDynamicWaves(uv_source + e * Y).x; // y plus
|
||||
ft_v = cascadeSource.SampleDynamicWaves(uv_source);
|
||||
|
||||
// wave propagation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user