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

@@ -29,6 +29,76 @@ namespace WaveHarmonic.Crest
BeforeTransparent,
}
/// <summary>
/// Rules to exclude cameras.
/// </summary>
[@GenerateDoc]
[System.Flags]
public enum WaterCameraExclusion
{
/// <inheritdoc cref="Generated.WaterCameraExclusion.Nothing" />
[Tooltip("No exclusion rules applied.")]
Nothing = 0,
/// <inheritdoc cref="Generated.WaterCameraExclusion.Hidden" />
[Tooltip("Exclude hidden cameras.\n\nDoes not affect reflection cameras, as they are typically always hidden. Use the Reflection flag for them.")]
Hidden = 1 << 1,
/// <inheritdoc cref="Generated.WaterCameraExclusion.Reflection" />
[Tooltip("Exclude reflection cameras.")]
Reflection = 1 << 2,
/// <inheritdoc cref="Generated.WaterCameraExclusion.NonMainCamera" />
[Tooltip("Exclude cameras not tagged as MainCamera.")]
NonMainCamera = 1 << 3,
/// <inheritdoc cref="Generated.WaterCameraExclusion.Everything" />
[Tooltip("Apply all exclusion rules.")]
Everything = ~0,
}
/// <summary>
/// The background processing mode for when cameras do not render.
/// </summary>
[@GenerateDoc]
public enum WaterDataBackgroundMode
{
/// <inheritdoc cref="Generated.WaterDataBackgroundMode.Always" />
[Tooltip("Always progress simulations in the background when camera does not render.")]
Always,
/// <inheritdoc cref="Generated.WaterDataBackgroundMode.Inactive" />
[Tooltip("Progress simulations in the background when camera is inactive (ie !isActiveAndEnabled).")]
Inactive,
/// <inheritdoc cref="Generated.WaterDataBackgroundMode.Disabled" />
[Tooltip("Progress simulations in the background when camera is disabled (ie !enabled).")]
Disabled,
/// <inheritdoc cref="Generated.WaterDataBackgroundMode.Never" />
[Tooltip("Never progress simulations in the background.")]
Never,
}
[InspectorOrder(InspectorSort.ByName)]
[UnityEngine.Rendering.GenerateHLSL(sourcePath = "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings/Visualize.Crest")]
enum VisualizeDataTypes
{
Albedo,
Displacement,
DynamicWaves,
Level,
Flow,
Foam,
Shadow,
Depth,
Clip,
ShorelineDistance,
Absorption,
Scattering,
Cascades,
}
partial class WaterRenderer
{
internal const float k_MaximumWindSpeedKPH = 150f;
@@ -49,45 +119,60 @@ namespace WaveHarmonic.Crest
[@Group("Environment", Group.Style.Accordian)]
#if d_UnityModuleWind
[Tooltip("Uses a provided WindZone as the source of global wind.\n\nIt must be directional. Wind speed units are presumed to be in m/s.")]
[@GenerateAPI]
[@GenerateAPI(symbol: "d_UnityModuleWind")]
[@DecoratedField, SerializeField]
WindZone _WindZone;
[Tooltip("Whether to override the given wind zone's wind speed.")]
[@Predicated(nameof(_WindZone), hide: true)]
[@Show(nameof(_WindZone))]
[@GenerateAPI(symbol: "d_UnityModuleWind")]
[@InlineToggle, SerializeField]
bool _OverrideWindZoneWindSpeed;
#endif
[Tooltip("Base wind speed in km/h.\n\nControls wave conditions. Can be overridden on Shape* components.")]
[@Predicated(typeof(WaterRenderer), nameof(WindSpeedOverriden), inverted: true, hide: true)]
#if d_UnityModuleWind
[@Show(typeof(WaterRenderer), nameof(WindSpeedOverriden))]
[@ShowComputedProperty(nameof(WindSpeed))]
#endif
[@Range(0, k_MaximumWindSpeedKPH, scale: 2f)]
[@GenerateAPI(Getter.Custom)]
[SerializeField]
internal float _WindSpeed = 10f;
#if d_UnityModuleWind
[Tooltip("Whether to override the given wind zone's wind direction.")]
[@Predicated(nameof(_WindZone), hide: true)]
[@Show(nameof(_WindZone))]
[@GenerateAPI(symbol: "d_UnityModuleWind")]
[@InlineToggle, SerializeField]
bool _OverrideWindZoneWindDirection;
#endif
[Tooltip("Base wind direction in degrees.\n\nControls wave conditions. Can be overridden on Shape* components.")]
[@Predicated(typeof(WaterRenderer), nameof(WindDirectionOverriden), inverted: true, hide: true)]
#if d_UnityModuleWind
[@Show(typeof(WaterRenderer), nameof(WindDirectionOverriden))]
[@ShowComputedProperty(nameof(WindDirection))]
#endif
[@Range(-180, 180)]
[@GenerateAPI(Getter.Custom)]
[SerializeField]
internal float _WindDirection;
#if d_UnityModuleWind
[Tooltip("Whether to override the given wind zone's wind turbulence.")]
[@Predicated(nameof(_WindZone), hide: true)]
[@Show(nameof(_WindZone))]
[@GenerateAPI(symbol: "d_UnityModuleWind")]
[@InlineToggle, SerializeField]
bool _OverrideWindZoneWindTurbulence;
#endif
[Tooltip("Base wind turbulence.\n\nControls wave conditions. Can be overridden on ShapeFFT components.")]
[@Predicated(typeof(WaterRenderer), nameof(WindTurbulenceOverriden), inverted: true, hide: true)]
#if d_UnityModuleWind
[@Show(typeof(WaterRenderer), nameof(WindTurbulenceOverriden))]
[@ShowComputedProperty(nameof(WindTurbulence))]
#endif
[@Range(0, 1)]
[@GenerateAPI(Getter.Custom)]
[SerializeField]
@@ -102,7 +187,7 @@ namespace WaveHarmonic.Crest
[@Label("Gravity")]
[Tooltip("Gravity for all wave calculations.")]
[@Predicated(nameof(_OverrideGravity))]
[@Enable(nameof(_OverrideGravity))]
[@GenerateAPI]
[@DecoratedField, SerializeField]
float _GravityOverride = -9.8f;
@@ -140,14 +225,14 @@ namespace WaveHarmonic.Crest
[@Label("Color Texture")]
[Tooltip("Whether to write the water surface color to the color/opaque texture.\n\nThis is likely only beneficial if the water injection point is before transparency, and there are shaders which need it (like refraction).")]
[@Predicated(nameof(_InjectionPoint), inverted: false, nameof(WaterInjectionPoint.Default))]
[@Disable(nameof(_InjectionPoint), nameof(WaterInjectionPoint.Default))]
[@GenerateAPI(Getter.Custom)]
[@DecoratedField, SerializeField]
internal bool _WriteToColorTexture = true;
[@Label("Depth Texture")]
[Tooltip("Whether to write the water surface depth to the depth texture.\n\nThe water surface writes to the depth buffer, but Unity does not copy it to the depth texture for post-processing effects like Depth of Field (or refraction). This will copy the depth buffer to the depth texture.\n\nIf the water injection point is in the transparent pass, be wary that it will include all transparent objects that write to depth. Furthermore, other third parties may already be doing this, and we do not check whether it is necessary to copy or not.\n\nThis feature has a considerable overhead if using the built-in render pipeline, as it requires rendering the surface depth another time.")]
[@Predicated(nameof(_Surface) + "." + nameof(SurfaceRenderer._Enabled))]
[@Enable(nameof(_Surface) + "." + nameof(SurfaceRenderer._Enabled))]
[@GenerateAPI(Getter.Custom)]
[@DecoratedField, SerializeField]
internal bool _WriteToDepthTexture = true;
@@ -155,7 +240,7 @@ namespace WaveHarmonic.Crest
[@Label("Motion Vectors")]
[Tooltip("Whether to enable motion vector support.")]
#if !UNITY_6000_0_OR_NEWER
[@Predicated(RenderPipeline.Universal, inverted: true, hide: true)]
[@Hide(RenderPipeline.Universal)]
#endif
[@GenerateAPI(Getter.Custom)]
[@DecoratedField, SerializeField]
@@ -164,14 +249,14 @@ namespace WaveHarmonic.Crest
[@Space(10)]
[Tooltip("Whether to override the automatic detection of framebuffer HDR rendering (BIRP only).\n\nRendering using HDR formats is optional, but there is no way for us to determine if HDR rendering is enabled in the Graphics Settings. We make an educated based on which platform is the target. If you see rendering issues, try disabling this.\n\n This has nothing to do with having an HDR monitor.")]
[@Predicated(RenderPipeline.Legacy, hide: true)]
[@Show(RenderPipeline.Legacy)]
[@GenerateAPI]
[@InlineToggle, SerializeField]
bool _OverrideRenderHDR;
[Tooltip("Force HDR format usage (BIRP only).\n\nIf enabled, we assume the framebuffer is an HDR format, otherwise an LDR format.")]
[@Predicated(RenderPipeline.Legacy, hide: true)]
[@Predicated(nameof(_OverrideRenderHDR))]
[@Show(RenderPipeline.Legacy)]
[@Enable(nameof(_OverrideRenderHDR))]
[@GenerateAPI]
[@DecoratedField, SerializeField]
bool _RenderHDR = true;
@@ -228,13 +313,36 @@ namespace WaveHarmonic.Crest
[SerializeField]
internal float _ExtentsSizeMultiplier = 100f;
[@Heading("Center of Detail")]
[@Heading("Center of Detail", alwaysEnabled: true)]
[Tooltip("Whether to support multiple center-of-detail (per camera).")]
#if !UNITY_6000_0_OR_NEWER
[@Hide(RenderPipeline.HighDefinition)]
#endif
[@DecoratedField]
[SerializeField]
bool _MultipleViewpoints;
[Tooltip("The viewpoint which drives the water detail - the center of the LOD system.\n\nSetting this is optional. Defaults to the camera.")]
[@Disable(nameof(_MultipleViewpoints))]
[@GenerateAPI(Getter.Custom)]
[@DecoratedField, SerializeField]
Transform _Viewpoint;
[Tooltip("Rules to exclude cameras from being a center-of-detail.\n\nThese are exclusion rules, so for all cameras, select Nothing.")]
[@Enable(nameof(_MultipleViewpoints))]
[@DecoratedField]
[@GenerateAPI]
[SerializeField]
WaterCameraExclusion _CameraExclusions = WaterCameraExclusion.Everything;
[Tooltip("The background rendering mode when a camera does not render.\n\nWhen switching between multiple cameras, simulations will not progress for cameras which do not render for that frame. This setting tells the system when it should continue to progress the simulations.")]
[@Enable(nameof(_MultipleViewpoints))]
[@GenerateAPI]
[@DecoratedField]
[SerializeField]
internal WaterDataBackgroundMode _DataBackgroundMode = WaterDataBackgroundMode.Never;
[@Label("Displacement Correction")]
[Tooltip("Keep the center of detail from drifting from the viewpoint.\n\nLarge horizontal displacement can displace the center of detail. This uses queries to keep the center of detail aligned.")]
[@GenerateAPI]
@@ -242,13 +350,13 @@ namespace WaveHarmonic.Crest
bool _CenterOfDetailDisplacementCorrection = true;
[Tooltip("Also checks terrain height when determining the scale.\n\nThe scale is changed based on the viewer's height above the water surface. This can be a problem with varied water level, as the viewer may not be directly over the higher water level leading to a height difference, and thus incorrect scale.")]
[Predicated(nameof(_Viewpoint), inverted: true)]
[@Disable(nameof(_Viewpoint))]
[@GenerateAPI]
[@DecoratedField, SerializeField]
bool _SampleTerrainHeightForScale = true;
[Tooltip("Forces smoothing for scale changes.\n\nWhen water level varies, smoothing scale change can prevent pops when the viewer's height above water sharply changes. Smoothing is disabled when terrain sampling is enabled or the water level simulation is disabled.")]
[Predicated(nameof(_Viewpoint), inverted: true)]
[@Disable(nameof(_Viewpoint))]
[@GenerateAPI]
[@DecoratedField, SerializeField]
bool _ForceScaleChangeSmoothing;
@@ -371,17 +479,20 @@ namespace WaveHarmonic.Crest
[@DecoratedField, SerializeField]
internal bool _ShowWaterProxyPlane;
[Tooltip("Sets the update rate of the water system when in edit mode.\n\nCan be reduced to save power.")]
[@Range(0f, 120f, Range.Clamp.Minimum)]
[SerializeField]
float _EditModeFrameRate = 30f;
[Tooltip("Move water with Scene view camera if Scene window is focused.")]
[@Predicated(nameof(_ShowWaterProxyPlane), true)]
[@Disable(nameof(_ShowWaterProxyPlane))]
[@DecoratedField, SerializeField]
internal bool _FollowSceneCamera = true;
[Tooltip("Whether height queries are enabled in edit mode.")]
[Tooltip("Each scene view will have its own viewpoint.")]
#if !UNITY_6000_0_OR_NEWER
[@Hide(RenderPipeline.HighDefinition)]
#endif
[@DecoratedField]
[SerializeField]
bool _EditorMultipleViewpoints = true;
[Tooltip("Whether height queries are enabled in edit mode.\n\nQueries force enable \"Always Refresh\" scene view option.")]
[@DecoratedField, SerializeField]
internal bool _HeightQueries = true;
#pragma warning restore 414
@@ -397,6 +508,44 @@ namespace WaveHarmonic.Crest
{
[@Space(10)]
#if !CREST_DEBUG
[HideInInspector]
#endif
[@DecoratedField]
[@SerializeField]
public bool _VisualizeData;
[@Show(nameof(_VisualizeData))]
[@DecoratedField]
[@SerializeField]
public VisualizeDataTypes _VisualizeDataType;
[@Show(nameof(_VisualizeData))]
[@Range(-16, 16)]
[@SerializeField]
public float _VisualizeDataExposure;
[@Show(nameof(_VisualizeData))]
[@Range(1, 100)]
[@SerializeField]
public float _VisualizeDataRange = 10f;
[@Show(nameof(_VisualizeData))]
[@DecoratedField]
[@SerializeField]
public bool _VisualizeDataSaturate = true;
[@Space(10)]
#if !CREST_DEBUG
[HideInInspector]
#endif
[Tooltip("Simulates cameras not rendering.")]
[@DecoratedField, SerializeField]
public bool _SimulatePaused;
[@Space(10)]
[Tooltip("Attach debug GUI that adds some controls and allows to visualize the water data.")]
[@DecoratedField, SerializeField]
public bool _AttachDebugGUI;
@@ -429,24 +578,39 @@ namespace WaveHarmonic.Crest
#if !CREST_DEBUG
[HideInInspector]
#endif
[Tooltip("Water will not move with viewpoint.")]
[Tooltip("Log scale changes to the console.")]
[@DecoratedField, SerializeField]
public bool _LogScaleChange;
#if !CREST_DEBUG
[HideInInspector]
#endif
[Tooltip("Water will not move with viewpoint.")]
[Tooltip("Pause the editor when the scale changes.")]
[@DecoratedField, SerializeField]
public bool _PauseOnScaleChange;
#if !CREST_DEBUG
[HideInInspector]
#endif
[Tooltip("Water will not move with viewpoint.")]
[Tooltip("Ignore waves when calculation scale.")]
[@DecoratedField, SerializeField]
public bool _IgnoreWavesForScaleChange;
#if !CREST_DEBUG
[HideInInspector]
#endif
[@InlineToggle]
[SerializeField]
public bool _OverrideScale;
#if !CREST_DEBUG
[HideInInspector]
#endif
[@Enable(nameof(_OverrideScale))]
[@Range(1, 256, Range.Clamp.Minimum, power: true, step: 2)]
[SerializeField]
public int _ScaleOverride;
[@Heading("Server")]
[Tooltip("Emulate running on a client without a GPU. Equivalent to running standalone with -nographics argument.")]