升级6.4.升级水,升级天气
This commit is contained in:
@@ -25,7 +25,7 @@ namespace WaveHarmonic.Crest
|
||||
public void SetVectorArray(int param, Vector4[] value) => Commands.SetGlobalVectorArray(param, value);
|
||||
public void SetMatrix(int param, Matrix4x4 value) => Commands.SetGlobalMatrix(param, value);
|
||||
public void SetInteger(int param, int value) => Commands.SetGlobalInteger(param, value);
|
||||
public void SetBoolean(int param, bool value) => Commands.SetGlobalInteger(param, value ? 1 : 0);
|
||||
public void SetBoolean(int param, bool value) => Commands.SetGlobalFloat(param, value ? 1f : 0f);
|
||||
|
||||
public void GetBlock() { }
|
||||
public void SetBlock() { }
|
||||
@@ -73,7 +73,7 @@ namespace WaveHarmonic.Crest
|
||||
public void SetVectorArray(int param, Vector4[] value) => Commands.SetGlobalVectorArray(param, value);
|
||||
public void SetMatrix(int param, Matrix4x4 value) => Commands.SetGlobalMatrix(param, value);
|
||||
public void SetInteger(int param, int value) => Commands.SetGlobalInteger(param, value);
|
||||
public void SetBoolean(int param, bool value) => Commands.SetGlobalInteger(param, value ? 1 : 0);
|
||||
public void SetBoolean(int param, bool value) => Commands.SetGlobalFloat(param, value ? 1f : 0f);
|
||||
|
||||
public void GetBlock() { }
|
||||
public void SetBlock() { }
|
||||
|
||||
@@ -23,6 +23,11 @@ namespace WaveHarmonic.Crest
|
||||
void SetBlock();
|
||||
}
|
||||
|
||||
interface IPropertyWrapperVariants : IPropertyWrapper
|
||||
{
|
||||
void SetKeyword(in LocalKeyword keyword, bool value);
|
||||
}
|
||||
|
||||
static class PropertyWrapperConstants
|
||||
{
|
||||
internal const string k_NoShaderMessage = "Cannot create required material because shader <i>{0}</i> could not be found or loaded."
|
||||
@@ -40,7 +45,7 @@ namespace WaveHarmonic.Crest
|
||||
public void SetVectorArray(int param, Vector4[] value) => Buffer.SetGlobalVectorArray(param, value);
|
||||
public void SetMatrix(int param, Matrix4x4 value) => Buffer.SetGlobalMatrix(param, value);
|
||||
public void SetInteger(int param, int value) => Buffer.SetGlobalInteger(param, value);
|
||||
public void SetBoolean(int param, bool value) => Buffer.SetGlobalInteger(param, value ? 1 : 0);
|
||||
public void SetBoolean(int param, bool value) => Buffer.SetGlobalFloat(param, value ? 1f : 0f);
|
||||
|
||||
public void GetBlock() { }
|
||||
public void SetBlock() { }
|
||||
@@ -65,14 +70,13 @@ namespace WaveHarmonic.Crest
|
||||
public void SetVectorArray(int param, Vector4[] value) => PropertyBlock.SetVectorArray(param, value);
|
||||
public void SetMatrix(int param, Matrix4x4 value) => PropertyBlock.SetMatrix(param, value);
|
||||
public void SetInteger(int param, int value) => PropertyBlock.SetInteger(param, value);
|
||||
public void SetBoolean(int param, bool value) => PropertyBlock.SetInteger(param, value ? 1 : 0);
|
||||
public void SetBoolean(int param, bool value) => PropertyBlock.SetFloat(param, value ? 1f : 0f);
|
||||
|
||||
public void GetBlock() => Renderer.GetPropertyBlock(PropertyBlock);
|
||||
public void SetBlock() => Renderer.SetPropertyBlock(PropertyBlock);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
readonly struct PropertyWrapperMaterial : IPropertyWrapper
|
||||
readonly struct PropertyWrapperMaterial : IPropertyWrapperVariants
|
||||
{
|
||||
public Material Material { get; }
|
||||
|
||||
@@ -97,7 +101,7 @@ namespace WaveHarmonic.Crest
|
||||
public void SetVectorArray(int param, Vector4[] value) => Material.SetVectorArray(param, value);
|
||||
public void SetMatrix(int param, Matrix4x4 value) => Material.SetMatrix(param, value);
|
||||
public void SetInteger(int param, int value) => Material.SetInteger(param, value);
|
||||
public void SetBoolean(int param, bool value) => Material.SetInteger(param, value ? 1 : 0);
|
||||
public void SetBoolean(int param, bool value) => Material.SetFloat(param, value ? 1f : 0f);
|
||||
|
||||
public void GetBlock() { }
|
||||
public void SetBlock() { }
|
||||
@@ -117,14 +121,13 @@ namespace WaveHarmonic.Crest
|
||||
public void SetVectorArray(int param, Vector4[] value) => MaterialPropertyBlock.SetVectorArray(param, value);
|
||||
public void SetMatrix(int param, Matrix4x4 value) => MaterialPropertyBlock.SetMatrix(param, value);
|
||||
public void SetInteger(int param, int value) => MaterialPropertyBlock.SetInteger(param, value);
|
||||
public void SetBoolean(int param, bool value) => MaterialPropertyBlock.SetInteger(param, value ? 1 : 0);
|
||||
public void SetBoolean(int param, bool value) => MaterialPropertyBlock.SetFloat(param, value ? 1f : 0f);
|
||||
|
||||
public void GetBlock() { }
|
||||
public void SetBlock() { }
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
readonly struct PropertyWrapperCompute : IPropertyWrapper
|
||||
readonly struct PropertyWrapperCompute : IPropertyWrapperVariants
|
||||
{
|
||||
readonly CommandBuffer _Buffer;
|
||||
readonly ComputeShader _Shader;
|
||||
@@ -140,7 +143,8 @@ namespace WaveHarmonic.Crest
|
||||
public void SetFloat(int param, float value) => _Buffer.SetComputeFloatParam(_Shader, param, value);
|
||||
public void SetFloatArray(int param, float[] value) => _Buffer.SetGlobalFloatArray(param, value);
|
||||
public void SetInteger(int param, int value) => _Buffer.SetComputeIntParam(_Shader, param, value);
|
||||
public void SetBoolean(int param, bool value) => _Buffer.SetComputeIntParam(_Shader, param, value ? 1 : 0);
|
||||
public void SetIntegers(int param, params int[] value) => _Buffer.SetComputeIntParams(_Shader, param, value);
|
||||
public void SetBoolean(int param, bool value) => _Buffer.SetComputeFloatParam(_Shader, param, value ? 1f : 0f);
|
||||
public void SetTexture(int param, Texture value) => _Buffer.SetComputeTextureParam(_Shader, _Kernel, param, value);
|
||||
public void SetTexture(int param, RenderTargetIdentifier value) => _Buffer.SetComputeTextureParam(_Shader, _Kernel, param, value);
|
||||
public void SetBuffer(int param, ComputeBuffer value) => _Buffer.SetComputeBufferParam(_Shader, _Kernel, param, value);
|
||||
@@ -156,8 +160,7 @@ namespace WaveHarmonic.Crest
|
||||
public void Dispatch(int x, int y, int z) => _Buffer.DispatchCompute(_Shader, _Kernel, x, y, z);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
readonly struct PropertyWrapperComputeStandalone : IPropertyWrapper
|
||||
readonly struct PropertyWrapperComputeStandalone : IPropertyWrapperVariants
|
||||
{
|
||||
readonly ComputeShader _Shader;
|
||||
readonly int _Kernel;
|
||||
@@ -171,7 +174,7 @@ namespace WaveHarmonic.Crest
|
||||
public void SetFloat(int param, float value) => _Shader.SetFloat(param, value);
|
||||
public void SetFloatArray(int param, float[] value) => _Shader.SetFloats(param, value);
|
||||
public void SetInteger(int param, int value) => _Shader.SetInt(param, value);
|
||||
public void SetBoolean(int param, bool value) => _Shader.SetBool(param, value);
|
||||
public void SetBoolean(int param, bool value) => _Shader.SetFloat(param, value ? 1f : 0f);
|
||||
public void SetTexture(int param, Texture value) => _Shader.SetTexture(_Kernel, param, value);
|
||||
public void SetBuffer(int param, ComputeBuffer value) => _Shader.SetBuffer(_Kernel, param, value);
|
||||
public void SetConstantBuffer(int param, ComputeBuffer value) => _Shader.SetConstantBuffer(param, value, 0, value.stride);
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace WaveHarmonic.Crest
|
||||
cameraData = frameData.Get<UniversalCameraData>();
|
||||
renderingData = frameData.Get<UniversalRenderingData>();
|
||||
|
||||
#if URP_COMPATIBILITY_MODE
|
||||
if (builder == null)
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
@@ -69,6 +70,7 @@ namespace WaveHarmonic.Crest
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
colorTargetHandle = resources.activeColorTexture;
|
||||
depthTargetHandle = resources.activeDepthTexture;
|
||||
|
||||
@@ -93,6 +93,7 @@ namespace WaveHarmonic.Crest
|
||||
return false;
|
||||
}
|
||||
|
||||
// Modified from:
|
||||
// https://github.com/Unity-Technologies/Graphics/blob/19ec161f3f752db865597374b3ad1b3eaf110097/Packages/com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs#L697-L729
|
||||
|
||||
/// <summary>
|
||||
@@ -108,7 +109,8 @@ namespace WaveHarmonic.Crest
|
||||
/// <param name="mipMapBias">Bias applied to mipmaps during filtering.</param>
|
||||
/// <param name="name">Name of the RTHandle.</param>
|
||||
/// <returns>If the RTHandle should be re-allocated</returns>
|
||||
public static bool ReAllocateIfNeeded(
|
||||
public static bool ReAllocateIfNeeded
|
||||
(
|
||||
ref RTHandle handle,
|
||||
Vector2 scaleFactor,
|
||||
in RenderTextureDescriptor descriptor,
|
||||
@@ -117,50 +119,28 @@ namespace WaveHarmonic.Crest
|
||||
bool isShadowMap = false,
|
||||
int anisoLevel = 1,
|
||||
float mipMapBias = 0,
|
||||
string name = "")
|
||||
string name = ""
|
||||
)
|
||||
{
|
||||
var usingConstantScale = handle != null && handle.useScaling && handle.scaleFactor == scaleFactor;
|
||||
if (!usingConstantScale || RTHandleNeedsReAlloc(handle, descriptor, filterMode, wrapMode, isShadowMap, anisoLevel, mipMapBias, name, true))
|
||||
// Only HDRP seems to use this?
|
||||
if (RenderPipelineHelper.IsHighDefinition)
|
||||
{
|
||||
handle?.Release();
|
||||
handle = RTHandles.Alloc(scaleFactor, descriptor, filterMode, wrapMode, isShadowMap, anisoLevel, mipMapBias, name);
|
||||
return true;
|
||||
var usingConstantScale = handle != null && handle.useScaling && handle.scaleFactor == scaleFactor;
|
||||
if (!usingConstantScale || RTHandleNeedsReAlloc(handle, descriptor, filterMode, wrapMode, isShadowMap, anisoLevel, mipMapBias, name, true))
|
||||
{
|
||||
handle?.Release();
|
||||
handle = RTHandles.Alloc(scaleFactor, descriptor, filterMode, wrapMode, isShadowMap, anisoLevel, mipMapBias, name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://github.com/Unity-Technologies/Graphics/blob/19ec161f3f752db865597374b3ad1b3eaf110097/Packages/com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs#L731-L764
|
||||
|
||||
/// <summary>
|
||||
/// Re-allocate dynamically resized RTHandle if it is not allocated or doesn't match the descriptor
|
||||
/// </summary>
|
||||
/// <param name="handle">RTHandle to check (can be null)</param>
|
||||
/// <param name="scaleFunc">Function used for the RTHandle size computation.</param>
|
||||
/// <param name="descriptor">Descriptor for the RTHandle to match</param>
|
||||
/// <param name="filterMode">Filtering mode of the RTHandle.</param>
|
||||
/// <param name="wrapMode">Addressing mode of the RTHandle.</param>
|
||||
/// <param name="isShadowMap">Set to true if the depth buffer should be used as a shadow map.</param>
|
||||
/// <param name="anisoLevel">Anisotropic filtering level.</param>
|
||||
/// <param name="mipMapBias">Bias applied to mipmaps during filtering.</param>
|
||||
/// <param name="name">Name of the RTHandle.</param>
|
||||
/// <returns>If an allocation was done</returns>
|
||||
public static bool ReAllocateIfNeeded(
|
||||
ref RTHandle handle,
|
||||
ScaleFunc scaleFunc,
|
||||
in RenderTextureDescriptor descriptor,
|
||||
FilterMode filterMode = FilterMode.Point,
|
||||
TextureWrapMode wrapMode = TextureWrapMode.Repeat,
|
||||
bool isShadowMap = false,
|
||||
int anisoLevel = 1,
|
||||
float mipMapBias = 0,
|
||||
string name = "")
|
||||
{
|
||||
var usingScaleFunction = handle != null && handle.useScaling && handle.scaleFactor == Vector2.zero;
|
||||
if (!usingScaleFunction || RTHandleNeedsReAlloc(handle, descriptor, filterMode, wrapMode, isShadowMap, anisoLevel, mipMapBias, name, true))
|
||||
else
|
||||
{
|
||||
handle?.Release();
|
||||
handle = RTHandles.Alloc(scaleFunc, descriptor, filterMode, wrapMode, isShadowMap, anisoLevel, mipMapBias, name);
|
||||
return true;
|
||||
if (RTHandleNeedsReAlloc(handle, descriptor, filterMode, wrapMode, isShadowMap, anisoLevel, mipMapBias, name, false))
|
||||
{
|
||||
handle?.Release();
|
||||
handle = RTHandles.Alloc(descriptor, filterMode, wrapMode, isShadowMap, anisoLevel, mipMapBias, name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -2,11 +2,18 @@
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
// ENABLE_VR is defined if the platform supports XR.
|
||||
// d_UnityModuleVR is defined if the VR module is installed.
|
||||
// VR module depends on XR module (which does nothing by itself) so we only need to check the VR module.
|
||||
#if ENABLE_VR && d_UnityModuleVR
|
||||
// In Unity 6.5, the XR module replaced the VR module.
|
||||
#if ENABLE_VR
|
||||
#if UNITY_6000_5_OR_NEWER
|
||||
#if d_UnityModuleXR
|
||||
#define _XR_ENABLED
|
||||
#endif
|
||||
#else
|
||||
#if d_UnityModuleVR
|
||||
#define _XR_ENABLED
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
@@ -1,18 +1,102 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#if ENABLE_VR && d_UnityModuleVR
|
||||
#if ENABLE_VR
|
||||
#if UNITY_6000_5_OR_NEWER
|
||||
#if d_UnityModuleXR
|
||||
#define _XR_ENABLED
|
||||
#endif
|
||||
#else
|
||||
#if d_UnityModuleVR
|
||||
#define _XR_ENABLED
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.XR;
|
||||
|
||||
namespace WaveHarmonic.Crest
|
||||
{
|
||||
static partial class Rendering
|
||||
{
|
||||
// Taken from Unity 6.5:
|
||||
// Packages/com.unity.render-pipelines.core/Runtime/Utilities/CoreUtils.cs
|
||||
|
||||
/// <summary>
|
||||
/// Return the GraphicsFormat of DepthStencil RenderTarget preferred for the current platform.
|
||||
/// </summary>
|
||||
/// <returns>The GraphicsFormat of DepthStencil RenderTarget preferred for the current platform.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static GraphicsFormat GetDefaultDepthStencilFormat()
|
||||
{
|
||||
#if UNITY_SWITCH || UNITY_SWITCH2 || UNITY_EMBEDDED_LINUX || UNITY_QNX || UNITY_ANDROID
|
||||
return GraphicsFormat.D24_UNorm_S8_UInt;
|
||||
#else
|
||||
return GraphicsFormat.D32_SFloat_S8_UInt;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Taken from Unity 6.5:
|
||||
// Packages/com.unity.render-pipelines.core/Runtime/Utilities/CoreUtils.cs
|
||||
|
||||
/// <summary>
|
||||
/// Return the GraphicsFormat of Depth-only RenderTarget preferred for the current platform.
|
||||
/// </summary>
|
||||
/// <returns>The GraphicsFormat of Depth-only RenderTarget preferred for the current platform.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static GraphicsFormat GetDefaultDepthOnlyFormat()
|
||||
{
|
||||
#if UNITY_SWITCH || UNITY_SWITCH2 || UNITY_EMBEDDED_LINUX || UNITY_QNX || UNITY_ANDROID
|
||||
return GraphicsFormatUtility.GetDepthStencilFormat(24, 0); // returns GraphicsFormat.D24_UNorm when hardware supports it
|
||||
#else
|
||||
return GraphicsFormat.D32_SFloat;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Taken from Unity 6.5:
|
||||
// Packages/com.unity.render-pipelines.core/Runtime/Utilities/CoreUtils.cs
|
||||
|
||||
/// <summary>
|
||||
/// Return the number of DepthStencil RenderTarget depth bits preferred for the current platform.
|
||||
/// </summary>
|
||||
/// <returns>The number of DepthStencil RenderTarget depth bits preferred for the current platform.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DepthBits GetDefaultDepthBufferBits()
|
||||
{
|
||||
#if UNITY_SWITCH || UNITY_SWITCH2 || UNITY_EMBEDDED_LINUX || UNITY_QNX || UNITY_ANDROID
|
||||
return DepthBits.Depth24;
|
||||
#else
|
||||
return DepthBits.Depth32;
|
||||
#endif
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static GraphicsFormat GetDefaultColorFormat(bool hdr)
|
||||
{
|
||||
return SystemInfo.GetGraphicsFormat(hdr ? DefaultFormat.HDR : DefaultFormat.LDR);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static GraphicsFormat GetDefaultDepthFormat(bool stencil)
|
||||
{
|
||||
return stencil ? GetDefaultDepthStencilFormat() : GetDefaultDepthOnlyFormat();
|
||||
}
|
||||
|
||||
// URP_COMPATIBILITY_MODE = URP + UE < 6.4
|
||||
public static bool IsRenderGraph => RenderPipelineHelper.IsUniversal
|
||||
#if URP_COMPATIBILITY_MODE
|
||||
#if !UNITY_6000_0_OR_NEWER
|
||||
&& false
|
||||
#else
|
||||
&& !GraphicsSettings.GetRenderPipelineSettings<UnityEngine.Rendering.Universal.RenderGraphSettings>().enableRenderCompatibilityMode
|
||||
#endif
|
||||
#endif
|
||||
;
|
||||
|
||||
public static partial class BIRP
|
||||
{
|
||||
static partial class ShaderIDs
|
||||
|
||||
Reference in New Issue
Block a user