升级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

@@ -28,16 +28,16 @@
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Depth.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Volume/UnderwaterShared.hlsl"
#if !d_Crest_WaterSurface
#define CREST_INTEGRATE_COLOR_AFTER_FOG(color)
#define CREST_INTEGRATE_COLOR_FINAL(color)
#endif
m_CrestNameSpace
static bool s_IsUnderWater;
static float s_FogDistance;
static half s_FogMultiplier;
static float2 s_PositionSS;
static float3 s_PositionWS;
static half3 s_ViewWS;
static float s_DepthRaw;
static half3 s_VolumeOpacity;
static half3 s_VolumeLighting;
float3 ApplyFog(float3 color)
{
@@ -46,22 +46,11 @@ float3 ApplyFog(float3 color)
{
return color;
}
else
#endif
return ApplyUnderwaterEffect
(
color,
s_DepthRaw,
0, // Caustics only
s_FogDistance,
s_ViewWS,
s_PositionSS,
s_PositionWS,
false, // No caustics
true, // TODO: implement
true, // TODO: implement
s_FogMultiplier
);
{
return lerp(color, s_VolumeLighting, s_VolumeOpacity * (s_IsUnderWater ? 1.0 : 0.0));
}
}
float3 NoFog(float3 color)
@@ -122,12 +111,23 @@ void SetUpFog(const float2 i_PositionNDC, const float3 i_PositionWS, const float
}
s_IsUnderWater = true;
s_PositionSS = positionSS;
s_PositionWS = i_PositionWS;
s_ViewWS = GetWorldSpaceNormalizeViewDir(i_PositionWS);
s_FogDistance = fogDistance;
s_DepthRaw = i_DepthRaw;
s_FogMultiplier = i_Multiplier;
ApplyUnderwaterEffect
(
0, // Color
0, // TIR only
0, // Caustics only
fogDistance,
GetWorldSpaceNormalizeViewDir(i_PositionWS),
positionSS,
i_PositionWS,
false, // No caustics
true, // TODO: implement
true, // TODO: implement
i_Multiplier,
s_VolumeOpacity,
s_VolumeLighting
);
}
m_CrestNameSpaceEnd
@@ -139,6 +139,7 @@ m_CrestNameSpaceEnd
#endif
#if CREST_BIRP
// Color is RGBA.
#ifdef UNITY_PASS_FORWARDADD
#define m_Unity_FogColor fixed4(0, 0, 0, 0)
#else
@@ -155,27 +156,70 @@ if (m_Crest::s_IsUnderWater) \
else \
{ \
UNITY_APPLY_FOG_COLOR(coord, color, m_Unity_FogColor); \
}
CREST_INTEGRATE_COLOR_AFTER_FOG(color.rgb) \
} \
CREST_INTEGRATE_COLOR_FINAL(color.rgb)
#else
#define UNITY_APPLY_FOG(coord, color) \
UNITY_APPLY_FOG_COLOR(coord, color, m_Unity_FogColor); \
color.rgb = m_Crest::ApplyFog(color.rgb);
color.rgb = m_Crest::ApplyFog(color.rgb); \
if (!m_Crest::s_IsUnderWater) \
{ \
CREST_INTEGRATE_COLOR_AFTER_FOG(color.rgb) \
} \
CREST_INTEGRATE_COLOR_FINAL(color.rgb)
#endif // CREST_DISCARD_ATMOSPHERIC_SCATTERING
#endif // CREST_BIRP
#if CREST_HDRP
// Color is RGBA.
#if (CREST_DISCARD_ATMOSPHERIC_SCATTERING != 0)
#define EvaluateAtmosphericScattering(i, V, color) m_Crest::s_IsUnderWater ? float4(m_Crest::ApplyFog(color.rgb), color.a) : EvaluateAtmosphericScattering(i, V, color)
#define EvaluateAtmosphericScattering(i, V, color) color; \
if (m_Crest::s_IsUnderWater) \
{ \
color.rgb = m_Crest::ApplyFog(color.rgb); \
} \
else \
{ \
color = EvaluateAtmosphericScattering(i, V, color); \
CREST_INTEGRATE_COLOR_AFTER_FOG(color.rgb) \
} \
CREST_INTEGRATE_COLOR_FINAL(color.rgb)
#else
#define EvaluateAtmosphericScattering(i, V, color) EvaluateAtmosphericScattering(i, V, color); color.rgb = m_Crest::ApplyFog(color.rgb)
#define EvaluateAtmosphericScattering(i, V, color) color; \
color = EvaluateAtmosphericScattering(i, V, color); \
color.rgb = m_Crest::ApplyFog(color.rgb); \
if (!m_Crest::s_IsUnderWater) \
{ \
CREST_INTEGRATE_COLOR_AFTER_FOG(color.rgb); \
} \
CREST_INTEGRATE_COLOR_FINAL(color.rgb)
#endif
#endif
#if CREST_URP
// Color is RGB.
#if (CREST_DISCARD_ATMOSPHERIC_SCATTERING != 0)
#define MixFog(color, coord) m_Crest::s_IsUnderWater ? m_Crest::ApplyFog(color) : MixFog(color, coord)
#define MixFog(color, coord) color; \
if (m_Crest::s_IsUnderWater) \
{ \
color = m_Crest::ApplyFog(color); \
} \
else \
{ \
color = MixFog(color, coord); \
CREST_INTEGRATE_COLOR_AFTER_FOG(color) \
} \
CREST_INTEGRATE_COLOR_FINAL(color)
#else
#define MixFog(color, coord) MixFog(color, coord); color.rgb = m_Crest::ApplyFog(color.rgb)
#define MixFog(color, coord) color; \
color = MixFog(color, coord); \
color = m_Crest::ApplyFog(color); \
if (!m_Crest::s_IsUnderWater) \
{ \
CREST_INTEGRATE_COLOR_AFTER_FOG(color); \
} \
CREST_INTEGRATE_COLOR_FINAL(color)
#endif
#endif
@@ -216,6 +260,11 @@ void CrestNodeIntegrateWaterVolume_float
o_Color = i_Color;
o_Emission = i_Emission;
if (i_Multiplier == 0)
{
return;
}
#ifndef SHADERGRAPH_PREVIEW
m_Crest::SetUpFog(i_PositionNDC, i_PositionWS, i_DepthRaw, i_Multiplier);
#endif