修改水

This commit is contained in:
2026-01-01 22:00:33 +08:00
parent 040a222bd6
commit 9ceffccd39
1800 changed files with 103929 additions and 139495 deletions

View File

@@ -0,0 +1,107 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
#if d_UnityHDRP
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
namespace WaveHarmonic.Crest
{
static class CustomPassHelpers
{
internal static List<CustomPassVolume> s_Volumes = new();
// Create or update Game Object.
public static GameObject CreateOrUpdate
(
Transform parent,
string name,
bool hide = true
)
{
GameObject gameObject = null;
// Find the existing custom pass volume.
// During recompiles, the reference will be lost so we need to find the game object. It could be limited to
// the editor if it is safe to do so, but there is a potential for leaking game objects.
if (gameObject == null)
{
var transform = parent.Find(name);
if (transform != null)
{
gameObject = transform.gameObject;
}
}
// Create or update the custom pass volume.
if (gameObject == null)
{
gameObject = new()
{
name = name,
hideFlags = hide ? HideFlags.HideAndDontSave : HideFlags.DontSave,
};
// Place the custom pass under the water renderer since it is easier to find later. Transform.Find can
// find inactive game objects unlike GameObject.Find.
gameObject.transform.parent = parent;
}
else
{
gameObject.hideFlags = hide ? HideFlags.HideAndDontSave : HideFlags.DontSave;
gameObject.SetActive(true);
}
return gameObject;
}
// Create or update Custom Pass Volume.
public static void CreateOrUpdate<T>
(
GameObject gameObject,
ref T pass,
string name,
CustomPassInjectionPoint injectionPoint
)
where T : CustomPass, new()
{
CustomPassVolume volume = null;
gameObject.GetComponents(s_Volumes);
foreach (var v in s_Volumes)
{
if (v.injectionPoint == injectionPoint)
{
volume = v;
break;
}
}
// Create the custom pass volume if it does not exist.
if (volume == null)
{
// It appears that this is currently the only way to add a custom pass.
volume = gameObject.AddComponent<CustomPassVolume>();
volume.injectionPoint = injectionPoint;
volume.isGlobal = true;
}
// Create custom pass.
pass ??= new()
{
name = $"Crest {name}",
targetColorBuffer = CustomPass.TargetBuffer.None,
targetDepthBuffer = CustomPass.TargetBuffer.None,
};
// Add custom pass.
if (!volume.customPasses.Contains(pass))
{
volume.customPasses.Add(pass);
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 03b1e50fbb96a49f1ac7de50cc1f30db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,189 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine;
using UnityEngine.Rendering;
namespace WaveHarmonic.Crest
{
/// <summary>
/// Unified interface for setting properties on both materials and material property blocks
/// </summary>
interface IPropertyWrapper
{
void SetFloat(int param, float value);
void SetFloatArray(int param, float[] value);
void SetVector(int param, Vector4 value);
void SetVectorArray(int param, Vector4[] value);
void SetTexture(int param, Texture value);
void SetMatrix(int param, Matrix4x4 matrix);
void SetInteger(int param, int value);
void SetBoolean(int param, bool value);
void GetBlock();
void SetBlock();
}
static class PropertyWrapperConstants
{
internal const string k_NoShaderMessage = "Cannot create required material because shader <i>{0}</i> could not be found or loaded."
+ " Try right clicking the Crest folder in the Project view and selecting Reimport, and checking for errors.";
}
readonly struct PropertyWrapperBuffer : IPropertyWrapper
{
public CommandBuffer Buffer { get; }
public PropertyWrapperBuffer(CommandBuffer mpb) => Buffer = mpb;
public void SetFloat(int param, float value) => Buffer.SetGlobalFloat(param, value);
public void SetFloatArray(int param, float[] value) => Buffer.SetGlobalFloatArray(param, value);
public void SetTexture(int param, Texture value) => Buffer.SetGlobalTexture(param, value);
public void SetVector(int param, Vector4 value) => Buffer.SetGlobalVector(param, value);
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 GetBlock() { }
public void SetBlock() { }
}
readonly struct PropertyWrapperRenderer : IPropertyWrapper
{
public MaterialPropertyBlock PropertyBlock { get; }
public Renderer Renderer { get; }
public PropertyWrapperRenderer(Renderer renderer, MaterialPropertyBlock block)
{
Renderer = renderer;
PropertyBlock = block;
}
public void SetFloat(int param, float value) => PropertyBlock.SetFloat(param, value);
public void SetFloatArray(int param, float[] value) => PropertyBlock.SetFloatArray(param, value);
public void SetTexture(int param, Texture value) => PropertyBlock.SetTexture(param, value);
public void SetBuffer(int param, ComputeBuffer value) => PropertyBlock.SetBuffer(param, value);
public void SetVector(int param, Vector4 value) => PropertyBlock.SetVector(param, value);
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 GetBlock() => Renderer.GetPropertyBlock(PropertyBlock);
public void SetBlock() => Renderer.SetPropertyBlock(PropertyBlock);
}
[System.Serializable]
readonly struct PropertyWrapperMaterial : IPropertyWrapper
{
public Material Material { get; }
public PropertyWrapperMaterial(Material material) => Material = material;
public PropertyWrapperMaterial(Shader shader)
{
Debug.Assert(shader != null, "Crest: PropertyWrapperMaterial: Cannot create required material because shader is null");
Material = new(shader);
}
public PropertyWrapperMaterial(string shaderPath)
{
var shader = Shader.Find(shaderPath);
Debug.AssertFormat(shader != null, $"Crest.PropertyWrapperMaterial: {PropertyWrapperConstants.k_NoShaderMessage}", shaderPath);
Material = new(shader);
}
public void SetFloat(int param, float value) => Material.SetFloat(param, value);
public void SetFloatArray(int param, float[] value) => Material.SetFloatArray(param, value);
public void SetTexture(int param, Texture value) => Material.SetTexture(param, value);
public void SetBuffer(int param, ComputeBuffer value) => Material.SetBuffer(param, value);
public void SetVector(int param, Vector4 value) => Material.SetVector(param, value);
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 GetBlock() { }
public void SetBlock() { }
// Non-Interface Methods
public void SetKeyword(in LocalKeyword keyword, bool value) => Material.SetKeyword(keyword, value);
}
readonly struct PropertyWrapperMPB : IPropertyWrapper
{
public MaterialPropertyBlock MaterialPropertyBlock { get; }
public PropertyWrapperMPB(MaterialPropertyBlock mpb) => MaterialPropertyBlock = mpb;
public void SetFloat(int param, float value) => MaterialPropertyBlock.SetFloat(param, value);
public void SetFloatArray(int param, float[] value) => MaterialPropertyBlock.SetFloatArray(param, value);
public void SetTexture(int param, Texture value) => MaterialPropertyBlock.SetTexture(param, value);
public void SetVector(int param, Vector4 value) => MaterialPropertyBlock.SetVector(param, value);
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 GetBlock() { }
public void SetBlock() { }
}
[System.Serializable]
readonly struct PropertyWrapperCompute : IPropertyWrapper
{
readonly CommandBuffer _Buffer;
readonly ComputeShader _Shader;
readonly int _Kernel;
public PropertyWrapperCompute(CommandBuffer buffer, ComputeShader shader, int kernel)
{
_Buffer = buffer;
_Shader = shader;
_Kernel = kernel;
}
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 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);
public void SetVector(int param, Vector4 value) => _Buffer.SetComputeVectorParam(_Shader, param, value);
public void SetVectorArray(int param, Vector4[] value) => _Buffer.SetComputeVectorArrayParam(_Shader, param, value);
public void SetMatrix(int param, Matrix4x4 value) => _Buffer.SetComputeMatrixParam(_Shader, param, value);
public void GetBlock() { }
public void SetBlock() { }
// Non-Interface Methods
public void SetKeyword(in LocalKeyword keyword, bool value) => _Buffer.SetKeyword(_Shader, keyword, value);
public void Dispatch(int x, int y, int z) => _Buffer.DispatchCompute(_Shader, _Kernel, x, y, z);
}
[System.Serializable]
readonly struct PropertyWrapperComputeStandalone : IPropertyWrapper
{
readonly ComputeShader _Shader;
readonly int _Kernel;
public PropertyWrapperComputeStandalone(ComputeShader shader, int kernel)
{
_Shader = shader;
_Kernel = kernel;
}
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 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);
public void SetVector(int param, Vector4 value) => _Shader.SetVector(param, value);
public void SetVectorArray(int param, Vector4[] value) => _Shader.SetVectorArray(param, value);
public void SetMatrix(int param, Matrix4x4 value) => _Shader.SetMatrix(param, value);
public void GetBlock() { }
public void SetBlock() { }
// Non-Interface Methods
public void SetKeyword(in LocalKeyword keyword, bool value) => _Shader.SetKeyword(keyword, value);
public void Dispatch(int x, int y, int z) => _Shader.Dispatch(_Kernel, x, y, z);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b2659ec9b44b34272a21ea388cd354d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
#if d_UnityURP
#if UNITY_6000_0_OR_NEWER
using System.Reflection;
using System.Runtime.CompilerServices;
using UnityEngine.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
using UnityEngine.Rendering.Universal;
namespace WaveHarmonic.Crest
{
static class RenderGraphHelper
{
public struct Handle
{
RTHandle _RTHandle;
TextureHandle _TextureHandle;
public readonly RTHandle Texture { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => _RTHandle ?? _TextureHandle; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Handle(RTHandle handle) => new() { _RTHandle = handle };
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Handle(TextureHandle handle) => new() { _TextureHandle = handle };
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator RTHandle(Handle texture) => texture.Texture;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator TextureHandle(Handle texture) => texture._TextureHandle;
}
static readonly FieldInfo s_RenderContext = typeof(InternalRenderGraphContext).GetField("renderContext", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly FieldInfo s_WrappedContext = typeof(UnsafeGraphContext).GetField("wrappedContext", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly FieldInfo s_FrameData = typeof(RenderingData).GetField("frameData", BindingFlags.NonPublic | BindingFlags.Instance);
public static ScriptableRenderContext GetRenderContext(this UnsafeGraphContext unsafeContext)
{
return (ScriptableRenderContext)s_RenderContext.GetValue((InternalRenderGraphContext)s_WrappedContext.GetValue(unsafeContext));
}
public static ContextContainer GetFrameData(this ref RenderingData renderingData)
{
return (ContextContainer)s_FrameData.GetValue(renderingData);
}
}
}
#endif // UNITY_6000_0_OR_NEWER
#endif // d_UnityURP

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ed778baa1b8804c5ca0074af8b68f7e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,169 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine;
using UnityEngine.Rendering;
namespace WaveHarmonic.Crest
{
static class RenderPipelineCompatibilityHelper
{
// Taken from:
// https://github.com/Unity-Technologies/Graphics/blob/19ec161f3f752db865597374b3ad1b3eaf110097/Packages/com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs#L588-L634
/// <summary>
/// Return true if handle does not match descriptor
/// </summary>
/// <param name="handle">RTHandle to check (can be null)</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>
/// <param name="scaled">Check if the RTHandle has auto scaling enabled if not, check the widths and heights</param>
/// <returns></returns>
internal static bool RTHandleNeedsReAlloc(
RTHandle handle,
in RenderTextureDescriptor descriptor,
FilterMode filterMode,
TextureWrapMode wrapMode,
bool isShadowMap,
int anisoLevel,
float mipMapBias,
string name,
bool scaled)
{
if (handle == null || handle.rt == null)
return true;
if (handle.useScaling != scaled)
return true;
if (!scaled && (handle.rt.width != descriptor.width || handle.rt.height != descriptor.height))
return true;
return
handle.rt.descriptor.depthBufferBits != descriptor.depthBufferBits ||
(handle.rt.descriptor.depthBufferBits == (int)DepthBits.None && !isShadowMap && handle.rt.descriptor.graphicsFormat != descriptor.graphicsFormat) ||
handle.rt.descriptor.dimension != descriptor.dimension ||
handle.rt.descriptor.enableRandomWrite != descriptor.enableRandomWrite ||
handle.rt.descriptor.useMipMap != descriptor.useMipMap ||
handle.rt.descriptor.autoGenerateMips != descriptor.autoGenerateMips ||
handle.rt.descriptor.msaaSamples != descriptor.msaaSamples ||
handle.rt.descriptor.bindMS != descriptor.bindMS ||
handle.rt.descriptor.useDynamicScale != descriptor.useDynamicScale ||
handle.rt.descriptor.memoryless != descriptor.memoryless ||
handle.rt.filterMode != filterMode ||
handle.rt.wrapMode != wrapMode ||
handle.rt.anisoLevel != anisoLevel ||
handle.rt.mipMapBias != mipMapBias ||
handle.name != name;
}
// https://github.com/Unity-Technologies/Graphics/blob/19ec161f3f752db865597374b3ad1b3eaf110097/Packages/com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs#L666-L695
/// <summary>
/// Re-allocate fixed-size 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="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></returns>
public static bool ReAllocateIfNeeded(
ref RTHandle handle,
in RenderTextureDescriptor descriptor,
FilterMode filterMode = FilterMode.Point,
TextureWrapMode wrapMode = TextureWrapMode.Repeat,
bool isShadowMap = false,
int anisoLevel = 1,
float mipMapBias = 0,
string name = "")
{
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;
}
// https://github.com/Unity-Technologies/Graphics/blob/19ec161f3f752db865597374b3ad1b3eaf110097/Packages/com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs#L697-L729
/// <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="scaleFactor">Constant scale 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 the RTHandle should be re-allocated</returns>
public static bool ReAllocateIfNeeded(
ref RTHandle handle,
Vector2 scaleFactor,
in RenderTextureDescriptor descriptor,
FilterMode filterMode = FilterMode.Point,
TextureWrapMode wrapMode = TextureWrapMode.Repeat,
bool isShadowMap = false,
int anisoLevel = 1,
float mipMapBias = 0,
string name = "")
{
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))
{
handle?.Release();
handle = RTHandles.Alloc(scaleFunc, descriptor, filterMode, wrapMode, isShadowMap, anisoLevel, mipMapBias, name);
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 39dff4a7749404569b14b7395adc361a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,57 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Rendering.Universal;
namespace WaveHarmonic.Crest
{
enum RenderPipeline
{
Legacy,
HighDefinition,
Universal,
}
sealed class RenderPipelineHelper
{
public static RenderPipeline RenderPipeline => GraphicsSettings.currentRenderPipeline switch
{
#if d_UnityHDRP
HDRenderPipelineAsset => RenderPipeline.HighDefinition,
#endif
#if d_UnityURP
UniversalRenderPipelineAsset => RenderPipeline.Universal,
#endif
_ => RenderPipeline.Legacy,
};
// GraphicsSettings.currentRenderPipeline could be from the graphics setting or current quality level.
public static bool IsLegacy => GraphicsSettings.currentRenderPipeline == null;
public static bool IsUniversal
{
get
{
#if d_UnityURP
return GraphicsSettings.currentRenderPipeline is UniversalRenderPipelineAsset;
#else
return false;
#endif
}
}
public static bool IsHighDefinition
{
get
{
#if d_UnityHDRP
return GraphicsSettings.currentRenderPipeline is HDRenderPipelineAsset;
#else
return false;
#endif
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 00e1b88667d3544fd875d2f9184fdd78
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
using UnityEngine;
namespace WaveHarmonic.Crest
{
static class TextureArrayHelpers
{
const int k_SmallTextureSize = 4;
public static Texture2D CreateTexture2D(Color color, TextureFormat format)
{
var texture = new Texture2D(k_SmallTextureSize, k_SmallTextureSize, format, false, false);
var pixels = new Color[texture.height * texture.width];
for (var i = 0; i < pixels.Length; i++)
{
pixels[i] = color;
}
texture.SetPixels(pixels);
texture.Apply();
return texture;
}
public static Texture2DArray CreateTexture2DArray(Texture2D texture, int depth)
{
var array = new Texture2DArray(
k_SmallTextureSize, k_SmallTextureSize,
depth,
texture.format,
false,
false
);
for (var textureArrayIndex = 0; textureArrayIndex < array.depth; textureArrayIndex++)
{
Graphics.CopyTexture(texture, 0, 0, array, textureArrayIndex, 0);
}
array.Apply();
return array;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 18d910d25ea794953b63417c1a72d587
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: