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

@@ -8,49 +8,55 @@ namespace WaveHarmonic.Crest
{
partial class ShadowLod
{
internal bool ShouldRender(Camera camera)
{
if (!_Enabled)
{
return false;
}
// Even though volume also uses shadows, it only makes sense with a surface.
if (!_Water._ActiveModules.HasFlag(WaterRenderer.ActiveModules.Surface))
{
return false;
}
// Only sample shadows for the main camera.
if (_Water.IsSingleViewpointMode && _Water.Viewer != camera)
{
return false;
}
return true;
}
internal void OnBeginCameraRendering(ScriptableRenderContext context, Camera camera)
{
// TODO: refactor this similar to MaskRenderer.
if (!RenderPipelineHelper.IsLegacy)
{
#if d_UnityURP
if (RenderPipelineHelper.IsUniversal)
{
SampleShadowsURP.EnqueuePass(context, camera);
}
#endif
if (RenderPipelineHelper.IsUniversal)
{
SampleShadowsURP.EnqueuePass(context, camera);
return;
}
#endif
if (!RenderPipelineHelper.IsLegacy)
{
return;
}
CopyShadowMapBuffer?.Clear();
#if UNITY_EDITOR
// Do not execute when editor is not active to conserve power and prevent possible leaks.
if (!UnityEditorInternal.InternalEditorUtility.isApplicationActive)
{
CopyShadowMapBuffer?.Clear();
return;
}
if (!WaterRenderer.IsWithinEditorUpdate)
{
CopyShadowMapBuffer?.Clear();
return;
}
#endif
var water = _Water;
if (water == null)
{
return;
}
if (!WaterRenderer.ShouldRender(camera, water.Surface.Layer))
{
return;
}
if (camera == water.Viewer && CopyShadowMapBuffer != null)
if (CopyShadowMapBuffer != null)
{
if (_Light != null)
{
@@ -62,7 +68,7 @@ namespace WaveHarmonic.Crest
// Disable for XR SPI otherwise input will not have correct world position.
Rendering.BIRP.DisableXR(CopyShadowMapBuffer, camera);
BuildCommandBuffer(water, CopyShadowMapBuffer);
BuildCommandBuffer(_Water, CopyShadowMapBuffer);
// Restore XR SPI as we cannot rely on remaining pipeline to do it for us.
Rendering.BIRP.EnableXR(CopyShadowMapBuffer, camera);
@@ -71,6 +77,12 @@ namespace WaveHarmonic.Crest
internal void OnEndCameraRendering(Camera camera)
{
// Method is only called for either single viewpoint mode or separate viewpoints.
if (_Water.IsMultipleViewpointMode)
{
StoreCameraData(camera);
}
if (!RenderPipelineHelper.IsLegacy)
{
return;
@@ -83,36 +95,15 @@ namespace WaveHarmonic.Crest
CopyShadowMapBuffer?.Clear();
return;
}
if (!WaterRenderer.IsWithinEditorUpdate)
{
CopyShadowMapBuffer?.Clear();
return;
}
#endif
var water = _Water;
if (water == null)
// CBs added to a light are executed for every camera, but the LOD data is only
// supports a single camera. Removing the CB after the camera renders restricts the
// CB to one camera. Careful of recursive rendering for planar reflections, as it
// executes a camera within this camera's frame.
if (_Light != null && CopyShadowMapBuffer != null)
{
return;
}
if (!WaterRenderer.ShouldRender(camera, water.Surface.Layer))
{
return;
}
if (camera == water.Viewer)
{
// CBs added to a light are executed for every camera, but the LOD data is only
// supports a single camera. Removing the CB after the camera renders restricts the
// CB to one camera. Careful of recursive rendering for planar reflections, as it
// executes a camera within this camera's frame.
if (_Light != null && CopyShadowMapBuffer != null)
{
_Light.RemoveCommandBuffer(LightEvent.BeforeScreenspaceMask, CopyShadowMapBuffer);
}
_Light.RemoveCommandBuffer(LightEvent.BeforeScreenspaceMask, CopyShadowMapBuffer);
}
}
}