升级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,6 +3,7 @@
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using WaveHarmonic.Crest.Utility;
namespace WaveHarmonic.Crest
@@ -10,11 +11,17 @@ namespace WaveHarmonic.Crest
/// <summary>
/// Simulates horizontal motion of water.
/// </summary>
[FilterEnum(nameof(_QuerySource), Filtered.Mode.Exclude, (int)LodQuerySource.CPU)]
[FilterEnum(nameof(_TextureFormatMode), Filtered.Mode.Exclude, (int)LodTextureFormatMode.Automatic)]
public sealed partial class FlowLod : Lod<IFlowProvider>
{
const string k_FlowKeyword = "CREST_FLOW_ON_INTERNAL";
static new class ShaderIDs
{
public static readonly int s_Flow = Shader.PropertyToID("g_Crest_Flow");
}
internal static readonly Color s_GizmoColor = new(0f, 0f, 1f, 0.5f);
internal override string ID => "Flow";
@@ -34,6 +41,7 @@ namespace WaveHarmonic.Crest
{
_Resolution = 128;
_TextureFormat = GraphicsFormat.R16G16_SFloat;
_MaximumQueryCount = 1024;
}
internal override void Enable()
@@ -50,11 +58,37 @@ namespace WaveHarmonic.Crest
Shader.DisableKeyword(k_FlowKeyword);
}
private protected override IFlowProvider CreateProvider(bool enable)
internal override void BuildCommandBuffer(WaterRenderer water, CommandBuffer buffer)
{
var time = water.CurrentTime;
var period = 1f;
var half = period * 0.5f;
var offset0 = Helpers.Fmod(time, period);
var weight0 = offset0 / half;
if (weight0 > 1f) weight0 = 2f - weight0;
var offset1 = Helpers.Fmod(time + half, period);
var weight1 = 1f - weight0;
Shader.SetGlobalVector(ShaderIDs.s_Flow, new(offset0, weight0, offset1, weight1));
base.BuildCommandBuffer(water, buffer);
}
private protected override IFlowProvider CreateProvider(bool onEnable)
{
Queryable?.CleanUp();
// Flow is GPU only, and can only be queried using the compute path.
return enable && Enabled ? new FlowQuery(_Water) : IFlowProvider.None;
return onEnable && Enabled && QuerySource == LodQuerySource.GPU
? IFlowProvider.Create(_Water)
: IFlowProvider.None;
}
internal override void SetGlobals(bool onEnable)
{
base.SetGlobals(onEnable);
// Zero offset. Use the first sample.
Shader.SetGlobalVector(ShaderIDs.s_Flow, new(0, 1, 0, 0));
}
internal static readonly SortedList<int, ILodInput> s_Inputs = new(Helpers.DuplicateComparison);