还原水插件
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestTransferWaves
|
||||
|
||||
#pragma multi_compile_local __ d_Texture d_TextureBlend
|
||||
@@ -13,7 +11,6 @@
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Filtering.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Constants.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Globals.hlsl"
|
||||
@@ -35,8 +32,6 @@ float _Crest_RespectShallowWaterAttenuation;
|
||||
float _Crest_MaximumAttenuationDepth;
|
||||
float _Crest_WaveResolutionMultiplier;
|
||||
float _Crest_TransitionalWavelengthThreshold;
|
||||
uint _Crest_Resolution;
|
||||
bool _Crest_SeaLevelOnly;
|
||||
|
||||
// Texture
|
||||
#if d_Texture
|
||||
@@ -65,8 +60,6 @@ void TransferWaves(uint3 id)
|
||||
const uint last = parameters.y;
|
||||
const half transition = parameters.w;
|
||||
|
||||
const uint2 resolution = uint2(_Crest_Resolution, _Crest_Resolution);
|
||||
|
||||
#if !d_TextureBlend
|
||||
// Additive only. All wavelengths filtered out for this LOD so nothing to do.
|
||||
if (parameters.x < 0 || parameters.y < 0)
|
||||
@@ -161,12 +154,11 @@ void TransferWaves(uint3 id)
|
||||
axisZ1.x = -axisX1.y; axisZ1.y = axisX1.x;
|
||||
}
|
||||
#else
|
||||
|
||||
const float2 positionWaves = float2(dot(positionWS, _Crest_AxisX), dot(positionWS, float2(-_Crest_AxisX.y, _Crest_AxisX.x)));
|
||||
#endif // d_Texture
|
||||
|
||||
const half level = Cascade::MakeLevel(slice0).SampleLevel(positionWS);
|
||||
const half depth = Cascade::MakeDepth(slice0).SampleSignedDepthFromSeaLevel(positionWS) + level;
|
||||
const half depth = Cascade::MakeDepth(slice0).SampleSignedDepthFromSeaLevel(positionWS) +
|
||||
Cascade::MakeLevel(slice0).SampleLevel(positionWS);
|
||||
|
||||
half3 _displacement = 0.0;
|
||||
|
||||
@@ -225,8 +217,8 @@ void TransferWaves(uint3 id)
|
||||
const float2 uv1 = float2(dot(positionScaledWS, axisX1), dot(positionScaledWS, axisZ1));
|
||||
|
||||
// Sample displacement, rotate into frame.
|
||||
const float3 displacement0 = Utility::SampleBicubicRepeat(_Crest_WaveBuffer, uv0, resolution, waveBufferIndex).xyz;
|
||||
const float3 displacement1 = Utility::SampleBicubicRepeat(_Crest_WaveBuffer, uv1, resolution, waveBufferIndex).xyz;
|
||||
float3 displacement0 = _Crest_WaveBuffer.SampleLevel(sampler_Crest_linear_repeat, float3(uv0, waveBufferIndex), 0).xyz;
|
||||
float3 displacement1 = _Crest_WaveBuffer.SampleLevel(sampler_Crest_linear_repeat, float3(uv1, waveBufferIndex), 0).xyz;
|
||||
|
||||
float3 displacement = lerp(displacement0, displacement1, t);
|
||||
displacement.xz = displacement.x * axis + displacement.z * float2(-axis.y, axis.x);
|
||||
@@ -235,9 +227,7 @@ void TransferWaves(uint3 id)
|
||||
|
||||
#else // !d_Texture
|
||||
// Sample displacement, rotate into frame defined by global wind direction.
|
||||
// Hardware bilinear produces small noise artifacts. Custom bilinear solves that,
|
||||
// but we still get texel artifacts that show up in normals, so use bicubic.
|
||||
float3 displacement = Utility::SampleBicubicRepeat(_Crest_WaveBuffer, positionWaves / waveBufferSize, resolution, waveBufferIndex).xyz;
|
||||
half3 displacement = _Crest_WaveBuffer.SampleLevel(sampler_Crest_linear_repeat, float3(positionWaves / waveBufferSize, waveBufferIndex), 0).xyz;
|
||||
displacement.xz = displacement.x * _Crest_AxisX + displacement.z * float2(-_Crest_AxisX.y, _Crest_AxisX.x);
|
||||
_displacement += displacement * weight;
|
||||
#endif // d_Texture
|
||||
@@ -249,13 +239,6 @@ void TransferWaves(uint3 id)
|
||||
_Crest_Target[id] *= 1.0 - saturate(alpha);
|
||||
#endif
|
||||
|
||||
#if !d_Texture
|
||||
if (_Crest_SeaLevelOnly)
|
||||
{
|
||||
_displacement *= saturate(1.0 - abs(level));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Always write full alpha so textures show up in previews.
|
||||
_Crest_Target[id] += float4(_displacement, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
|
||||
#pragma multi_compile_local d_Sphere d_Cube d_Rectangle
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Adds clipping from a provided texture. Used by Painted and Texture input modes.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
// afterwards. It is converted to world-space in another shader before writing into
|
||||
// the LOD data.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestCopy
|
||||
#pragma kernel CrestFill
|
||||
|
||||
@@ -19,7 +17,7 @@
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Globals.hlsl"
|
||||
|
||||
Texture2D<float> _CamDepthBuffer;
|
||||
RWTexture2D<m_Float2> _Crest_Target;
|
||||
RWTexture2D<float2> _Crest_Target;
|
||||
|
||||
#if d_Crest_BackFaceInclusion
|
||||
Texture2D<float> _Crest_CameraDepthBufferBackfaces;
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
// from an ODC, then they are in object-space and are converted to world-space as
|
||||
// the LOD data stores world-space height.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
|
||||
#pragma multi_compile_local __ d_CrestSDF
|
||||
@@ -24,14 +22,14 @@
|
||||
|
||||
#if d_CrestSDF
|
||||
#undef m_CrestType
|
||||
#define m_CrestType m_Float2
|
||||
#define m_CrestType float2
|
||||
#endif
|
||||
|
||||
Texture2D<m_CrestType> _Crest_Texture;
|
||||
RWTexture2DArray<m_CrestType> _Crest_Target;
|
||||
|
||||
CBUFFER_START(CrestInputTexture)
|
||||
m_CrestType _Crest_Multiplier;
|
||||
float2 _Crest_Multiplier;
|
||||
float2 _Crest_TextureSize;
|
||||
float2 _Crest_TexturePosition;
|
||||
float2 _Crest_TextureRotation;
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Adds flow from a provided texture. Used by Painted and Texture input modes.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
@@ -17,7 +15,7 @@
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Cascade.hlsl"
|
||||
|
||||
Texture2D _Crest_Texture;
|
||||
RWTexture2DArray<m_Float2> _Crest_Target;
|
||||
RWTexture2DArray<float2> _Crest_Target;
|
||||
|
||||
CBUFFER_START(CrestPerMaterial)
|
||||
int _Crest_Blend;
|
||||
@@ -64,8 +62,7 @@ void Execute(uint3 id)
|
||||
}
|
||||
|
||||
const float2 target = _Crest_Target[id];
|
||||
const float2 result = Blend(_Crest_Blend, weight, 1.0, source, target);
|
||||
_Crest_Target[id] = m_Float2FromFloat2(result);
|
||||
_Crest_Target[id] = Blend(_Crest_Blend, weight, 1.0, source, target);
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Adds foam from a provided texture. Used by Painted and Texture input modes.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
// An implementation of the Jump Flood algorithm by Rong and Tan
|
||||
// Source: https://www.comp.nus.edu.sg/~tants/jfa.html
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestInitialize
|
||||
#pragma kernel CrestExecute
|
||||
#pragma kernel CrestApply
|
||||
@@ -29,13 +27,13 @@ float _Crest_WaterLevel;
|
||||
CBUFFER_END
|
||||
|
||||
// Holds scene depth for initialization.
|
||||
Texture2D<m_Float2> _Crest_Source;
|
||||
RWTexture2D<m_Float2> _Crest_Target;
|
||||
Texture2D<float2> _Crest_Source;
|
||||
RWTexture2D<float2> _Crest_Target;
|
||||
|
||||
// Setting this to zero means that geometry at exactly the origin won't be handled
|
||||
// gracefully - but it would only affect a single-pixel in the worst-case and would
|
||||
// doubtfully be noticable anyway. Use infinity instead.
|
||||
#define m_CrestUninitializedPosition m_Float2Constructor(m_Crest_PositiveInfinity, m_Crest_PositiveInfinity)
|
||||
#define m_CrestUninitializedPosition float2(m_Crest_PositiveInfinity, m_Crest_PositiveInfinity)
|
||||
|
||||
#if d_Crest_Inverted
|
||||
#define m_DepthCheck depth > 0.0
|
||||
@@ -68,7 +66,7 @@ void Initialize(const uint3 id)
|
||||
depth += lerp(Cascade::MakeLevel(slice0).SampleLevel(position), Cascade::MakeLevel(slice1).SampleLevel(position), alpha);
|
||||
#endif
|
||||
|
||||
_Crest_Target[id.xy] = m_DepthCheck ? m_Float2FromFloat2(position) : m_CrestUninitializedPosition;
|
||||
_Crest_Target[id.xy] = m_DepthCheck ? position : m_CrestUninitializedPosition;
|
||||
}
|
||||
|
||||
void Execute(const uint3 id)
|
||||
@@ -113,7 +111,7 @@ void Execute(const uint3 id)
|
||||
}
|
||||
}
|
||||
|
||||
_Crest_Target[id.xy] = m_Float2FromFloat2(nearest);
|
||||
_Crest_Target[id.xy] = nearest;
|
||||
}
|
||||
|
||||
void Apply(const uint3 id)
|
||||
@@ -146,7 +144,7 @@ void Apply(const uint3 id)
|
||||
|
||||
result.y = distance;
|
||||
|
||||
_Crest_Target[id.xy] = m_Float2FromFloat2(result);
|
||||
_Crest_Target[id.xy] = result;
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Adds height from a provided texture. Used by Painted and Texture input modes.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
|
||||
#pragma multi_compile_local __ d_CatmullRom
|
||||
@@ -29,7 +27,7 @@ float _Crest_Multiplier;
|
||||
float2 _Crest_TextureSize;
|
||||
float2 _Crest_TexturePosition;
|
||||
float2 _Crest_TextureRotation;
|
||||
float2 _Crest_TextureResolution;
|
||||
float2 _Crest_Resolution;
|
||||
CBUFFER_END
|
||||
|
||||
m_CrestNameSpace
|
||||
@@ -51,7 +49,7 @@ void Execute(uint3 id)
|
||||
}
|
||||
|
||||
#if d_CatmullRom
|
||||
const float source = Utility::SampleTextureCatmullRom(_Crest_Texture, LODData_linear_clamp_sampler, uv, _Crest_TextureResolution)
|
||||
const float source = Utility::SampleTextureCatmullRom(_Crest_Texture, LODData_linear_clamp_sampler, uv, _Crest_Resolution)
|
||||
#else
|
||||
const float source = _Crest_Texture.SampleLevel(LODData_linear_clamp_sampler, uv, 0.0)
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
@@ -14,7 +12,7 @@
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/InputsDriven.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Cascade.hlsl"
|
||||
|
||||
RWTexture2DArray<m_Float2> _Crest_Target;
|
||||
RWTexture2DArray<float2> _Crest_Target;
|
||||
|
||||
CBUFFER_START(CrestPerWaterInput)
|
||||
float3 _Crest_Position;
|
||||
@@ -118,7 +116,7 @@ void Execute(uint3 id)
|
||||
// Helps interaction to work at different scales
|
||||
acceleration /= minimumWavelength;
|
||||
|
||||
_Crest_Target[id] = m_Float2Constructor(_Crest_Target[id].x, _Crest_Target[id].y + acceleration * _Crest_SimDeltaTime);
|
||||
_Crest_Target[id] = float2(_Crest_Target[id].x, _Crest_Target[id].y + acceleration * _Crest_SimDeltaTime);
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestPackLevel
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestQueryDisplacement d_CrestDisplacement
|
||||
#pragma kernel CrestQueryFlow d_CrestFlow
|
||||
#pragma kernel CrestQueryDepth d_CrestDepth
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Merged into Query.compute.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
[numthreads(1, 1, 1)]
|
||||
void CrestExecute(uint3 id : SV_DispatchThreadID) { }
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Merged into Query.compute.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestExecute
|
||||
[numthreads(1, 1, 1)]
|
||||
void CrestExecute(uint3 id : SV_DispatchThreadID) { }
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
// Compute shader to perform combine of displacements. Reads and writes to texture array which saves
|
||||
// needing to do ping pong of render targets. Unfortunately reading/writing float4s is not supported
|
||||
// on pre-DX11.3 hardware (aka typed UAV loads), so this path is not the default, for now..
|
||||
|
||||
#pragma kernel CrestShapeCombineAnimatedWaves
|
||||
#pragma kernel CrestShapeCopyAnimatedWaves
|
||||
#pragma kernel CrestShapeCombineDynamicWaves d_CombineDynamicWaves
|
||||
|
||||
#pragma multi_compile_local _ d_Combine
|
||||
#pragma multi_compile_local _ d_DynamicWaves
|
||||
#pragma multi_compile_local _ d_Flow
|
||||
|
||||
#if d_CombineDynamicWaves
|
||||
#define d_DynamicWaves 1
|
||||
#endif
|
||||
#pragma kernel ShapeCombine
|
||||
#pragma kernel ShapeCombine_DISABLE_COMBINE _DISABLE_COMBINE
|
||||
#pragma kernel ShapeCombine_FLOW_ON _FLOW_ON
|
||||
#pragma kernel ShapeCombine_FLOW_ON_DISABLE_COMBINE _FLOW_ON _DISABLE_COMBINE
|
||||
#pragma kernel ShapeCombine_DYNAMIC_WAVE_SIM_ON _DYNAMIC_WAVE_SIM_ON
|
||||
#pragma kernel ShapeCombine_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE _DYNAMIC_WAVE_SIM_ON _DISABLE_COMBINE
|
||||
#pragma kernel ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON _FLOW_ON _DYNAMIC_WAVE_SIM_ON
|
||||
#pragma kernel ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE _FLOW_ON _DYNAMIC_WAVE_SIM_ON _DISABLE_COMBINE
|
||||
#pragma kernel ShapeCombineDynamicWaves
|
||||
#pragma kernel ShapeCombineDynamicWaves_DISABLE_COMBINE _DISABLE_COMBINE
|
||||
#pragma kernel ShapeCombineCopyDynamicWaves
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
@@ -28,10 +30,11 @@ float _Crest_DisplaceClamp;
|
||||
|
||||
Texture2DArray _Crest_WaveBuffer;
|
||||
RWTexture2DArray<float4> _Crest_Target;
|
||||
RWTexture2DArray<float4> _Crest_DynamicWavesTarget;
|
||||
RWTexture2DArray<float4> _Crest_AnimatedWavesTarget;
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
#if d_Flow
|
||||
void Flow(const float texel, out float2 offsets, out float2 weights)
|
||||
{
|
||||
const float period = max(3.0 * texel, 1.0);
|
||||
@@ -41,9 +44,7 @@ void Flow(const float texel, out float2 offsets, out float2 weights)
|
||||
if (weights.x > 1.0) weights.x = 2.0 - weights.x;
|
||||
weights.y = 1.0 - weights.x;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_Combine
|
||||
void SampleDisplacementsCompute(
|
||||
in RWTexture2DArray<float4> i_dispSampler,
|
||||
in float i_resolution, in float3 i_uv_slice,
|
||||
@@ -81,11 +82,10 @@ void SampleDisplacementsCompute(
|
||||
|
||||
io_worldPos += i_wt * dataLerped.xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ShapeCombine(uint3 id)
|
||||
void ShapeCombineBase(uint3 id)
|
||||
{
|
||||
const uint slice0 = id.z;
|
||||
const uint slice0 = _Crest_LodIndex;
|
||||
const Cascade cascade = Cascade::MakeAnimatedWaves(slice0);
|
||||
|
||||
const float3 uv = cascade.IDToUV(id.xy);
|
||||
@@ -93,25 +93,23 @@ void ShapeCombine(uint3 id)
|
||||
|
||||
float3 result = 0.0;
|
||||
|
||||
#if !d_CombineDynamicWaves
|
||||
// Sample in waves for this cascade.
|
||||
{
|
||||
#if d_Flow
|
||||
#if _FLOW_ON
|
||||
const half2 flow = Cascade::MakeFlow(slice0).SampleFlow(positionWSXZ);
|
||||
|
||||
float2 offsets, weights;
|
||||
Flow(cascade._Texel, offsets, weights);
|
||||
|
||||
result += cascade.SampleAnimatedWavesOverflow(_Crest_WaveBuffer, positionWSXZ - offsets.x * flow, 1.0).xyz * weights.x;
|
||||
result += cascade.SampleAnimatedWavesOverflow(_Crest_WaveBuffer, positionWSXZ - offsets.y * flow, 1.0).xyz * weights.y;
|
||||
result += cascade.Sample(_Crest_WaveBuffer, positionWSXZ - offsets[0] * flow).xyz * weights[0];
|
||||
result += cascade.Sample(_Crest_WaveBuffer, positionWSXZ - offsets[1] * flow).xyz * weights[1];
|
||||
#else
|
||||
result += _Crest_WaveBuffer[id].xyz;
|
||||
#endif
|
||||
result += cascade.Sample(_Crest_WaveBuffer, uv).xyz;
|
||||
#endif // _FLOW_ON
|
||||
}
|
||||
#endif
|
||||
|
||||
// Disabled for last LOD.
|
||||
#if d_Combine
|
||||
#if !_DISABLE_COMBINE
|
||||
{
|
||||
const Cascade cascade = Cascade::MakeAnimatedWaves(slice0 + 1);
|
||||
// Sample the shape 1 texture at this world position.
|
||||
@@ -121,37 +119,61 @@ void ShapeCombine(uint3 id)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_DynamicWaves
|
||||
#if _DYNAMIC_WAVE_SIM_ON
|
||||
{
|
||||
// Convert dynamic wave sim to displacements.
|
||||
result += Cascade::MakeDynamicWaves(slice0)
|
||||
.SampleDynamicWavesDisplacement(positionWSXZ, _Crest_HorizontalDisplace, _Crest_DisplaceClamp);
|
||||
}
|
||||
#endif
|
||||
#endif // _DYNAMIC_WAVE_SIM_ON
|
||||
|
||||
_Crest_Target[id] = float4(result, 0.0);
|
||||
}
|
||||
|
||||
void ShapeCombineAnimatedWaves(uint3 id)
|
||||
{
|
||||
id.z = _Crest_LodIndex;
|
||||
ShapeCombine(id);
|
||||
}
|
||||
|
||||
void ShapeCopyAnimatedWaves(uint3 id)
|
||||
{
|
||||
ShapeCombine(id);
|
||||
_Crest_Target[uint3(id.xy, slice0)] = float4(result, 0.0);
|
||||
}
|
||||
|
||||
void ShapeCombineDynamicWaves(uint3 id)
|
||||
{
|
||||
// We are combining from the target which matches the Animated Waves descriptor.
|
||||
id.z = _Crest_LodIndex;
|
||||
ShapeCombine(id);
|
||||
const uint slice0 = _Crest_LodIndex;
|
||||
const Cascade cascade = Cascade::MakeAnimatedWaves(slice0);
|
||||
const float3 uv = cascade.IDToUV(id.xy);
|
||||
const float2 positionWSXZ = cascade.UVToWorld(uv);
|
||||
float3 result = 0.0;
|
||||
|
||||
// Disabled for last LOD.
|
||||
#if !_DISABLE_COMBINE
|
||||
{
|
||||
// We are sampling from the target which matches Animated Waves descriptor.
|
||||
const Cascade cascade = Cascade::MakeAnimatedWaves(slice0 + 1);
|
||||
const float3 uv = cascade.WorldToUV(positionWSXZ);
|
||||
// Waves to combine down from the next lod up the chain.
|
||||
SampleDisplacementsCompute(_Crest_DynamicWavesTarget, cascade._Resolution, uv, 1.0, result);
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
// We are sampling from Dynamic Waves.
|
||||
const Cascade cascade = Cascade::MakeDynamicWaves(slice0);
|
||||
const float3 uv = cascade.WorldToUV(positionWSXZ);
|
||||
result += cascade.SampleDynamicWavesDisplacement(uv, _Crest_HorizontalDisplace, _Crest_DisplaceClamp);
|
||||
}
|
||||
|
||||
_Crest_DynamicWavesTarget[uint3(id.xy, slice0)] = float4(result, 0.0);
|
||||
}
|
||||
|
||||
void ShapeCombineCopyDynamicWaves(uint3 id)
|
||||
{
|
||||
_Crest_AnimatedWavesTarget[id] += _Crest_DynamicWavesTarget[id];
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
m_CrestKernelDefault(ShapeCombineAnimatedWaves)
|
||||
m_CrestKernelDefault(ShapeCopyAnimatedWaves)
|
||||
m_CrestKernelDefault(ShapeCombineDynamicWaves)
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombine(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineBase(id); }
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombine_DISABLE_COMBINE(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineBase(id); }
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombine_FLOW_ON(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineBase(id); }
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombine_FLOW_ON_DISABLE_COMBINE(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineBase(id); }
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombine_DYNAMIC_WAVE_SIM_ON(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineBase(id); }
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombine_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineBase(id); }
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineBase(id); }
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineBase(id); }
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombineDynamicWaves(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineDynamicWaves(id); }
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombineDynamicWaves_DISABLE_COMBINE(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineDynamicWaves(id); }
|
||||
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, 1)] void ShapeCombineCopyDynamicWaves(uint3 id : SV_DispatchThreadID) { m_Crest::ShapeCombineCopyDynamicWaves(id); }
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestShorelineColor
|
||||
|
||||
#pragma multi_compile_local __ d_Crest_ShorelineColorSource_ShorelineDistance
|
||||
|
||||
@@ -3,19 +3,16 @@
|
||||
|
||||
// Solves 2D wave equation
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestUpdateDynamicWaves
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Constants.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Globals.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/InputsDriven.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Cascade.hlsl"
|
||||
|
||||
RWTexture2DArray<m_Float2> _Crest_Target;
|
||||
RWTexture2DArray<float2> _Crest_Target;
|
||||
|
||||
CBUFFER_START(CrestPerMaterial)
|
||||
float _Crest_Damping;
|
||||
@@ -48,7 +45,7 @@ void UpdateDynamicWaves(uint3 id)
|
||||
if (sliceIndexSource < 0.0 || sliceIndexSource >= cascadeSource._Count)
|
||||
{
|
||||
// Always initialise with 0 values.
|
||||
_Crest_Target[id] = 0.0;
|
||||
_Crest_Target[id] = (float2)0;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,7 +72,7 @@ void UpdateDynamicWaves(uint3 id)
|
||||
// Wave reflections off geometry.
|
||||
if (waterDepth <= 0.0)
|
||||
{
|
||||
_Crest_Target[id] = 0.0;
|
||||
_Crest_Target[id] = float2(0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -145,7 +142,7 @@ void UpdateDynamicWaves(uint3 id)
|
||||
vtp = 0.0;
|
||||
}
|
||||
|
||||
_Crest_Target[id] = m_Float2Constructor(ftp, vtp);
|
||||
_Crest_Target[id] = float2(ftp, vtp);
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestUpdateFoam
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
@@ -55,16 +53,9 @@ void UpdateFoam(uint3 id)
|
||||
// accumulation of foam and causes overshoots when _Crest_WaveFoamStrength is less than 1.0.
|
||||
float simDeltaTime = _Crest_NeedsPrewarming ? max(_Crest_SimDeltaTime, min(1.0, _Crest_WaveFoamStrength - 1.0) / _Crest_FoamFadeRate) : _Crest_SimDeltaTime;
|
||||
|
||||
// Limit wave contributions at low water scales only where filtering is needed.
|
||||
uint filteredSlice = slice0;
|
||||
if (g_Crest_WaterScale <= 8)
|
||||
{
|
||||
filteredSlice = max(_Crest_MinimumWavesSlice, filteredSlice);
|
||||
}
|
||||
|
||||
// The determinant of the displacement Jacobian is a good measure for turbulence.
|
||||
float det;
|
||||
const half3 displacement = Cascade::MakeAnimatedWaves(filteredSlice).SampleDisplacement(worldPosXZ, det);
|
||||
const half3 displacement = Cascade::MakeAnimatedWaves(max(_Crest_MinimumWavesSlice, slice0)).SampleDisplacement(worldPosXZ, det);
|
||||
foam += 5.0 * simDeltaTime * _Crest_WaveFoamStrength * saturate( _Crest_WaveFoamCoverage - det );
|
||||
|
||||
// Prewarm shoreline foam. 1.0 / _Crest_FoamFadeRate perfectly matches a paused water in edit mode which is fine for
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Soft shadow term is red, hard shadow term is green.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestUpdateShadowsBRP _BRP
|
||||
#pragma kernel CrestUpdateShadowsHRP _HRP
|
||||
#pragma kernel CrestUpdateShadowsURP _URP
|
||||
@@ -35,7 +33,7 @@ bool _Crest_SampleColorMap;
|
||||
float3 _Crest_Absorption;
|
||||
float3 _Crest_Scattering;
|
||||
|
||||
RWTexture2DArray<m_Float2> _Crest_Target;
|
||||
RWTexture2DArray<float2> _Crest_Target;
|
||||
|
||||
|
||||
m_CrestNameSpace
|
||||
@@ -148,7 +146,7 @@ void UpdateShadows(const uint3 id)
|
||||
shadow = lerp(shadow, shadowThisFrame, _Crest_JitterDiameters_CurrentFrameWeights.zw * _Crest_SimDeltaTime * 60.0);
|
||||
}
|
||||
|
||||
_Crest_Target[id] = m_Float2FromFloat2(shadow);
|
||||
_Crest_Target[id] = shadow;
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
@@ -1,4 +1,176 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
// Replaced with UpdateShadow.compute.
|
||||
// Soft shadow term is red, hard shadow term is green. In HDRP, hard shadows are not computed and y channel will be 0.
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Constants.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Globals.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/InputsDriven.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Cascade.hlsl"
|
||||
// Noise functions used for jitter.
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Noise/Noise.hlsl"
|
||||
|
||||
CBUFFER_START(CrestPerMaterial)
|
||||
// Settings._jitterDiameterSoft, Settings._jitterDiameterHard, Settings._currentFrameWeightSoft, Settings._currentFrameWeightHard
|
||||
float4 _Crest_JitterDiameters_CurrentFrameWeights;
|
||||
float _Crest_SimDeltaTime;
|
||||
|
||||
bool _Crest_ClearShadows;
|
||||
|
||||
float3 _Crest_CenterPos;
|
||||
float3 _Crest_Scale;
|
||||
float4x4 _Crest_MainCameraProjectionMatrix;
|
||||
|
||||
bool _Crest_SampleColorMap;
|
||||
float3 _Crest_Absorption;
|
||||
float3 _Crest_Scattering;
|
||||
CBUFFER_END
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
uint id : SV_VertexID;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float3 positionWS : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings Vertex(Attributes input)
|
||||
{
|
||||
// This will work for all pipelines.
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
output.positionCS = GetFullScreenTriangleVertexPosition(input.id);
|
||||
float2 uv = GetFullScreenTriangleTexCoord(input.id);
|
||||
|
||||
// World position from UV.
|
||||
output.positionWS.xyz = float3(uv.x - 0.5, 0.0, uv.y - 0.5) * _Crest_Scale * 4.0 + _Crest_CenterPos;
|
||||
output.positionWS.y = g_Crest_WaterCenter.y;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
half SampleShadows(const float4 i_positionWS);
|
||||
half ComputeShadowFade(const float4 i_positionWS);
|
||||
|
||||
// Compiler shows warning when using intermediate returns, disable this.
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4000)
|
||||
half ComputeShadow(const float4 i_positionWS, const float i_jitterDiameter, const half i_terrainHeight)
|
||||
{
|
||||
float4 positionWS = i_positionWS;
|
||||
|
||||
if (i_jitterDiameter > 0.0)
|
||||
{
|
||||
// Add jitter.
|
||||
positionWS.xz += i_jitterDiameter * (hash33(uint3(abs(positionWS.xz * 10.0), _Time.y * 120.0)) - 0.5).xy;
|
||||
|
||||
// Shadow Bleeding.
|
||||
// If we are not within a terrain, then check for shadow bleeding.
|
||||
if (i_positionWS.y > i_terrainHeight)
|
||||
{
|
||||
// WorldToSafeUV
|
||||
half terrainHeight = Cascade::MakeDepth(_Crest_LodIndex).SampleSceneHeight(positionWS.xz);
|
||||
|
||||
// If our current position is below the jittered terrain height, then we have landed within a terrain and
|
||||
// we do not want to sample those shadows.
|
||||
if (i_positionWS.y < terrainHeight)
|
||||
{
|
||||
// Return no shadows.
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SampleShadows(positionWS);
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
half2 Fragment(Varyings input)
|
||||
{
|
||||
float4 positionWS = float4(input.positionWS.xyz, 1.0);
|
||||
|
||||
// Shadow from last frame. Manually implement black border.
|
||||
const float sliceIndexSource = clamp((int)_Crest_LodIndex + g_Crest_LodChange, 0.0, g_Crest_LodCount - 1.0);
|
||||
half2 shadow = Cascade::MakeShadowSource(sliceIndexSource).SampleShadowOverflow(positionWS.xz, 1.0);
|
||||
|
||||
// Add displacement so shorelines do not receive shadows incorrectly.
|
||||
positionWS.xyz += Cascade::MakeAnimatedWaves(_Crest_LodIndex).SampleDisplacement(positionWS.xz);
|
||||
|
||||
// This was calculated in vertex but we have to sample sea level offset in fragment.
|
||||
float4 mainCameraCoordinates = mul(_Crest_MainCameraProjectionMatrix, positionWS);
|
||||
|
||||
// Check if the current sample is visible in the main camera (and therefore the shadow map can be sampled). This is
|
||||
// required as the shadow buffer is world aligned and surrounds viewer.
|
||||
float3 projected = mainCameraCoordinates.xyz / mainCameraCoordinates.w;
|
||||
if (projected.z < 1.0 && projected.z > 0.0 && abs(projected.x) < 1.0 && abs(projected.y) < 1.0)
|
||||
{
|
||||
half2 shadowThisFrame = 1.0;
|
||||
|
||||
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
||||
positionWS.xyz -= _WorldSpaceCameraPos.xyz;
|
||||
#endif
|
||||
|
||||
half terrainHeight = Cascade::MakeDepth(_Crest_LodIndex).SampleSceneHeight(positionWS.xz);
|
||||
|
||||
half softJitter = _Crest_JitterDiameters_CurrentFrameWeights[CREST_SHADOW_INDEX_SOFT];
|
||||
|
||||
if (_Crest_SampleColorMap)
|
||||
{
|
||||
half3 absorption = _Crest_Absorption;
|
||||
half3 scattering = _Crest_Scattering;
|
||||
|
||||
if (g_Crest_SampleAbsorptionSimulation)
|
||||
{
|
||||
absorption = Cascade::MakeAbsorption(_Crest_LodIndex).SampleAbsorption(positionWS.xz);
|
||||
}
|
||||
|
||||
if (g_Crest_SampleScatteringSimulation)
|
||||
{
|
||||
scattering = Cascade::MakeScattering(_Crest_LodIndex).SampleScattering(positionWS.xz);
|
||||
}
|
||||
|
||||
half3 extinction = absorption + scattering;
|
||||
half factor = saturate(min(min(extinction.x, extinction.y), extinction.z) * g_Crest_DynamicSoftShadowsFactor);
|
||||
softJitter = (1.0 - factor) * k_Crest_MaximumShadowJitter;
|
||||
}
|
||||
|
||||
// Add soft shadowing data.
|
||||
shadowThisFrame[CREST_SHADOW_INDEX_SOFT] = ComputeShadow
|
||||
(
|
||||
positionWS,
|
||||
softJitter,
|
||||
terrainHeight
|
||||
);
|
||||
|
||||
#ifdef CREST_SAMPLE_SHADOW_HARD
|
||||
// Add hard shadowing data.
|
||||
shadowThisFrame[CREST_SHADOW_INDEX_HARD] = ComputeShadow
|
||||
(
|
||||
positionWS,
|
||||
_Crest_JitterDiameters_CurrentFrameWeights[CREST_SHADOW_INDEX_HARD],
|
||||
terrainHeight
|
||||
);
|
||||
#endif
|
||||
|
||||
shadowThisFrame = (half2)1.0 - saturate(shadowThisFrame + ComputeShadowFade(positionWS));
|
||||
|
||||
shadow = lerp(shadow, shadowThisFrame, _Crest_JitterDiameters_CurrentFrameWeights.zw * _Crest_SimDeltaTime * 60.0);
|
||||
}
|
||||
|
||||
return shadow;
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
m_CrestVertex
|
||||
m_CrestFragment(half2)
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
result._Texture = g_Crest_Cascade##name##source; \
|
||||
result._SamplingParameters = g_Crest_SamplingParametersCascade##name##source; \
|
||||
result._Index = i_Index; \
|
||||
result._IndexI = i_Index; \
|
||||
result._PositionSnapped = perSlice.xy; \
|
||||
result._Texel = perSlice.z; \
|
||||
result._Resolution = perType.y; \
|
||||
@@ -57,7 +56,6 @@
|
||||
result._Texture = i_Cascade._Texture; \
|
||||
result._SamplingParameters = i_Cascade._SamplingParameters; \
|
||||
result._Index = i_Index; \
|
||||
result._IndexI = i_Index; \
|
||||
result._PositionSnapped = perSlice.xy; \
|
||||
result._Texel = perSlice.z; \
|
||||
result._Resolution = perType.y; \
|
||||
@@ -72,7 +70,6 @@
|
||||
const float4 perAll = g_Crest_CascadeData##source[i_Index]; \
|
||||
Cascade result; \
|
||||
result._Index = i_Index; \
|
||||
result._IndexI = i_Index; \
|
||||
result._Scale = perAll.x; \
|
||||
result._Weight = perAll.y; \
|
||||
result._MaximumWavelength = perAll.z; \
|
||||
@@ -143,51 +140,6 @@
|
||||
} \
|
||||
} \
|
||||
return result; \
|
||||
} \
|
||||
half4 Sample##name##Overflow(const Texture2DArray i_Texture, const float2 i_Position, const float i_Border) m_ConstantReturn \
|
||||
{ \
|
||||
half4 result = 0.0; \
|
||||
const float3 uv = WorldToUV(i_Position); \
|
||||
const half2 r = abs(uv.xy - 0.5); \
|
||||
const half rMax = 0.5 - _OneOverResolution * i_Border; \
|
||||
if (max(r.x, r.y) <= rMax) \
|
||||
{ \
|
||||
result = Sample(i_Texture, uv); \
|
||||
} \
|
||||
else if ((_Index + 1) < _Count) \
|
||||
{ \
|
||||
const Cascade cascade = Cascade::Make##name(_Index + 1, this); \
|
||||
const float3 uv = cascade.WorldToUV(i_Position); \
|
||||
const half2 r = abs(uv.xy - 0.5); \
|
||||
const half rMax = 0.5 - cascade._OneOverResolution * i_Border; \
|
||||
if (max(r.x, r.y) <= rMax) \
|
||||
{ \
|
||||
result = Sample(i_Texture, uv); \
|
||||
} \
|
||||
} \
|
||||
return result; \
|
||||
} \
|
||||
half4 Sample##name##Overflow(const Texture2DArray i_Texture, const float3 i_UV, const float i_Border) m_ConstantReturn \
|
||||
{ \
|
||||
half4 result = 0.0; \
|
||||
const half2 r = abs(i_UV.xy - 0.5); \
|
||||
const half rMax = 0.5 - _OneOverResolution * i_Border; \
|
||||
if (max(r.x, r.y) <= rMax) \
|
||||
{ \
|
||||
result = Sample(i_Texture, i_UV); \
|
||||
} \
|
||||
else if ((_Index + 1) < _Count) \
|
||||
{ \
|
||||
const Cascade cascade = Cascade::Make##name(_Index + 1, this); \
|
||||
const float3 uv = cascade.WorldToUV(UVToWorld(i_UV)); \
|
||||
const half2 r = abs(uv.xy - 0.5); \
|
||||
const half rMax = 0.5 - cascade._OneOverResolution * i_Border; \
|
||||
if (max(r.x, r.y) <= rMax) \
|
||||
{ \
|
||||
result = Sample(i_Texture, uv); \
|
||||
} \
|
||||
} \
|
||||
return result; \
|
||||
}
|
||||
|
||||
#define m_SampleWeighted(name, type) \
|
||||
@@ -223,8 +175,6 @@ struct Cascade
|
||||
// For copy constructor.
|
||||
float4 _SamplingParameters[MAX_LOD_COUNT];
|
||||
|
||||
uint _IndexI;
|
||||
|
||||
m_MakeCascadeShared
|
||||
m_MakeCascadeSharedPrevious
|
||||
|
||||
@@ -233,7 +183,6 @@ struct Cascade
|
||||
const float4 perAll = i_Previous ? g_Crest_CascadeDataSource[i_Index] : g_Crest_CascadeData[i_Index];
|
||||
Cascade result;
|
||||
result._Index = i_Index;
|
||||
result._IndexI = i_Index;
|
||||
result._Scale = perAll.x;
|
||||
result._Weight = perAll.y;
|
||||
result._MaximumWavelength = perAll.z;
|
||||
@@ -283,12 +232,6 @@ struct Cascade
|
||||
return float3((i_Position - _PositionSnapped) / (_Texel * _Resolution) + 0.5, _Index);
|
||||
}
|
||||
|
||||
uint3 WorldToID(const float2 i_Position) m_ConstantReturn
|
||||
{
|
||||
const float3 uv = WorldToUV(i_Position);
|
||||
return uint3(uv.xy * _Resolution, _IndexI);
|
||||
}
|
||||
|
||||
float2 IDToWorld(const uint2 i_ID) m_ConstantReturn
|
||||
{
|
||||
return UVToWorld(IDToUV(i_ID));
|
||||
@@ -411,7 +354,6 @@ struct Cascade
|
||||
float4 position = SampleAnimatedWaves(uv);
|
||||
io_LevelOffset += position.w * i_Weight;
|
||||
io_Position += position.xyz * i_Weight;
|
||||
io_Position.y += position.w * i_Weight;
|
||||
|
||||
// Derivatives
|
||||
{
|
||||
@@ -514,13 +456,6 @@ struct Cascade
|
||||
return value;
|
||||
}
|
||||
|
||||
void SampleSignedDepthFromSeaLevelAndDistance(const float2 i_Position, const float i_Weight, inout half io_Depth, inout half io_Distance) m_ConstantReturn
|
||||
{
|
||||
const half2 value = SampleSignedDepthFromSeaLevelAndDistance(i_Position) * i_Weight;
|
||||
io_Depth += value.x;
|
||||
io_Distance += value.y;
|
||||
}
|
||||
|
||||
void SampleSignedDepthFromSeaLevel(const float2 i_Position, const float i_Weight, inout half io_Depth) m_ConstantReturn
|
||||
{
|
||||
io_Depth += (g_Crest_WaterCenter.y - SampleSceneHeight(i_Position)) * i_Weight;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings.Crest.hlsl"
|
||||
|
||||
SamplerState LODData_linear_clamp_sampler;
|
||||
SamplerState sampler_Crest_point_clamp;
|
||||
SamplerState LODData_point_clamp_sampler;
|
||||
SamplerState sampler_Crest_linear_repeat;
|
||||
|
||||
SamplerState _Crest_linear_clamp_sampler;
|
||||
@@ -25,11 +25,6 @@ float g_Crest_ClipByDefault;
|
||||
float g_Crest_LodAlphaBlackPointFade;
|
||||
float g_Crest_LodAlphaBlackPointWhitePointFade;
|
||||
|
||||
// Refraction
|
||||
float g_Crest_WaterDepthAtViewer;
|
||||
float g_Crest_MaximumVerticalDisplacement;
|
||||
float2 g_Crest_HorizonNormal;
|
||||
|
||||
// Hack - due to SV_IsFrontFace occasionally coming through as true for
|
||||
// backfaces, add a param here that forces water to be in undrwater state. I
|
||||
// think the root cause here might be imprecision or numerical issues at water
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#ifndef d_WaveHarmonic_Crest_Keywords
|
||||
#define d_WaveHarmonic_Crest_Keywords
|
||||
|
||||
#define d_Crest_AlbedoLod CREST_ALBEDO_SIMULATION
|
||||
#define d_Crest_FlowLod defined(_CREST_FLOW_LOD)
|
||||
#define d_Crest_ShadowLod CREST_SHADOW_SIMULATION
|
||||
#define d_Crest_AbsorptionLod CREST_ABSORPTION_SIMULATION
|
||||
#define d_Crest_ScatteringLod CREST_SCATTERING_SIMULATION
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e2c3338345cc4cc79fac0ec9b65a4f2
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -13,22 +13,6 @@
|
||||
|
||||
#define m_FloatMaximum 3.402823466e+38
|
||||
|
||||
|
||||
//
|
||||
// Fallback for WebGPU
|
||||
//
|
||||
|
||||
#ifdef SHADER_API_WEBGPU
|
||||
#define m_Float2 float4
|
||||
#define m_Float2Constructor(x, y) float4(x, y, 0.0, 0.0)
|
||||
#define m_Float2FromFloat2(p0) float4(p0.x, p0.y, 0, 0)
|
||||
#else
|
||||
#define m_Float2 float2
|
||||
#define m_Float2Constructor(x, y) float2(x, y)
|
||||
#define m_Float2FromFloat2(p0) p0
|
||||
#endif
|
||||
|
||||
|
||||
#if (CREST_FULL_PRECISION_DISPLACEMENT != 0)
|
||||
#define m_DisplacementTexture(texture, components) texture<float##components>
|
||||
#else
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
//
|
||||
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
|
||||
//
|
||||
|
||||
#ifndef d_WaveHarmonic_Crest_Settings
|
||||
#define d_WaveHarmonic_Crest_Settings
|
||||
#ifndef SETTINGS_CREST_HLSL
|
||||
#define SETTINGS_CREST_HLSL
|
||||
//
|
||||
// WaveHarmonic.Crest.Editor.ShaderSettings: static fields
|
||||
//
|
||||
#define CREST_PACKAGE_HDRP (1)
|
||||
#define CREST_PACKAGE_URP (1)
|
||||
#define CREST_PORTALS (0)
|
||||
#define CREST_SHIFTING_ORIGIN (0)
|
||||
#define CREST_FULL_PRECISION_DISPLACEMENT (1)
|
||||
#define CREST_DISCARD_ATMOSPHERIC_SCATTERING (1)
|
||||
#define CREST_LEGACY_UNDERWATER (0)
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings/Settings.Crest.hlsl"
|
||||
|
||||
#if CREST_PLATFORM_STANDALONE
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings/Settings.Crest.Standalone.hlsl"
|
||||
#elif CREST_PLATFORM_SERVER
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings/Settings.Crest.Server.hlsl"
|
||||
#elif CREST_PLATFORM_ANDROID
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings/Settings.Crest.Android.hlsl"
|
||||
#elif CREST_PLATFORM_IOS
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings/Settings.Crest.iOS.hlsl"
|
||||
#elif CREST_PLATFORM_WEB
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings/Settings.Crest.Web.hlsl"
|
||||
#elif CREST_PLATFORM_TVOS
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings/Settings.Crest.tvOS.hlsl"
|
||||
#elif CREST_PLATFORM_VISIONOS
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings/Settings.Crest.visionOS.hlsl"
|
||||
#else
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings/Settings.Crest.Default.hlsl"
|
||||
#endif
|
||||
|
||||
#endif // d_WaveHarmonic_Crest_Settings
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb30ad2b71bed4acca040c6ce2900f37
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
|
||||
//
|
||||
|
||||
#ifndef SETTINGS_CREST_ANDROID_HLSL
|
||||
#define SETTINGS_CREST_ANDROID_HLSL
|
||||
//
|
||||
// WaveHarmonic.Crest.Editor.ShaderSettingsAndroid: static fields
|
||||
//
|
||||
#define CREST_ALBEDO_SIMULATION (1)
|
||||
#define CREST_ABSORPTION_SIMULATION (1)
|
||||
#define CREST_SCATTERING_SIMULATION (1)
|
||||
#define CREST_SHADOW_SIMULATION (1)
|
||||
#define CREST_CAUSTICS_FORCE_DISTORTION (1)
|
||||
#define CREST_FOAM_BIOLUMINESCENCE (1)
|
||||
#define CREST_NORMAL_MAPS (1)
|
||||
#define CREST_SIMPLE_TRANSPARENCY (0)
|
||||
#define CREST_PLANAR_REFLECTIONS (1)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 307613c3b5e1c4f7da556862bfea5712
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
|
||||
//
|
||||
|
||||
#ifndef SETTINGS_CREST_DEFAULT_HLSL
|
||||
#define SETTINGS_CREST_DEFAULT_HLSL
|
||||
//
|
||||
// WaveHarmonic.Crest.Editor.ShaderSettingsDefault: static fields
|
||||
//
|
||||
#define CREST_ALBEDO_SIMULATION (1)
|
||||
#define CREST_ABSORPTION_SIMULATION (1)
|
||||
#define CREST_SCATTERING_SIMULATION (1)
|
||||
#define CREST_SHADOW_SIMULATION (1)
|
||||
#define CREST_CAUSTICS_FORCE_DISTORTION (1)
|
||||
#define CREST_FOAM_BIOLUMINESCENCE (1)
|
||||
#define CREST_NORMAL_MAPS (1)
|
||||
#define CREST_SIMPLE_TRANSPARENCY (0)
|
||||
#define CREST_PLANAR_REFLECTIONS (1)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b6abac1d09714922b174070c93c9054
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
|
||||
//
|
||||
|
||||
#ifndef SETTINGS_CREST_SERVER_HLSL
|
||||
#define SETTINGS_CREST_SERVER_HLSL
|
||||
//
|
||||
// WaveHarmonic.Crest.Editor.ShaderSettingsServer: static fields
|
||||
//
|
||||
#define CREST_ALBEDO_SIMULATION (1)
|
||||
#define CREST_ABSORPTION_SIMULATION (1)
|
||||
#define CREST_SCATTERING_SIMULATION (1)
|
||||
#define CREST_SHADOW_SIMULATION (1)
|
||||
#define CREST_CAUSTICS_FORCE_DISTORTION (1)
|
||||
#define CREST_FOAM_BIOLUMINESCENCE (1)
|
||||
#define CREST_NORMAL_MAPS (1)
|
||||
#define CREST_SIMPLE_TRANSPARENCY (0)
|
||||
#define CREST_PLANAR_REFLECTIONS (1)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15a7369ec789c4ae08ac764eab29463e
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
|
||||
//
|
||||
|
||||
#ifndef SETTINGS_CREST_STANDALONE_HLSL
|
||||
#define SETTINGS_CREST_STANDALONE_HLSL
|
||||
//
|
||||
// WaveHarmonic.Crest.Editor.ShaderSettingsStandalone: static fields
|
||||
//
|
||||
#define CREST_ALBEDO_SIMULATION (1)
|
||||
#define CREST_ABSORPTION_SIMULATION (1)
|
||||
#define CREST_SCATTERING_SIMULATION (1)
|
||||
#define CREST_SHADOW_SIMULATION (1)
|
||||
#define CREST_CAUSTICS_FORCE_DISTORTION (1)
|
||||
#define CREST_FOAM_BIOLUMINESCENCE (1)
|
||||
#define CREST_NORMAL_MAPS (1)
|
||||
#define CREST_SIMPLE_TRANSPARENCY (0)
|
||||
#define CREST_PLANAR_REFLECTIONS (1)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9f563484a71c4e04a3aefcbef8ce36a
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
|
||||
//
|
||||
|
||||
#ifndef SETTINGS_CREST_WEB_HLSL
|
||||
#define SETTINGS_CREST_WEB_HLSL
|
||||
//
|
||||
// WaveHarmonic.Crest.Editor.ShaderSettingsWeb: static fields
|
||||
//
|
||||
#define CREST_ALBEDO_SIMULATION (0)
|
||||
#define CREST_ABSORPTION_SIMULATION (0)
|
||||
#define CREST_SCATTERING_SIMULATION (0)
|
||||
#define CREST_SHADOW_SIMULATION (0)
|
||||
#define CREST_CAUSTICS_FORCE_DISTORTION (0)
|
||||
#define CREST_FOAM_BIOLUMINESCENCE (0)
|
||||
#define CREST_NORMAL_MAPS (1)
|
||||
#define CREST_SIMPLE_TRANSPARENCY (0)
|
||||
#define CREST_PLANAR_REFLECTIONS (0)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0eecd007d82c74bf88658c84586cda62
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,26 +0,0 @@
|
||||
//
|
||||
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
|
||||
//
|
||||
|
||||
#ifndef SETTINGS_CREST_HLSL
|
||||
#define SETTINGS_CREST_HLSL
|
||||
//
|
||||
// WaveHarmonic.Crest.Editor.ShaderSettings: static fields
|
||||
//
|
||||
#define CREST_PACKAGE_HDRP (1)
|
||||
#define CREST_PACKAGE_URP (1)
|
||||
#define CREST_PORTALS (0)
|
||||
#define CREST_SHIFTING_ORIGIN (0)
|
||||
#define CREST_PLATFORM_STANDALONE (1)
|
||||
#define CREST_PLATFORM_SERVER (0)
|
||||
#define CREST_PLATFORM_ANDROID (0)
|
||||
#define CREST_PLATFORM_IOS (0)
|
||||
#define CREST_PLATFORM_WEB (0)
|
||||
#define CREST_PLATFORM_TVOS (0)
|
||||
#define CREST_PLATFORM_VISIONOS (0)
|
||||
#define CREST_FULL_PRECISION_DISPLACEMENT (1)
|
||||
#define CREST_DISCARD_ATMOSPHERIC_SCATTERING (1)
|
||||
#define CREST_LEGACY_UNDERWATER (0)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b25f99570a3c543dca0d91bc54a4e27e
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
|
||||
//
|
||||
|
||||
#ifndef SETTINGS_CREST_IOS_HLSL
|
||||
#define SETTINGS_CREST_IOS_HLSL
|
||||
//
|
||||
// WaveHarmonic.Crest.Editor.ShaderSettingsIOS: static fields
|
||||
//
|
||||
#define CREST_ALBEDO_SIMULATION (1)
|
||||
#define CREST_ABSORPTION_SIMULATION (1)
|
||||
#define CREST_SCATTERING_SIMULATION (1)
|
||||
#define CREST_SHADOW_SIMULATION (1)
|
||||
#define CREST_CAUSTICS_FORCE_DISTORTION (1)
|
||||
#define CREST_FOAM_BIOLUMINESCENCE (1)
|
||||
#define CREST_NORMAL_MAPS (1)
|
||||
#define CREST_SIMPLE_TRANSPARENCY (0)
|
||||
#define CREST_PLANAR_REFLECTIONS (1)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d8991669495c4da8b6d2d9c62dadcb1
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
|
||||
//
|
||||
|
||||
#ifndef SETTINGS_CREST_TVOS_HLSL
|
||||
#define SETTINGS_CREST_TVOS_HLSL
|
||||
//
|
||||
// WaveHarmonic.Crest.Editor.ShaderSettingsTVOS: static fields
|
||||
//
|
||||
#define CREST_ALBEDO_SIMULATION (1)
|
||||
#define CREST_ABSORPTION_SIMULATION (1)
|
||||
#define CREST_SCATTERING_SIMULATION (1)
|
||||
#define CREST_SHADOW_SIMULATION (1)
|
||||
#define CREST_CAUSTICS_FORCE_DISTORTION (1)
|
||||
#define CREST_FOAM_BIOLUMINESCENCE (1)
|
||||
#define CREST_NORMAL_MAPS (1)
|
||||
#define CREST_SIMPLE_TRANSPARENCY (0)
|
||||
#define CREST_PLANAR_REFLECTIONS (1)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bff51ef931a4443a7b6c1a2fc2b88772
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead
|
||||
//
|
||||
|
||||
#ifndef SETTINGS_CREST_VISIONOS_HLSL
|
||||
#define SETTINGS_CREST_VISIONOS_HLSL
|
||||
//
|
||||
// WaveHarmonic.Crest.Editor.ShaderSettingsVisionOS: static fields
|
||||
//
|
||||
#define CREST_ALBEDO_SIMULATION (1)
|
||||
#define CREST_ABSORPTION_SIMULATION (1)
|
||||
#define CREST_SCATTERING_SIMULATION (1)
|
||||
#define CREST_SHADOW_SIMULATION (1)
|
||||
#define CREST_CAUSTICS_FORCE_DISTORTION (1)
|
||||
#define CREST_FOAM_BIOLUMINESCENCE (1)
|
||||
#define CREST_NORMAL_MAPS (1)
|
||||
#define CREST_SIMPLE_TRANSPARENCY (0)
|
||||
#define CREST_PLANAR_REFLECTIONS (1)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0648a06882284ebc88f4b28f3c6f825
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -66,67 +66,6 @@ float4 SampleTextureCatmullRom(in Texture2D<float4> tex, in SamplerState linearS
|
||||
return result;
|
||||
}
|
||||
|
||||
float4 CubicWeights(const float f)
|
||||
{
|
||||
const float f2 = f * f;
|
||||
const float f3 = f2 * f;
|
||||
|
||||
// Catmull–Rom (a = -0.5)
|
||||
return float4
|
||||
(
|
||||
-0.5 * f3 + f2 - 0.5 * f,
|
||||
1.5 * f3 - 2.5 * f2 + 1.0,
|
||||
-1.5 * f3 + 2.0 * f2 + 0.5 * f,
|
||||
0.5 * f3 - 0.5 * f2
|
||||
);
|
||||
}
|
||||
|
||||
float4 SampleBicubicRepeat
|
||||
(
|
||||
const Texture2DArray<float4> i_Texture,
|
||||
const float2 i_UV,
|
||||
const uint2 i_Size,
|
||||
const uint i_Slice
|
||||
)
|
||||
{
|
||||
// Convert to texel space (centered at pixel centers).
|
||||
const float2 samplePosition = i_UV * (float2)i_Size - 0.5;
|
||||
const int2 texelPosition = (int2)floor(samplePosition);
|
||||
const float2 f = samplePosition - (float2)texelPosition;
|
||||
|
||||
// Precompute weights.
|
||||
const float4 wx = CubicWeights(f.x);
|
||||
const float4 wy = CubicWeights(f.y);
|
||||
|
||||
const uint2 size = i_Size - 1;
|
||||
|
||||
const uint4 x = uint4
|
||||
(
|
||||
(texelPosition.x - 1) & size.x,
|
||||
(texelPosition.x + 0) & size.x,
|
||||
(texelPosition.x + 1) & size.x,
|
||||
(texelPosition.x + 2) & size.x
|
||||
);
|
||||
|
||||
// Horizontal pass.
|
||||
float4 row[4];
|
||||
[unroll]
|
||||
for (int j = -1; j <= 2; ++j)
|
||||
{
|
||||
const int y = (texelPosition.y + j) & size.y;
|
||||
|
||||
const float4 t0 = i_Texture[uint3(x.x, y, i_Slice)];
|
||||
const float4 t1 = i_Texture[uint3(x.y, y, i_Slice)];
|
||||
const float4 t2 = i_Texture[uint3(x.z, y, i_Slice)];
|
||||
const float4 t3 = i_Texture[uint3(x.w, y, i_Slice)];
|
||||
|
||||
row[j + 1] = t0 * wx.x + t1 * wx.y + t2 * wx.z + t3 * wx.w;
|
||||
}
|
||||
|
||||
// Vertical pass.
|
||||
return row[0] * wy.x + row[1] * wy.y + row[2] * wy.z + row[3] * wy.w;
|
||||
}
|
||||
|
||||
m_UtilityNameSpaceEnd
|
||||
|
||||
#endif // d_WaveHarmonic_Utility_Filtering
|
||||
|
||||
@@ -43,16 +43,6 @@ float2 WorldNormalToScreenDirection(const float3 i_PositionWS, const float3 i_No
|
||||
return direction;
|
||||
}
|
||||
|
||||
float3 SafeComputeWorldSpacePosition(float2 positionNDC, float deviceDepth, float4x4 invViewProjMatrix)
|
||||
{
|
||||
float4 positionCS = ComputeClipSpacePosition(positionNDC, deviceDepth);
|
||||
float4 hpositionWS = mul(invViewProjMatrix, positionCS);
|
||||
|
||||
// w is sometimes zero when using oblique projection.
|
||||
// Zero is better than NaN.
|
||||
return hpositionWS.w > 0.0 ? hpositionWS.xyz / hpositionWS.w : 0.0;
|
||||
}
|
||||
|
||||
m_UtilityNameSpaceEnd
|
||||
|
||||
#endif // d_WaveHarmonic_Utility_Helpers
|
||||
|
||||
@@ -86,9 +86,6 @@
|
||||
// Transparent Objects Receives Shadows
|
||||
//
|
||||
|
||||
// WebGPU does not like the binding.
|
||||
#ifndef SHADER_API_WEBGPU
|
||||
|
||||
#if _SURFACE_TYPE_TRANSPARENT
|
||||
#if _TRANSPARENT_RECEIVES_SHADOWS
|
||||
#if SHADERPASS == SHADERPASS_FORWARD || SHADERPASS == SHADERPASS_FORWARD_ADD
|
||||
@@ -111,6 +108,4 @@ float4 _ShadowMapTexture_TexelSize;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // SHADER_API_WEBGPU
|
||||
|
||||
#endif // d_WaveHarmonic_Utility_ShaderGraphDefines
|
||||
|
||||
@@ -21,6 +21,24 @@
|
||||
#define CLUSTER_LIGHT_LOOP_SUBTRACTIVE_LIGHT_CHECK FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
|
||||
#endif // FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
|
||||
|
||||
#if UNITY_VERSION >= 60000000
|
||||
#if defined(STEREO_INSTANCING_ON) || defined(STEREO_MULTIVIEW_ON)
|
||||
#if _ALPHATEST_ON
|
||||
#if !USE_CLUSTER_LIGHT_LOOP
|
||||
// If not clustered and additional light shadows and XR, the shading model
|
||||
// completely breaks. It is like shadow attenuation is NaN or some obscure
|
||||
// compiler issue. For 2022.3, it is broken for forward+ only, but cannot be fixed.
|
||||
#define d_ShadowMaskBroken 1
|
||||
#else
|
||||
#if _RECEIVE_SHADOWS_OFF
|
||||
// Right eye broken rendering similar to above.
|
||||
#define d_AdditionalLightsBroken 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // CREST_URP
|
||||
|
||||
#if CREST_HDRP
|
||||
@@ -60,10 +78,7 @@ void PrimaryLight
|
||||
#elif CREST_BIRP
|
||||
#ifndef USING_DIRECTIONAL_LIGHT
|
||||
// Yes. This function wants the world position of the surface.
|
||||
o_Direction = UnityWorldSpaceLightDir(i_PositionWS);
|
||||
// Prevents divide by zero.
|
||||
if (all(o_Direction == 0)) o_Direction = half3(0.0, 1.0, 0.0);
|
||||
o_Direction = normalize(o_Direction);
|
||||
o_Direction = normalize(UnityWorldSpaceLightDir(i_PositionWS));
|
||||
#else
|
||||
o_Direction = _WorldSpaceLightPos0.xyz;
|
||||
// Prevents divide by zero.
|
||||
@@ -138,6 +153,14 @@ LIGHT_LOOP_BEGIN(pixelLightCount)
|
||||
// Includes shadows and cookies.
|
||||
Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
|
||||
|
||||
#if d_ShadowMaskBroken
|
||||
light.shadowAttenuation = 1.0;
|
||||
#endif
|
||||
|
||||
#if d_AdditionalLightsBroken
|
||||
light.color = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Depth.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Globals.hlsl"
|
||||
|
||||
float2 _Crest_HorizonNormal;
|
||||
|
||||
TEXTURE2D_X(_Crest_WaterMaskTexture);
|
||||
|
||||
m_CrestNameSpace
|
||||
@@ -43,7 +45,7 @@ half4 Fragment(Varyings input)
|
||||
|
||||
const uint2 positionSS = input.positionCS.xy;
|
||||
const float mask = LOAD_TEXTURE2D_X(_Crest_WaterMaskTexture, positionSS).x;
|
||||
const float2 offset = -((float2)mask) * g_Crest_HorizonNormal;
|
||||
const float2 offset = -((float2)mask) * _Crest_HorizonNormal;
|
||||
float weight = 1.0;
|
||||
|
||||
// Sample three pixels along the normal. If the sample is different than the
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Depth.hlsl"
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Shim.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Keywords.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Lighting.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/VolumeLighting.hlsl"
|
||||
|
||||
@@ -41,8 +40,6 @@ int _Crest_DataSliceOffset;
|
||||
half _Crest_Radius;
|
||||
half _Crest_RefractionStrength;
|
||||
|
||||
bool _Crest_PortalInverted;
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
struct Attributes
|
||||
@@ -90,7 +87,7 @@ half4 Fragment(Varyings input)
|
||||
|
||||
#if d_Masked
|
||||
// Prevent rendering inside of new portal modules.
|
||||
if ((LOAD_TEXTURE2D_X(_Crest_WaterMaskTexture, input.positionCS.xy).r == k_Crest_MaskInsidePortal) == _Crest_PortalInverted)
|
||||
if (LOAD_TEXTURE2D_X(_Crest_WaterMaskTexture, input.positionCS.xy).r == k_Crest_MaskInsidePortal)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,6 @@ half3 Caustics
|
||||
);
|
||||
}
|
||||
|
||||
#if d_Crest_CausticsForceDistortion
|
||||
if (i_Underwater)
|
||||
{
|
||||
float2 surfacePosXZ = i_ScenePositionWS.xz;
|
||||
@@ -94,7 +93,6 @@ half3 Caustics
|
||||
cuv1.xy += 1.30 * causticN;
|
||||
cuv2.xy += 1.77 * causticN;
|
||||
}
|
||||
#endif
|
||||
|
||||
half causticsStrength = i_Strength;
|
||||
|
||||
|
||||
@@ -12,43 +12,28 @@ TEXTURE2D_FLOAT(_Crest_WaterLine);
|
||||
float _Crest_WaterLineTexel;
|
||||
float2 _Crest_WaterLineResolution;
|
||||
float2 _Crest_WaterLineSnappedPosition;
|
||||
bool _Crest_WaterLineFlatWater;
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
float SampleWaterLineHeight(const float2 i_PositionWS)
|
||||
{
|
||||
if (_Crest_WaterLineFlatWater)
|
||||
{
|
||||
return g_Crest_WaterCenter.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
const float2 uv = (i_PositionWS - _Crest_WaterLineSnappedPosition) / (_Crest_WaterLineTexel * _Crest_WaterLineResolution) + 0.5;
|
||||
return _Crest_WaterLine.SampleLevel(_Crest_linear_clamp_sampler, uv, 0).r + g_Crest_WaterCenter.y;
|
||||
}
|
||||
const float2 uv = (i_PositionWS - _Crest_WaterLineSnappedPosition) / (_Crest_WaterLineTexel * _Crest_WaterLineResolution) + 0.5;
|
||||
return _Crest_WaterLine.SampleLevel(_Crest_linear_clamp_sampler, uv, 0).r + g_Crest_WaterCenter.y;
|
||||
}
|
||||
|
||||
half3 SampleWaterLineNormal(const float2 i_PositionWS, const float i_Height)
|
||||
{
|
||||
if (_Crest_WaterLineFlatWater)
|
||||
{
|
||||
return half3(0, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const float2 uv = (i_PositionWS - _Crest_WaterLineSnappedPosition) / (_Crest_WaterLineTexel * _Crest_WaterLineResolution) + 0.5;
|
||||
const float3 dd = float3(1.0 / _Crest_WaterLineResolution.xy, 0.0);
|
||||
const float xOffset = _Crest_WaterLine.SampleLevel(_Crest_linear_clamp_sampler, uv + dd.xz, 0).r;
|
||||
const float zOffset = _Crest_WaterLine.SampleLevel(_Crest_linear_clamp_sampler, uv + dd.zy, 0).r;
|
||||
const float2 uv = (i_PositionWS - _Crest_WaterLineSnappedPosition) / (_Crest_WaterLineTexel * _Crest_WaterLineResolution) + 0.5;
|
||||
const float3 dd = float3(1.0 / _Crest_WaterLineResolution.xy, 0.0);
|
||||
const float xOffset = _Crest_WaterLine.SampleLevel(_Crest_linear_clamp_sampler, uv + dd.xz, 0).r;
|
||||
const float zOffset = _Crest_WaterLine.SampleLevel(_Crest_linear_clamp_sampler, uv + dd.zy, 0).r;
|
||||
|
||||
return normalize(half3
|
||||
(
|
||||
(xOffset - i_Height) / _Crest_WaterLineTexel,
|
||||
1.0,
|
||||
(zOffset - i_Height) / _Crest_WaterLineTexel
|
||||
));
|
||||
}
|
||||
return normalize(half3
|
||||
(
|
||||
(xOffset - i_Height) / _Crest_WaterLineTexel,
|
||||
1.0,
|
||||
(zOffset - i_Height) / _Crest_WaterLineTexel
|
||||
));
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#ifndef d_WaveHarmonic_Crest_Surface_Emission
|
||||
#define d_WaveHarmonic_Crest_Surface_Emission
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
half3 FoamBioluminescence
|
||||
(
|
||||
const half i_FoamData,
|
||||
const half i_FoamMap,
|
||||
const half3 i_BioluminescenceColor,
|
||||
const half i_BioluminescenceIntensity,
|
||||
const half i_BioluminescenceGlowCoverage,
|
||||
const half i_BioluminescenceGlowIntensity,
|
||||
const bool i_BioluminescenceSparklesEnabled,
|
||||
const half i_BioluminescenceSparklesMap,
|
||||
const half i_BioluminescenceSparklesCoverage,
|
||||
const half i_BioluminescenceSparklesIntensity,
|
||||
const half i_BioluminescenceMaximumDepth,
|
||||
const half i_WaterDepth
|
||||
)
|
||||
{
|
||||
half3 emission = 0.0;
|
||||
|
||||
const half weight = 1.0 - saturate(i_WaterDepth / i_BioluminescenceMaximumDepth);
|
||||
|
||||
if (weight <= 0.0)
|
||||
{
|
||||
return emission;
|
||||
}
|
||||
|
||||
emission +=
|
||||
(i_BioluminescenceColor * i_FoamMap * i_BioluminescenceIntensity) +
|
||||
(i_BioluminescenceColor * saturate(i_FoamData - (1.0 - i_BioluminescenceGlowCoverage)) * i_BioluminescenceGlowIntensity);
|
||||
|
||||
if (i_BioluminescenceSparklesEnabled)
|
||||
{
|
||||
emission += (i_BioluminescenceColor * i_BioluminescenceSparklesMap * saturate(i_FoamData - (1.0 - i_BioluminescenceSparklesCoverage)) * i_BioluminescenceSparklesIntensity);
|
||||
}
|
||||
|
||||
emission *= weight;
|
||||
|
||||
return emission;
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
#endif // d_WaveHarmonic_Crest_Surface_Emission
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4707eb239a4b242d4ac074ac67b5544e
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
half2 WhiteFoamTexture
|
||||
half WhiteFoamTexture
|
||||
(
|
||||
const TiledTexture i_Texture,
|
||||
const half i_Foam,
|
||||
@@ -25,8 +25,7 @@ half2 WhiteFoamTexture
|
||||
const float2 i_WorldXZ1,
|
||||
const float2 i_TexelOffset,
|
||||
const half i_LodAlpha,
|
||||
const Cascade i_CascadeData0,
|
||||
const bool i_Sample2ndChannel = false
|
||||
const Cascade i_CascadeData0
|
||||
)
|
||||
{
|
||||
const float2 uvOffset = i_TexelOffset + g_Crest_Time * i_Texture._speed / 32.0;
|
||||
@@ -34,32 +33,19 @@ half2 WhiteFoamTexture
|
||||
// material 'scale' slider into an intuitive range.
|
||||
const float scale = i_Texture._scale * i_CascadeData0._Scale / 10.0;
|
||||
|
||||
const half2 f0 = i_Texture.Sample((i_WorldXZ0 + uvOffset) / scale).rg;
|
||||
const half2 f1 = i_Texture.Sample((i_WorldXZ1 + uvOffset) / (2.0 * scale)).rg;
|
||||
|
||||
const half fr = lerp(f0.r, f1.r, i_LodAlpha);
|
||||
half ft = lerp
|
||||
(
|
||||
i_Texture.Sample((i_WorldXZ0 + uvOffset) / scale).r,
|
||||
i_Texture.Sample((i_WorldXZ1 + uvOffset) / (2.0 * scale)).r,
|
||||
i_LodAlpha
|
||||
);
|
||||
|
||||
// Black point fade.
|
||||
const half result = saturate(1.0 - i_Foam);
|
||||
|
||||
#if d_Crest_FoamBioluminescence
|
||||
if (i_Sample2ndChannel)
|
||||
{
|
||||
// Helps with exaggerating at LOD borders. Very specific to sparkles as they do not
|
||||
// overlap leaving a dead zone in the middle.
|
||||
const half fg = f0.g * min(0.5, 1.0 - i_LodAlpha) * 2.0 +
|
||||
f1.g * min(0.5, i_LodAlpha) * 2.0;
|
||||
|
||||
return smoothstep(result, result + i_Feather, half2(fr, fg));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return half2(smoothstep(result, result + i_Feather, fr), 0.0);
|
||||
}
|
||||
half result = saturate(1.0 - i_Foam);
|
||||
return smoothstep(result, result + i_Feather, ft);
|
||||
}
|
||||
|
||||
half2 MultiScaleFoamAlbedo
|
||||
half MultiScaleFoamAlbedo
|
||||
(
|
||||
const TiledTexture i_Texture,
|
||||
const half i_Feather,
|
||||
@@ -67,8 +53,7 @@ half2 MultiScaleFoamAlbedo
|
||||
const Cascade i_CascadeData0,
|
||||
const Cascade i_CascadeData1,
|
||||
const half i_LodAlpha,
|
||||
const float2 i_UndisplacedXZ,
|
||||
const bool i_Sample2ndChannel
|
||||
const float2 i_UndisplacedXZ
|
||||
)
|
||||
{
|
||||
float2 worldXZ0 = i_UndisplacedXZ;
|
||||
@@ -82,7 +67,7 @@ half2 MultiScaleFoamAlbedo
|
||||
worldXZ1 -= ShiftingOriginOffset(i_Texture, i_CascadeData1);
|
||||
#endif // CREST_SHIFTING_ORIGIN
|
||||
|
||||
return WhiteFoamTexture(i_Texture, i_FoamData, i_Feather, worldXZ0, worldXZ1, (float2)0.0, i_LodAlpha, i_CascadeData0, i_Sample2ndChannel);
|
||||
return WhiteFoamTexture(i_Texture, i_FoamData, i_Feather, worldXZ0, worldXZ1, (float2)0.0, i_LodAlpha, i_CascadeData0);
|
||||
}
|
||||
|
||||
half2 MultiScaleFoamNormal
|
||||
@@ -112,8 +97,8 @@ half2 MultiScaleFoamNormal
|
||||
|
||||
// 0.25 is magic number found through tweaking.
|
||||
const float2 dd = float2(0.25 * i_PixelZ * i_Texture._texel, 0.0);
|
||||
const half whiteFoam_x = WhiteFoamTexture(i_Texture, i_FoamData, i_Feather, worldXZ0, worldXZ1, dd.xy, i_LodAlpha, i_CascadeData0).r;
|
||||
const half whiteFoam_z = WhiteFoamTexture(i_Texture, i_FoamData, i_Feather, worldXZ0, worldXZ1, dd.yx, i_LodAlpha, i_CascadeData0).r;
|
||||
const half whiteFoam_x = WhiteFoamTexture(i_Texture, i_FoamData, i_Feather, worldXZ0, worldXZ1, dd.xy, i_LodAlpha, i_CascadeData0);
|
||||
const half whiteFoam_z = WhiteFoamTexture(i_Texture, i_FoamData, i_Feather, worldXZ0, worldXZ1, dd.yx, i_LodAlpha, i_CascadeData0);
|
||||
|
||||
// Compute a foam normal - manually push in derivatives. If I used blend
|
||||
// smooths all the normals towards straight up when there is no foam.
|
||||
@@ -122,7 +107,7 @@ half2 MultiScaleFoamNormal
|
||||
return magicStrengthFactor * i_NormalStrength * half2(whiteFoam_x - i_FoamAlbedo, whiteFoam_z - i_FoamAlbedo) / dd.x;
|
||||
}
|
||||
|
||||
half2 MultiScaleFoamAlbedo
|
||||
half MultiScaleFoamAlbedo
|
||||
(
|
||||
const Flow i_Flow,
|
||||
const TiledTexture i_Texture,
|
||||
@@ -131,8 +116,7 @@ half2 MultiScaleFoamAlbedo
|
||||
const Cascade i_CascadeData0,
|
||||
const Cascade i_CascadeData1,
|
||||
const half i_LodAlpha,
|
||||
const float2 i_UndisplacedXZ,
|
||||
const bool i_Sample2ndChannel
|
||||
const float2 i_UndisplacedXZ
|
||||
)
|
||||
{
|
||||
return MultiScaleFoamAlbedo
|
||||
@@ -143,8 +127,7 @@ half2 MultiScaleFoamAlbedo
|
||||
i_CascadeData0,
|
||||
i_CascadeData1,
|
||||
i_LodAlpha,
|
||||
i_UndisplacedXZ - i_Flow._Flow * i_Flow._Offset0,
|
||||
i_Sample2ndChannel
|
||||
i_UndisplacedXZ - i_Flow._Flow * i_Flow._Offset0
|
||||
) * i_Flow._Weight0 + MultiScaleFoamAlbedo
|
||||
(
|
||||
i_Texture,
|
||||
@@ -153,8 +136,7 @@ half2 MultiScaleFoamAlbedo
|
||||
i_CascadeData0,
|
||||
i_CascadeData1,
|
||||
i_LodAlpha,
|
||||
i_UndisplacedXZ - i_Flow._Flow * i_Flow._Offset1,
|
||||
i_Sample2ndChannel
|
||||
i_UndisplacedXZ - i_Flow._Flow * i_Flow._Offset1
|
||||
) * i_Flow._Weight1;
|
||||
}
|
||||
|
||||
@@ -232,10 +214,8 @@ void ApplyFoamToSurface
|
||||
// as if it had transmission.
|
||||
// There is still ugliness around the edges. There will either be black or
|
||||
// incorrect reflections depending on the magic value.
|
||||
io_NormalWS = i_Foam > 0.0 ? half3(0.0, 1.0, 0.0) : io_NormalWS;
|
||||
#if _SPECULAR_SETUP
|
||||
io_NormalWS.y *= i_Foam > 0.15 ? -1.0 : 1.0;
|
||||
io_Specular = lerp(io_Specular, i_Specular, i_Foam);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,31 +23,13 @@ void SetUpFog(bool i_Underwater, float3 i_PositionWS, float i_Multiplier, float
|
||||
{
|
||||
s_IsUnderWater = i_Underwater;
|
||||
|
||||
// XR does not like early returns in URP.
|
||||
#if !defined(STEREO_INSTANCING_ON) && !defined(STEREO_MULTIVIEW_ON)
|
||||
if (!s_IsUnderWater)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (CREST_LEGACY_UNDERWATER != 1)
|
||||
ApplyUnderwaterEffect
|
||||
(
|
||||
0, // Not used (color)
|
||||
0, // TIR only
|
||||
0, // Caustics only
|
||||
i_FogDistance,
|
||||
i_ViewWS,
|
||||
i_PositionSS,
|
||||
i_PositionWS,
|
||||
false, // No caustics
|
||||
true, // TODO: implement
|
||||
false, // Do not apply lighting
|
||||
1.0, // TODO: implement
|
||||
s_VolumeOpacity,
|
||||
s_VolumeLighting
|
||||
);
|
||||
s_PositionSS = i_PositionSS;
|
||||
s_PositionWS = i_PositionWS;
|
||||
s_ViewWS = i_ViewWS;
|
||||
s_FogDistance = i_FogDistance;
|
||||
s_DepthRaw = 0;
|
||||
s_FogMultiplier = i_Multiplier;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define m_Properties \
|
||||
const float2 i_UndisplacedXZ, \
|
||||
float i_LodAlpha, \
|
||||
const float i_LodAlpha, \
|
||||
const half i_WaterLevelOffset, \
|
||||
const float2 i_WaterLevelDerivatives, \
|
||||
const half2 i_Flow, \
|
||||
@@ -19,36 +19,13 @@
|
||||
const float3 i_PositionWS, \
|
||||
const float3 i_PositionVS, \
|
||||
const float2 i_StaticLightMapUV, \
|
||||
inout half3 o_Albedo, \
|
||||
inout half3 o_NormalWS, \
|
||||
inout half3 o_Specular, \
|
||||
inout half3 o_Emission, \
|
||||
inout half o_Smoothness, \
|
||||
inout half o_Occlusion, \
|
||||
inout half o_Alpha
|
||||
|
||||
#define m_Parameters \
|
||||
i_UndisplacedXZ, \
|
||||
i_LodAlpha, \
|
||||
i_WaterLevelOffset, \
|
||||
i_WaterLevelDerivatives, \
|
||||
i_Flow, \
|
||||
i_ViewDirectionWS, \
|
||||
i_Facing, \
|
||||
i_SceneColor, \
|
||||
i_SceneDepthRaw, \
|
||||
i_ScreenPosition, \
|
||||
i_ScreenPositionRaw, \
|
||||
i_PositionWS, \
|
||||
i_PositionVS, \
|
||||
i_StaticLightMapUV, \
|
||||
o_Albedo, \
|
||||
o_NormalWS, \
|
||||
o_Specular, \
|
||||
o_Emission, \
|
||||
o_Smoothness, \
|
||||
o_Occlusion, \
|
||||
o_Alpha
|
||||
out half3 o_Albedo, \
|
||||
out half3 o_NormalWS, \
|
||||
out half3 o_Specular, \
|
||||
out half3 o_Emission, \
|
||||
out half o_Smoothness, \
|
||||
out half o_Occlusion, \
|
||||
out half o_Alpha
|
||||
|
||||
// Guard against Shader Graph preview.
|
||||
#ifndef SHADERGRAPH_PREVIEW
|
||||
@@ -56,7 +33,6 @@
|
||||
#define d_Crest_WaterSurface 1
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Shim.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Keywords.hlsl"
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Globals.hlsl"
|
||||
@@ -78,7 +54,6 @@
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Refraction.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Caustics.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/VolumeLighting.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Emission.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Fresnel.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Foam.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Alpha.hlsl"
|
||||
@@ -104,18 +79,17 @@ static const TiledTexture _Crest_CausticsTiledTexture =
|
||||
static const TiledTexture _Crest_CausticsDistortionTiledTexture =
|
||||
TiledTexture::Make(_Crest_CausticsDistortionTexture, sampler_Crest_CausticsDistortionTexture, _Crest_CausticsDistortionTexture_TexelSize, _Crest_CausticsDistortionScale, 1.0);
|
||||
|
||||
void Fragment
|
||||
(
|
||||
m_Properties,
|
||||
const uint i_LodIndex0,
|
||||
const uint i_LodIndex1,
|
||||
const float2 i_PositionSS,
|
||||
const bool i_Underwater,
|
||||
const float i_SceneZRaw,
|
||||
const float i_NegativeFog
|
||||
)
|
||||
void Fragment(m_Properties)
|
||||
{
|
||||
float2 scenePositionSS = i_PositionSS;
|
||||
o_Albedo = 0.0;
|
||||
o_NormalWS = half3(0.0, 1.0, 0.0);
|
||||
o_Specular = 0.0;
|
||||
o_Emission = 0.0;
|
||||
o_Smoothness = 0.7;
|
||||
o_Occlusion = 1.0;
|
||||
o_Alpha = 1.0;
|
||||
|
||||
const float2 positionSS = i_ScreenPosition.xy * _ScreenSize.xy;
|
||||
|
||||
// Editor only. There is no defined editor symbol.
|
||||
if (_Crest_DrawBoundaryXZ)
|
||||
@@ -131,25 +105,47 @@ void Fragment
|
||||
}
|
||||
}
|
||||
|
||||
const uint slice0 = i_LodIndex0;
|
||||
const uint slice1 = i_LodIndex1;
|
||||
bool underwater = IsUnderWater(i_Facing, g_Crest_ForceUnderwater, positionSS);
|
||||
|
||||
#if d_Crest_FlowLod
|
||||
// TODO: Should we use PosToSIs or check for overflow?
|
||||
float slice0 = _Crest_LodIndex;
|
||||
float slice1 = _Crest_LodIndex + 1;
|
||||
|
||||
#ifdef CREST_FLOW_ON
|
||||
const Flow flow = Flow::Make(i_Flow, g_Crest_Time);
|
||||
#endif
|
||||
|
||||
const Cascade cascade0 = Cascade::Make(slice0);
|
||||
const Cascade cascade1 = Cascade::Make(slice1);
|
||||
|
||||
const float sceneZ = Utility::CrestLinearEyeDepth(i_SceneZRaw);
|
||||
const float pixelZ = -i_PositionVS.z;
|
||||
float sceneRawZ = i_SceneDepthRaw;
|
||||
float negativeFog = _ProjectionParams.y;
|
||||
|
||||
const bool isLastLod = slice0 == (uint)g_Crest_LodCount - 1;
|
||||
#if (CREST_PORTALS != 0)
|
||||
#ifndef CREST_SHADOWPASS
|
||||
#if _ALPHATEST_ON
|
||||
if (m_CrestPortal)
|
||||
{
|
||||
const float pixelRawZ = i_ScreenPositionRaw.z / i_ScreenPositionRaw.w;
|
||||
if (Portal::EvaluateSurface(i_ScreenPosition.xy, pixelRawZ, i_PositionWS, underwater, sceneRawZ, negativeFog))
|
||||
{
|
||||
o_Alpha = 0.0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float sceneZ = Utility::CrestLinearEyeDepth(sceneRawZ);
|
||||
float pixelZ = -i_PositionVS.z;
|
||||
|
||||
const bool isLastLod = _Crest_LodIndex == (uint)g_Crest_LodCount - 1;
|
||||
const float weight0 = (1.0 - i_LodAlpha) * cascade0._Weight;
|
||||
const float weight1 = (1.0 - weight0) * cascade1._Weight;
|
||||
|
||||
// Data that fades towards the edge.
|
||||
half foam = 0.0; half _determinant = 0.0; half4 albedo = 0.0; half2 shadow = 0.0; half waterDepth = i_WaterLevelOffset; half shorelineDistance = 0.0;
|
||||
half foam = 0.0; half _determinant = 0.0; half4 albedo = 0.0; half2 shadow = 0.0;
|
||||
if (weight0 > m_CrestSampleLodThreshold)
|
||||
{
|
||||
Cascade::MakeAnimatedWaves(slice0).SampleNormals(i_UndisplacedXZ, weight0, o_NormalWS.xz, _determinant);
|
||||
@@ -159,28 +155,15 @@ void Fragment
|
||||
Cascade::MakeFoam(slice0).SampleFoam(i_UndisplacedXZ, weight0, foam);
|
||||
}
|
||||
|
||||
#if d_Crest_AlbedoLod
|
||||
if (_Crest_AlbedoEnabled)
|
||||
{
|
||||
Cascade::MakeAlbedo(slice0).SampleAlbedo(i_UndisplacedXZ, weight0, albedo);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_Crest_ShadowLod
|
||||
if (_Crest_ShadowsEnabled)
|
||||
{
|
||||
Cascade::MakeShadow(slice0).SampleShadow(i_PositionWS.xz, weight0, shadow);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_Crest_SimpleTransparency || d_Crest_FoamBioluminescence
|
||||
#if !d_Crest_SimpleTransparency
|
||||
if (_Crest_FoamEnabled && _Crest_FoamBioluminescenceEnabled)
|
||||
#endif
|
||||
{
|
||||
Cascade::MakeDepth(slice0).SampleSignedDepthFromSeaLevelAndDistance(i_PositionWS.xz, weight0, waterDepth, shorelineDistance);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (weight1 > m_CrestSampleLodThreshold)
|
||||
@@ -192,28 +175,15 @@ void Fragment
|
||||
Cascade::MakeFoam(slice1).SampleFoam(i_UndisplacedXZ, weight1, foam);
|
||||
}
|
||||
|
||||
#if d_Crest_AlbedoLod
|
||||
if (_Crest_AlbedoEnabled)
|
||||
{
|
||||
Cascade::MakeAlbedo(slice1).SampleAlbedo(i_UndisplacedXZ, weight1, albedo);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_Crest_ShadowLod
|
||||
if (_Crest_ShadowsEnabled)
|
||||
{
|
||||
Cascade::MakeShadow(slice1).SampleShadow(i_PositionWS.xz, weight1, shadow);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_Crest_SimpleTransparency || d_Crest_FoamBioluminescence
|
||||
#if !d_Crest_SimpleTransparency
|
||||
if (_Crest_FoamEnabled && _Crest_FoamBioluminescenceEnabled)
|
||||
#endif
|
||||
{
|
||||
Cascade::MakeDepth(slice1).SampleSignedDepthFromSeaLevelAndDistance(i_PositionWS.xz, weight1, waterDepth, shorelineDistance);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Invert so shadows are black as we normally multiply this by lighting.
|
||||
@@ -221,81 +191,99 @@ void Fragment
|
||||
|
||||
// Data that displays to the edge.
|
||||
// The default simulation value has been written to the border of the last slice.
|
||||
half3 absorption = _Crest_Absorption.xyz; half3 scattering = _Crest_Scattering.xyz;
|
||||
|
||||
#if d_Crest_AbsorptionLod || d_Crest_ScatteringLod
|
||||
half3 absorption = 0.0; half3 scattering = 0.0;
|
||||
{
|
||||
const float weight0 = (1.0 - (isLastLod ? 0.0 : i_LodAlpha)) * cascade0._Weight;
|
||||
const float weight1 = (1.0 - weight0) * cascade1._Weight;
|
||||
|
||||
#if d_Crest_ScatteringLod
|
||||
if (g_Crest_SampleScatteringSimulation)
|
||||
{
|
||||
scattering = 0.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_Crest_AbsorptionLod
|
||||
if (g_Crest_SampleAbsorptionSimulation)
|
||||
{
|
||||
absorption = 0.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (weight0 > m_CrestSampleLodThreshold)
|
||||
{
|
||||
#if d_Crest_ScatteringLod
|
||||
if (g_Crest_SampleScatteringSimulation)
|
||||
{
|
||||
Cascade::MakeScattering(slice0).SampleScattering(i_UndisplacedXZ, weight0, scattering);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_Crest_AbsorptionLod
|
||||
if (g_Crest_SampleAbsorptionSimulation)
|
||||
{
|
||||
Cascade::MakeAbsorption(slice0).SampleAbsorption(i_UndisplacedXZ, weight0, absorption);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (weight1 > m_CrestSampleLodThreshold)
|
||||
{
|
||||
#if d_Crest_ScatteringLod
|
||||
if (g_Crest_SampleScatteringSimulation)
|
||||
{
|
||||
Cascade::MakeScattering(slice1).SampleScattering(i_UndisplacedXZ, weight1, scattering);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_Crest_AbsorptionLod
|
||||
if (g_Crest_SampleAbsorptionSimulation)
|
||||
{
|
||||
Cascade::MakeAbsorption(slice1).SampleAbsorption(i_UndisplacedXZ, weight1, absorption);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!g_Crest_SampleScatteringSimulation)
|
||||
{
|
||||
scattering = _Crest_Scattering.xyz;
|
||||
}
|
||||
|
||||
if (!g_Crest_SampleAbsorptionSimulation)
|
||||
{
|
||||
absorption = _Crest_Absorption.xyz;
|
||||
}
|
||||
|
||||
// Determinant needs to be one when no waves.
|
||||
if (isLastLod)
|
||||
{
|
||||
_determinant += 1.0 - weight0;
|
||||
waterDepth = 10000.0;
|
||||
}
|
||||
|
||||
#if d_Transparent
|
||||
// Feather at intersection. Cannot be used for shadows since depth is not available.
|
||||
const float feather =
|
||||
#if d_Crest_SimpleTransparency
|
||||
saturate(waterDepth / 0.2);
|
||||
#else
|
||||
saturate((sceneZ - pixelZ) / 0.2);
|
||||
#endif
|
||||
// Normal.
|
||||
{
|
||||
if (_Crest_NormalMapEnabled)
|
||||
{
|
||||
o_NormalWS.xz += SampleNormalMaps
|
||||
(
|
||||
#ifdef CREST_FLOW_ON
|
||||
flow,
|
||||
#endif
|
||||
_Crest_NormalMapTiledTexture,
|
||||
_Crest_NormalMapStrength,
|
||||
i_UndisplacedXZ,
|
||||
i_LodAlpha,
|
||||
cascade0
|
||||
);
|
||||
}
|
||||
|
||||
const half3 extinction = VolumeExtinction(absorption, scattering);
|
||||
o_NormalWS = normalize(o_NormalWS);
|
||||
|
||||
WaterNormal
|
||||
(
|
||||
i_WaterLevelDerivatives,
|
||||
i_ViewDirectionWS,
|
||||
_Crest_MinimumReflectionDirectionY,
|
||||
underwater,
|
||||
o_NormalWS
|
||||
);
|
||||
|
||||
o_NormalWS = normalize(o_NormalWS);
|
||||
|
||||
o_NormalWS.xz *= _Crest_NormalsStrengthOverall;
|
||||
o_NormalWS.y = lerp(1.0, o_NormalWS.y, _Crest_NormalsStrengthOverall);
|
||||
|
||||
if (underwater)
|
||||
{
|
||||
// Flip when underwater.
|
||||
o_NormalWS.xyz *= -1.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Default for opaque render type.
|
||||
float sceneDistance = 1000.0;
|
||||
float3 scenePositionWS = 0.0;
|
||||
|
||||
const half3 ambientLight = AmbientLight();
|
||||
|
||||
float3 lightIntensity = 0.0;
|
||||
half3 lightDirection = 0.0;
|
||||
@@ -307,123 +295,24 @@ void Fragment
|
||||
lightDirection
|
||||
);
|
||||
|
||||
const half3 ambientLight = AmbientLight();
|
||||
const half3 additionalLight = AdditionalLighting(i_PositionWS, i_ScreenPositionRaw, i_StaticLightMapUV);
|
||||
half3 additionalLight = AdditionalLighting(i_PositionWS, i_ScreenPositionRaw, i_StaticLightMapUV);
|
||||
|
||||
// Normal.
|
||||
{
|
||||
WaterNormal
|
||||
(
|
||||
i_WaterLevelDerivatives,
|
||||
i_ViewDirectionWS,
|
||||
_Crest_MinimumReflectionDirectionY,
|
||||
i_Underwater,
|
||||
o_NormalWS
|
||||
);
|
||||
|
||||
#if d_Crest_NormalMap
|
||||
if (_Crest_NormalMapEnabled)
|
||||
{
|
||||
const half2 normalMap = SampleNormalMaps
|
||||
(
|
||||
#if d_Crest_FlowLod
|
||||
flow,
|
||||
#endif
|
||||
_Crest_NormalMapTiledTexture,
|
||||
_Crest_NormalMapStrength,
|
||||
i_UndisplacedXZ,
|
||||
i_LodAlpha,
|
||||
cascade0
|
||||
);
|
||||
|
||||
half normalMapStrength = _Crest_NormalMapStrength;
|
||||
|
||||
if (_Crest_NormalMapTurbulenceEnabled)
|
||||
{
|
||||
normalMapStrength = NormalMapTurbulence
|
||||
(
|
||||
o_NormalWS,
|
||||
normalMap,
|
||||
normalMapStrength,
|
||||
_Crest_NormalMapTurbulenceCoverage,
|
||||
_Crest_NormalMapTurbulenceStrength,
|
||||
i_ViewDirectionWS,
|
||||
_determinant,
|
||||
g_Crest_WaterCenter.y + i_WaterLevelOffset,
|
||||
pixelZ,
|
||||
lightDirection
|
||||
);
|
||||
}
|
||||
|
||||
o_NormalWS.xz += normalMap * normalMapStrength;
|
||||
}
|
||||
#endif // d_Crest_NormalMap
|
||||
|
||||
o_NormalWS = normalize(o_NormalWS);
|
||||
|
||||
WaterNormal
|
||||
(
|
||||
i_WaterLevelDerivatives,
|
||||
i_ViewDirectionWS,
|
||||
_Crest_MinimumReflectionDirectionY,
|
||||
i_Underwater,
|
||||
o_NormalWS
|
||||
);
|
||||
|
||||
o_NormalWS = normalize(o_NormalWS);
|
||||
|
||||
o_NormalWS.xz *= _Crest_NormalsStrengthOverall;
|
||||
o_NormalWS.y = lerp(1.0, o_NormalWS.y, _Crest_NormalsStrengthOverall);
|
||||
|
||||
if (i_Underwater)
|
||||
{
|
||||
// Flip when underwater.
|
||||
o_NormalWS.xyz *= -1.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Default for opaque render type.
|
||||
float sceneDistance = 1000.0;
|
||||
float3 scenePositionWS = i_PositionWS;
|
||||
|
||||
#if d_Crest_SimpleTransparency
|
||||
sceneDistance = waterDepth;
|
||||
// Increase ray for grazing angles.
|
||||
sceneDistance += (1.0 - dot(i_ViewDirectionWS, o_NormalWS)) * waterDepth;
|
||||
scenePositionWS.y = i_PositionWS.y - waterDepth;
|
||||
// Cannot sample scene so go with average light.
|
||||
o_Emission = i_Underwater ? 0.0 : (0.5 * (lightIntensity + additionalLight + ambientLight) * INV_PI);
|
||||
#if CREST_HDRP
|
||||
o_Emission /= GetCurrentExposureMultiplier();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
bool caustics = !i_Underwater;
|
||||
|
||||
#if !d_Crest_SimpleTransparency
|
||||
#if d_Transparent
|
||||
#ifndef d_SkipRefraction
|
||||
bool caustics;
|
||||
RefractedScene
|
||||
(
|
||||
_Crest_RefractionStrength,
|
||||
1.000293, // air
|
||||
_Crest_RefractiveIndexOfWater,
|
||||
o_NormalWS,
|
||||
i_PositionWS,
|
||||
i_ScreenPosition.xy,
|
||||
i_ScreenPositionRaw,
|
||||
pixelZ,
|
||||
i_ViewDirectionWS,
|
||||
i_SceneColor,
|
||||
sceneZ,
|
||||
i_SceneZRaw,
|
||||
cascade0._Scale,
|
||||
i_LodAlpha,
|
||||
i_Underwater,
|
||||
_Crest_TotalInternalReflectionIntensity,
|
||||
sceneRawZ,
|
||||
underwater,
|
||||
o_Emission,
|
||||
sceneDistance,
|
||||
scenePositionWS,
|
||||
scenePositionSS,
|
||||
caustics
|
||||
);
|
||||
|
||||
@@ -440,46 +329,45 @@ void Fragment
|
||||
#endif
|
||||
#endif // d_SkipRefraction
|
||||
#endif // d_Transparent
|
||||
#endif // d_Crest_SimpleTransparency
|
||||
|
||||
float refractedSeaLevel = g_Crest_WaterCenter.y;
|
||||
float3 refractedSurfacePosition = float3(0, refractedSeaLevel, 0);
|
||||
if (!underwater && slice1 < g_Crest_LodCount)
|
||||
{
|
||||
// Sample larger slice to avoid the first slice.
|
||||
float4 displacement = Cascade::MakeAnimatedWaves(slice1).Sample(scenePositionWS.xz);
|
||||
refractedSeaLevel = g_Crest_WaterCenter.y + displacement.w;
|
||||
refractedSurfacePosition = displacement.xyz;
|
||||
refractedSurfacePosition.y += refractedSeaLevel;
|
||||
}
|
||||
|
||||
// Out-scattering.
|
||||
if (!i_Underwater)
|
||||
if (!underwater)
|
||||
{
|
||||
// Account for extinction of light as it travels down through volume.
|
||||
o_Emission *= exp(-extinction * max(0.0, i_PositionWS.y - scenePositionWS.y));
|
||||
// Account for average extinction of light as it travels down through volume. Assume flat water as anything else would be expensive.
|
||||
half3 extinction = absorption.xyz + scattering.xyz;
|
||||
o_Emission *= exp(-extinction * max(0.0, refractedSeaLevel - scenePositionWS.y));
|
||||
}
|
||||
|
||||
#if d_Transparent
|
||||
#ifndef d_SkipRefraction
|
||||
// Caustics
|
||||
if (_Crest_CausticsEnabled && !i_Underwater && caustics)
|
||||
if (_Crest_CausticsEnabled && !underwater && caustics)
|
||||
{
|
||||
half lightOcclusion = 1.0;
|
||||
#if !d_Crest_SimpleTransparency
|
||||
lightOcclusion = PrimaryLightShadows(scenePositionWS, scenePositionSS);
|
||||
#endif
|
||||
|
||||
#if d_Crest_SimpleTransparency
|
||||
if (_Crest_RefractionStrength > 0.0)
|
||||
{
|
||||
// Gives a parallax like effect.
|
||||
const half3 ray = refract(-i_ViewDirectionWS, o_NormalWS, 1.0 / _Crest_RefractiveIndexOfWater) * _Crest_RefractionStrength;
|
||||
scenePositionWS += ray * waterDepth * 2.0;
|
||||
}
|
||||
#endif
|
||||
half lightOcclusion = PrimaryLightShadows(scenePositionWS, positionSS);
|
||||
|
||||
half blur = 0.0;
|
||||
#if d_Crest_FlowLod
|
||||
#ifdef CREST_FLOW_ON
|
||||
blur = _Crest_CausticsMotionBlur;
|
||||
#endif
|
||||
|
||||
o_Emission *= Caustics
|
||||
(
|
||||
#if d_Crest_FlowLod
|
||||
#ifdef CREST_FLOW_ON
|
||||
flow,
|
||||
#endif
|
||||
scenePositionWS,
|
||||
i_PositionWS.y,
|
||||
refractedSurfacePosition.y,
|
||||
lightIntensity,
|
||||
lightDirection,
|
||||
lightOcclusion,
|
||||
@@ -492,7 +380,7 @@ void Fragment
|
||||
_Crest_CausticsDistortionTiledTexture,
|
||||
_Crest_CausticsDistortionStrength,
|
||||
blur,
|
||||
_Crest_CausticsForceDistortion
|
||||
underwater
|
||||
);
|
||||
}
|
||||
#endif // d_SkipRefraction
|
||||
@@ -516,6 +404,7 @@ void Fragment
|
||||
}
|
||||
|
||||
// Volume Lighting
|
||||
const half3 extinction = VolumeExtinction(absorption, scattering);
|
||||
const half3 volumeOpacity = VolumeOpacity(extinction, sceneDistance);
|
||||
const half3 volumeLight = VolumeLighting
|
||||
(
|
||||
@@ -542,7 +431,7 @@ void Fragment
|
||||
(
|
||||
i_ViewDirectionWS,
|
||||
o_NormalWS,
|
||||
i_Underwater,
|
||||
underwater,
|
||||
1.0, // air
|
||||
_Crest_RefractiveIndexOfWater,
|
||||
_Crest_TotalInternalReflectionIntensity,
|
||||
@@ -550,7 +439,7 @@ void Fragment
|
||||
reflected
|
||||
);
|
||||
|
||||
if (i_Underwater)
|
||||
if (underwater)
|
||||
{
|
||||
o_Emission *= transmitted;
|
||||
o_Emission += volumeLight * reflected;
|
||||
@@ -563,12 +452,10 @@ void Fragment
|
||||
}
|
||||
}
|
||||
|
||||
#if _SPECULAR_SETUP
|
||||
// Specular
|
||||
{
|
||||
o_Specular = _Crest_Specular * reflected * shadow.y;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Smoothness
|
||||
{
|
||||
@@ -578,27 +465,24 @@ void Fragment
|
||||
|
||||
// Occlusion
|
||||
{
|
||||
o_Occlusion = i_Underwater ? _Crest_OcclusionUnderwater : _Crest_Occlusion;
|
||||
o_Occlusion = underwater ? _Crest_OcclusionUnderwater : _Crest_Occlusion;
|
||||
}
|
||||
|
||||
// Planar Reflections
|
||||
#if d_Crest_PlanarReflections
|
||||
if (_Crest_PlanarReflectionsEnabled)
|
||||
{
|
||||
half4 reflection = PlanarReflection
|
||||
(
|
||||
_Crest_ReflectionColorTexture,
|
||||
sampler_Crest_ReflectionColorTexture,
|
||||
_Crest_ReflectionTexture,
|
||||
sampler_Crest_ReflectionTexture,
|
||||
_Crest_PlanarReflectionsIntensity,
|
||||
o_Smoothness,
|
||||
_Crest_PlanarReflectionsRoughness,
|
||||
_Crest_MinimumReflectionDirectionY,
|
||||
pixelZ,
|
||||
o_NormalWS,
|
||||
_Crest_PlanarReflectionsDistortion,
|
||||
i_ViewDirectionWS,
|
||||
i_ScreenPosition.xy,
|
||||
i_Underwater
|
||||
underwater
|
||||
);
|
||||
|
||||
half alpha = reflection.a;
|
||||
@@ -607,14 +491,13 @@ void Fragment
|
||||
// Results are darker than Unity's.
|
||||
o_Occlusion *= 1.0 - alpha;
|
||||
}
|
||||
#endif // d_Crest_PlanarReflections
|
||||
|
||||
// Foam
|
||||
if (_Crest_FoamEnabled)
|
||||
{
|
||||
half2 albedo = MultiScaleFoamAlbedo
|
||||
half albedo = MultiScaleFoamAlbedo
|
||||
(
|
||||
#if d_Crest_FlowLod
|
||||
#ifdef CREST_FLOW_ON
|
||||
flow,
|
||||
#endif
|
||||
_Crest_FoamTiledTexture,
|
||||
@@ -623,20 +506,19 @@ void Fragment
|
||||
cascade0,
|
||||
cascade1,
|
||||
i_LodAlpha,
|
||||
i_UndisplacedXZ,
|
||||
_Crest_FoamBioluminescenceEnabled && _Crest_FoamBioluminescenceSparklesEnabled
|
||||
i_UndisplacedXZ
|
||||
);
|
||||
|
||||
half2 normal = MultiScaleFoamNormal
|
||||
(
|
||||
#if d_Crest_FlowLod
|
||||
#ifdef CREST_FLOW_ON
|
||||
flow,
|
||||
#endif
|
||||
_Crest_FoamTiledTexture,
|
||||
_Crest_FoamFeather,
|
||||
_Crest_FoamNormalStrength,
|
||||
foam,
|
||||
albedo.x,
|
||||
albedo,
|
||||
cascade0,
|
||||
cascade1,
|
||||
i_LodAlpha,
|
||||
@@ -648,13 +530,13 @@ void Fragment
|
||||
|
||||
ApplyFoamToSurface
|
||||
(
|
||||
albedo.x,
|
||||
albedo,
|
||||
normal,
|
||||
intensity,
|
||||
_Crest_Occlusion,
|
||||
_Crest_FoamSmoothness,
|
||||
_Crest_Specular,
|
||||
i_Underwater,
|
||||
underwater,
|
||||
o_Albedo,
|
||||
o_NormalWS,
|
||||
o_Emission,
|
||||
@@ -664,71 +546,36 @@ void Fragment
|
||||
);
|
||||
|
||||
// We will use this for shadow casting.
|
||||
const half foamData = foam;
|
||||
foam = albedo.r;
|
||||
|
||||
#if d_Crest_FoamBioluminescence
|
||||
if (_Crest_FoamBioluminescenceEnabled)
|
||||
{
|
||||
half3 emission = FoamBioluminescence
|
||||
(
|
||||
foamData,
|
||||
albedo.r,
|
||||
_Crest_FoamBioluminescenceColor.rgb,
|
||||
_Crest_FoamBioluminescenceIntensity,
|
||||
_Crest_FoamBioluminescenceGlowCoverage,
|
||||
_Crest_FoamBioluminescenceGlowIntensity,
|
||||
_Crest_FoamBioluminescenceSparklesEnabled,
|
||||
albedo.y,
|
||||
_Crest_FoamBioluminescenceSparklesCoverage,
|
||||
_Crest_FoamBioluminescenceSparklesIntensity,
|
||||
_Crest_FoamBioluminescenceMaximumDepth,
|
||||
waterDepth
|
||||
);
|
||||
|
||||
emission *= _Crest_FoamBioluminescenceSeaLevelOnly ? saturate(1.0 - abs(i_WaterLevelOffset)) : 1.0;
|
||||
|
||||
#if d_Transparent
|
||||
// Apply feathering to avoid hardening the edge.
|
||||
emission *= feather * feather * feather;
|
||||
#endif
|
||||
|
||||
o_Emission += emission;
|
||||
}
|
||||
#endif // d_Crest_FoamBioluminescence
|
||||
foam = albedo;
|
||||
}
|
||||
|
||||
// Albedo
|
||||
#if d_Crest_AlbedoLod
|
||||
if (_Crest_AlbedoEnabled)
|
||||
{
|
||||
const float foamMask = _Crest_AlbedoIgnoreFoam ? (1.0 - saturate(foam)) : 1.0;
|
||||
o_Albedo = lerp(o_Albedo, albedo.rgb, albedo.a * foamMask);
|
||||
o_Emission *= 1.0 - albedo.a * foamMask;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_Crest_SimpleTransparency
|
||||
o_Alpha = i_Underwater
|
||||
? 1.0 - transmitted
|
||||
: max(max(length(volumeOpacity), _Crest_TransparencyMinimumAlpha), max(foam, albedo.a));
|
||||
#endif
|
||||
|
||||
// Alpha
|
||||
{
|
||||
#ifndef CREST_SHADOWPASS
|
||||
#if d_Transparent
|
||||
// Feather at intersection. Cannot be used for shadows since depth is not available.
|
||||
o_Alpha = min(o_Alpha, feather);
|
||||
o_Alpha = saturate((sceneZ - pixelZ) / 0.2);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// This keyword works for all RPs despite BIRP having prefixes in serialised data.
|
||||
#if d_Crest_AlphaTest
|
||||
#if _ALPHATEST_ON
|
||||
#if CREST_SHADOWPASS
|
||||
o_Alpha = min(o_Alpha, max(foam, albedo.a) - _Crest_ShadowCasterThreshold);
|
||||
o_Alpha = max(foam, albedo.a) - _Crest_ShadowCasterThreshold;
|
||||
#endif
|
||||
#endif // d_Crest_AlphaTest
|
||||
|
||||
// Add 0.5 bias for LOD blending and texel resolution correction. This will help to
|
||||
// tighten and smooth clipped edges.
|
||||
o_Alpha -= ClipSurface(i_PositionWS.xz) > 0.5 ? 2.0 : 0.0;
|
||||
#endif // _ALPHATEST_ON
|
||||
|
||||
// Specular in HDRP is still affected outside the 0-1 alpha range.
|
||||
o_Alpha = min(o_Alpha, 1.0);
|
||||
@@ -736,107 +583,22 @@ void Fragment
|
||||
|
||||
SetUpFog
|
||||
(
|
||||
i_Underwater,
|
||||
underwater,
|
||||
i_PositionWS,
|
||||
1.0, // N/A: multiplier for fog nodes
|
||||
pixelZ - i_NegativeFog,
|
||||
sceneDistance - negativeFog,
|
||||
i_ViewDirectionWS,
|
||||
i_PositionSS
|
||||
positionSS
|
||||
);
|
||||
}
|
||||
|
||||
// IMPORTANT!
|
||||
// Do not branch on o_Alpha, as it is not robust. Rendering will break on stereo
|
||||
// rendering in the form of losing additional lighting and/or broken reflection
|
||||
// probe sampling. This is an issue with the shader compiler it seems.
|
||||
void Fragment(m_Properties)
|
||||
{
|
||||
const float2 positionSS = i_ScreenPosition.xy * _ScreenSize.xy;
|
||||
|
||||
bool underwater = IsUnderWater(i_Facing, g_Crest_ForceUnderwater, positionSS);
|
||||
float sceneRawZ = i_SceneDepthRaw;
|
||||
float negativeFog = _ProjectionParams.y;
|
||||
|
||||
#if d_Crest_AlphaTest
|
||||
#if !d_Crest_SimpleTransparency
|
||||
#ifndef CREST_SHADOWPASS
|
||||
#if (CREST_PORTALS != 0)
|
||||
if (m_CrestPortal)
|
||||
{
|
||||
const float pixelRawZ = i_ScreenPositionRaw.z / i_ScreenPositionRaw.w;
|
||||
o_Alpha = Portal::EvaluateSurface(i_ScreenPosition.xy, pixelRawZ, i_PositionWS, underwater, sceneRawZ, negativeFog) ? -1.0 : 1.0;
|
||||
#ifndef SHADER_API_WEBGPU
|
||||
clip(o_Alpha);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uint slice0;
|
||||
uint slice1;
|
||||
float alpha;
|
||||
|
||||
#if d_Crest_AlphaTest || d_Crest_CustomMesh
|
||||
PosToSliceIndices(i_PositionWS.xz, 0.0, g_Crest_LodCount - 1.0, g_Crest_WaterScale, slice0, slice1, alpha);
|
||||
#endif
|
||||
|
||||
#if d_Crest_AlphaTest
|
||||
{
|
||||
const Cascade cascade0 = Cascade::Make(slice0);
|
||||
const Cascade cascade1 = Cascade::Make(slice1);
|
||||
const float weight0 = (1.0 - alpha) * cascade0._Weight;
|
||||
const float weight1 = (1.0 - weight0) * cascade1._Weight;
|
||||
|
||||
float clipSurface = 0.0;
|
||||
if (weight0 > m_CrestSampleLodThreshold)
|
||||
{
|
||||
Cascade::MakeClip(slice0).SampleClip(i_PositionWS.xz, weight0, clipSurface);
|
||||
}
|
||||
if (weight1 > m_CrestSampleLodThreshold)
|
||||
{
|
||||
Cascade::MakeClip(slice1).SampleClip(i_PositionWS.xz, weight1, clipSurface);
|
||||
}
|
||||
|
||||
// Add 0.5 bias for LOD blending and texel resolution correction. This will help to
|
||||
// tighten and smooth clipped edges.
|
||||
o_Alpha -= clipSurface > 0.5 ? 2.0 : 0.0;
|
||||
|
||||
#ifndef SHADER_API_WEBGPU
|
||||
clip(o_Alpha);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
#if !d_Crest_CustomMesh
|
||||
slice0 = _Crest_LodIndex;
|
||||
slice1 = _Crest_LodIndex + 1;
|
||||
alpha = i_LodAlpha;
|
||||
#endif
|
||||
|
||||
i_LodAlpha = alpha;
|
||||
|
||||
Fragment
|
||||
(
|
||||
m_Parameters,
|
||||
slice0,
|
||||
slice1,
|
||||
positionSS,
|
||||
underwater,
|
||||
sceneRawZ,
|
||||
negativeFog
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
#endif // SHADERGRAPH_PREVIEW
|
||||
|
||||
void Fragment_float(m_Properties)
|
||||
{
|
||||
#if SHADERGRAPH_PREVIEW
|
||||
o_Albedo = 0.0;
|
||||
o_NormalWS = half3(0.0, 1.0, 0.0);
|
||||
o_Specular = 0.0;
|
||||
@@ -844,10 +606,32 @@ void Fragment_float(m_Properties)
|
||||
o_Smoothness = 0.7;
|
||||
o_Occlusion = 1.0;
|
||||
o_Alpha = 1.0;
|
||||
|
||||
#if !SHADERGRAPH_PREVIEW
|
||||
m_Crest::Fragment(m_Parameters);
|
||||
#endif
|
||||
#else // SHADERGRAPH_PREVIEW
|
||||
m_Crest::Fragment
|
||||
(
|
||||
i_UndisplacedXZ,
|
||||
i_LodAlpha,
|
||||
i_WaterLevelOffset,
|
||||
i_WaterLevelDerivatives,
|
||||
i_Flow,
|
||||
i_ViewDirectionWS,
|
||||
i_Facing,
|
||||
i_SceneColor,
|
||||
i_SceneDepthRaw,
|
||||
i_ScreenPosition,
|
||||
i_ScreenPositionRaw,
|
||||
i_PositionWS,
|
||||
i_PositionVS,
|
||||
i_StaticLightMapUV,
|
||||
o_Albedo,
|
||||
o_NormalWS,
|
||||
o_Specular,
|
||||
o_Emission,
|
||||
o_Smoothness,
|
||||
o_Occlusion,
|
||||
o_Alpha
|
||||
);
|
||||
#endif // SHADERGRAPH_PREVIEW
|
||||
}
|
||||
|
||||
#undef m_Properties
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
// These are per cascade, set per chunk instance.
|
||||
CBUFFER_START(CrestChunkGeometryData)
|
||||
float _Crest_ChunkMeshScaleAlpha;
|
||||
float _Crest_ChunkMeshScaleAlphaSource;
|
||||
float _Crest_ChunkGeometryGridWidth;
|
||||
float _Crest_ChunkGeometryGridWidthSource;
|
||||
CBUFFER_END
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#ifndef d_WaveHarmonic_Crest_SurfaceKeywords
|
||||
#define d_WaveHarmonic_Crest_SurfaceKeywords
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Keywords.hlsl"
|
||||
|
||||
#define d_Crest_AlphaTest defined(_ALPHATEST_ON)
|
||||
#define d_Crest_MotionVectors defined(_TRANSPARENT_WRITES_MOTION_VEC)
|
||||
|
||||
#define d_Crest_CustomMesh defined(_CREST_CUSTOM_MESH)
|
||||
|
||||
#define d_Crest_CausticsForceDistortion CREST_CAUSTICS_FORCE_DISTORTION
|
||||
#define d_Crest_FoamBioluminescence CREST_FOAM_BIOLUMINESCENCE
|
||||
#define d_Crest_NormalMap CREST_NORMAL_MAPS
|
||||
#define d_Crest_SimpleTransparency CREST_SIMPLE_TRANSPARENCY
|
||||
#define d_Crest_PlanarReflections CREST_PLANAR_REFLECTIONS
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d4fdd4ba0e96485c93d748132deef6a
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,7 +5,6 @@
|
||||
#define CREST_WATER_NORMAL_H
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings.Crest.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Constants.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Texture.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Flow.hlsl"
|
||||
@@ -14,43 +13,12 @@
|
||||
#include "Packages/com.waveharmonic.crest.shifting-origin/Runtime/Shaders/ShiftingOrigin.hlsl"
|
||||
#endif
|
||||
|
||||
#if _CREST_CUSTOM_MESH
|
||||
float4 _Crest_NormalMapParameters[MAX_LOD_COUNT];
|
||||
#define _Crest_ChunkNormalMapParameters _Crest_NormalMapParameters[i_CascadeData._IndexI]
|
||||
#else
|
||||
// These are per cascade, set per chunk instance.
|
||||
float _Crest_ChunkFarNormalsWeight;
|
||||
float2 _Crest_ChunkNormalScrollSpeed;
|
||||
#define _Crest_ChunkNormalMapParameters float3(_Crest_ChunkNormalScrollSpeed, _Crest_ChunkFarNormalsWeight)
|
||||
#endif
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
// Limit how close to horizontal reflection ray can get, useful to avoid unsightly below-horizon reflections.
|
||||
half3 ApplyMinimumReflectionDirectionY
|
||||
(
|
||||
const half i_MinimumReflectionDirectionY,
|
||||
const half3 i_ViewDirectionWS,
|
||||
const half3 i_NormalWS
|
||||
)
|
||||
{
|
||||
half3 normal = i_NormalWS;
|
||||
|
||||
float3 refl = reflect(-i_ViewDirectionWS, normal);
|
||||
if (refl.y < i_MinimumReflectionDirectionY)
|
||||
{
|
||||
// Find the normal that keeps the reflection direction above the horizon. Compute
|
||||
// the reflection dir that does work, normalize it, and then normal is half vector
|
||||
// between this good reflection direction and view direction.
|
||||
float3 FL = refl;
|
||||
FL.y = i_MinimumReflectionDirectionY;
|
||||
FL = normalize(FL);
|
||||
normal = normalize(FL + i_ViewDirectionWS);
|
||||
}
|
||||
|
||||
return normal;
|
||||
}
|
||||
|
||||
half2 SampleNormalMaps
|
||||
(
|
||||
const TiledTexture i_NormalMap,
|
||||
@@ -67,24 +35,20 @@ half2 SampleNormalMaps
|
||||
worldXZUndisplaced -= ShiftingOriginOffset(i_NormalMap, i_CascadeData);
|
||||
#endif
|
||||
|
||||
const float3 parameters = _Crest_ChunkNormalMapParameters.xyz;
|
||||
const float2 speed = parameters.xy;
|
||||
const float farWeight = parameters.z;
|
||||
|
||||
const float2 v0 = float2(0.94, 0.34), v1 = float2(-0.85, -0.53);
|
||||
float scale = i_NormalMap._scale * i_CascadeData._Scale / 10.0;
|
||||
const float spdmulL = speed.x * i_NormalMap._speed;
|
||||
const float spdmulL = _Crest_ChunkNormalScrollSpeed.x * i_NormalMap._speed;
|
||||
half2 norm =
|
||||
UnpackNormal(i_NormalMap.Sample((worldXZUndisplaced + v0 * g_Crest_Time * spdmulL) / scale)).xy +
|
||||
UnpackNormal(i_NormalMap.Sample((worldXZUndisplaced + v1 * g_Crest_Time * spdmulL) / scale)).xy;
|
||||
|
||||
// blend in next higher scale of normals to obtain continuity
|
||||
const half nblend = i_LodAlpha * farWeight;
|
||||
const half nblend = i_LodAlpha * _Crest_ChunkFarNormalsWeight;
|
||||
if (nblend > 0.001)
|
||||
{
|
||||
// next lod level
|
||||
scale *= 2.0;
|
||||
const float spdmulH = speed.y * i_NormalMap._speed;
|
||||
const float spdmulH = _Crest_ChunkNormalScrollSpeed.y * i_NormalMap._speed;
|
||||
norm = lerp(norm,
|
||||
UnpackNormal(i_NormalMap.Sample((worldXZUndisplaced + v0 * g_Crest_Time * spdmulH) / scale)).xy +
|
||||
UnpackNormal(i_NormalMap.Sample((worldXZUndisplaced + v1 * g_Crest_Time * spdmulH) / scale)).xy,
|
||||
@@ -92,7 +56,7 @@ half2 SampleNormalMaps
|
||||
}
|
||||
|
||||
// approximate combine of normals. would be better if normals applied in local frame.
|
||||
return norm;
|
||||
return i_Strength * norm;
|
||||
}
|
||||
|
||||
half2 SampleNormalMaps
|
||||
@@ -122,41 +86,6 @@ half2 SampleNormalMaps
|
||||
) * i_Flow._Weight1;
|
||||
}
|
||||
|
||||
half NormalMapTurbulence
|
||||
(
|
||||
const half3 i_NormalWS,
|
||||
const half2 i_NormalMap,
|
||||
const half i_NormalMapStrength,
|
||||
const half i_Coverage,
|
||||
const half i_Strength,
|
||||
const half3 i_ViewDirectionWS,
|
||||
const half i_Determinant,
|
||||
const half i_WaterLevel,
|
||||
const float i_PixelZ,
|
||||
const half3 i_PrimaryLightDirection
|
||||
)
|
||||
{
|
||||
half strength = i_NormalMapStrength;
|
||||
|
||||
if (saturate(i_Coverage - i_Determinant) > 0)
|
||||
{
|
||||
// Add boosted normal map.
|
||||
half3 normal = i_NormalWS;
|
||||
normal.xz += i_NormalMap * i_Strength;
|
||||
normal = normalize(normal);
|
||||
|
||||
// Increase normal map strength only if "sparkle".
|
||||
if (dot(normal, normalize(i_ViewDirectionWS + i_PrimaryLightDirection)) >= 0.99)
|
||||
{
|
||||
// Height (100m) & distance (2m) cull. Looks odd up close and degrades up high.
|
||||
const half cull = max(saturate(abs(_WorldSpaceCameraPos.y - i_WaterLevel) * 0.01), 1.0 - saturate(i_PixelZ * 0.5));
|
||||
strength = lerp(i_Strength, strength, cull);
|
||||
}
|
||||
}
|
||||
|
||||
return strength;
|
||||
}
|
||||
|
||||
void WaterNormal
|
||||
(
|
||||
const float2 i_WaterLevelDerivatives,
|
||||
@@ -177,11 +106,22 @@ void WaterNormal
|
||||
return;
|
||||
}
|
||||
|
||||
io_NormalWS = ApplyMinimumReflectionDirectionY(i_MinimumReflectionDirectionY, i_ViewDirectionWS, io_NormalWS);
|
||||
// Limit how close to horizontal reflection ray can get, useful to avoid unsightly below-horizon reflections.
|
||||
{
|
||||
float3 refl = reflect(-i_ViewDirectionWS, io_NormalWS);
|
||||
if (refl.y < i_MinimumReflectionDirectionY)
|
||||
{
|
||||
// Find the normal that keeps the reflection direction above the horizon. Compute
|
||||
// the reflection dir that does work, normalize it, and then normal is half vector
|
||||
// between this good reflection direction and view direction.
|
||||
float3 FL = refl;
|
||||
FL.y = i_MinimumReflectionDirectionY;
|
||||
FL = normalize(FL);
|
||||
io_NormalWS = normalize(FL + i_ViewDirectionWS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,16 +6,10 @@
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Utility.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Helpers.hlsl"
|
||||
|
||||
float _Crest_ReflectionOverscan;
|
||||
float4 _Crest_ReflectionPositionNormal[2];
|
||||
float4x4 _Crest_ReflectionMatrixIVP[2];
|
||||
float4x4 _Crest_ReflectionMatrixV[2];
|
||||
Texture2DArray _Crest_ReflectionColorTexture;
|
||||
SamplerState sampler_Crest_ReflectionColorTexture;
|
||||
Texture2DArray _Crest_ReflectionDepthTexture;
|
||||
SamplerState sampler_Crest_ReflectionDepthTexture;
|
||||
Texture2DArray _Crest_ReflectionTexture;
|
||||
SamplerState sampler_Crest_ReflectionTexture;
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
@@ -26,8 +20,6 @@ half4 PlanarReflection
|
||||
const half i_Intensity,
|
||||
const half i_Smoothness,
|
||||
const half i_Roughness,
|
||||
const half i_MinimumReflectionDirectionY,
|
||||
const float i_SurfaceDepth,
|
||||
const half3 i_NormalWS,
|
||||
const half i_NormalStrength,
|
||||
const half3 i_ViewDirectionWS,
|
||||
@@ -35,18 +27,10 @@ half4 PlanarReflection
|
||||
const bool i_Underwater
|
||||
)
|
||||
{
|
||||
const uint slice = i_Underwater ? 1 : 0;
|
||||
|
||||
half3 planeNormal = half3(0.0, i_Underwater ? -1.0 : 1.0, 0.0);
|
||||
half3 reflected = reflect(-i_ViewDirectionWS, lerp(planeNormal, i_NormalWS, i_NormalStrength));
|
||||
reflected.y = -reflected.y;
|
||||
|
||||
// Limit how close to horizontal reflection ray can get, useful to avoid unsightly below-horizon reflections.
|
||||
if (!i_Underwater)
|
||||
{
|
||||
reflected = ApplyMinimumReflectionDirectionY(i_MinimumReflectionDirectionY, i_ViewDirectionWS, reflected);
|
||||
}
|
||||
|
||||
float4 positionCS = mul(UNITY_MATRIX_VP, half4(reflected, 0.0));
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
positionCS.y = -positionCS.y;
|
||||
@@ -54,39 +38,19 @@ half4 PlanarReflection
|
||||
|
||||
float2 positionNDC = positionCS.xy * rcp(positionCS.w) * 0.5 + 0.5;
|
||||
|
||||
// Overscan.
|
||||
positionNDC.xy -= 0.5;
|
||||
positionNDC.xy *= _Crest_ReflectionOverscan;
|
||||
positionNDC.xy += 0.5;
|
||||
|
||||
// Cancel out distortion if out of bounds. We could make this nicer by doing an edge fade but the improvement is
|
||||
// barely noticeable. Edge fade requires recalculating the above a second time.
|
||||
if (i_Underwater)
|
||||
{
|
||||
const float4 positionAndNormal = _Crest_ReflectionPositionNormal[slice];
|
||||
float4 positionAndNormal = _Crest_ReflectionPositionNormal[i_Underwater];
|
||||
if (dot(positionNDC - positionAndNormal.xy, positionAndNormal.zw) < 0.0)
|
||||
{
|
||||
float2 ndc = i_PositionNDC;
|
||||
ndc.xy -= 0.5;
|
||||
ndc.xy *= _Crest_ReflectionOverscan;
|
||||
ndc.xy += 0.5;
|
||||
|
||||
positionNDC = lerp(ndc, positionNDC, 0.25);
|
||||
positionNDC = lerp(i_PositionNDC, positionNDC, 0.25);
|
||||
}
|
||||
}
|
||||
|
||||
half4 reflection;
|
||||
|
||||
if (_Crest_PlanarReflectionsApplySmoothness)
|
||||
{
|
||||
const half roughness = PerceptualSmoothnessToPerceptualRoughness(i_Smoothness);
|
||||
half level = PerceptualRoughnessToMipmapLevel(roughness, i_Roughness);
|
||||
reflection = i_ReflectionsTexture.SampleLevel(sampler_Crest_ReflectionColorTexture, float3(positionNDC, i_Underwater), level);
|
||||
}
|
||||
else
|
||||
{
|
||||
reflection = i_ReflectionsTexture.SampleLevel(sampler_Crest_point_clamp, float3(positionNDC, i_Underwater), 0.0);
|
||||
}
|
||||
const half roughness = PerceptualSmoothnessToPerceptualRoughness(i_Smoothness);
|
||||
const half level = PerceptualRoughnessToMipmapLevel(roughness, i_Roughness);
|
||||
half4 reflection = i_ReflectionsTexture.SampleLevel(sampler_Crest_ReflectionTexture, float3(positionNDC, i_Underwater), level);
|
||||
|
||||
// If more than four layers are used on the terrain, they will appear black if HDR
|
||||
// is enabled on the planar reflection camera. Alpha is probably a negative value.
|
||||
@@ -94,21 +58,6 @@ half4 PlanarReflection
|
||||
|
||||
reflection.a *= i_Intensity;
|
||||
|
||||
// Mitigate leaks.
|
||||
{
|
||||
// TODO: calculate linear depth from device depth directly. First attempt failed.
|
||||
// Most effective when surface is smooth due to mip-maps. Surprisingly effective
|
||||
// even when rough.
|
||||
const float rRawDepth = _Crest_ReflectionDepthTexture.SampleLevel(sampler_Crest_ReflectionDepthTexture, float3(positionNDC, i_Underwater), 0).r;
|
||||
const float3 rPositionWS = Utility::SafeComputeWorldSpacePosition(positionNDC, rRawDepth, _Crest_ReflectionMatrixIVP[slice]);
|
||||
const float rDepth = LinearEyeDepth(rPositionWS, _Crest_ReflectionMatrixV[slice]);
|
||||
|
||||
if (rRawDepth > 0.0 && rDepth <= i_SurfaceDepth)
|
||||
{
|
||||
reflection.a = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
return reflection;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#ifndef CREST_WATER_REFRACTION_H
|
||||
#define CREST_WATER_REFRACTION_H
|
||||
|
||||
#if !d_Crest_SimpleTransparency
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings.Crest.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Depth.hlsl"
|
||||
@@ -20,144 +18,91 @@
|
||||
#define FoveatedRemapLinearToNonUniform(uv) uv
|
||||
#endif
|
||||
|
||||
#if (UNITY_VERSION < 60000000) || !defined(CREST_URP)
|
||||
float4 _CameraDepthTexture_TexelSize;
|
||||
#endif
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
float2 GetRefractionCoordinates(const half3 i_View, const half3 i_Normal, const float3 i_Position, const half i_IOR, const half i_Strength)
|
||||
{
|
||||
float3 position = i_Position;
|
||||
|
||||
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
||||
position -= _WorldSpaceCameraPos;
|
||||
#endif
|
||||
|
||||
const half3 ray = refract(-i_View, i_Normal, i_IOR) * i_Strength;
|
||||
float2 uv = ComputeNormalizedDeviceCoordinates(position + ray, UNITY_MATRIX_VP);
|
||||
|
||||
#if CREST_HDRP
|
||||
// Prevent artifacts at edge. Maybe because depth is an atlas for HDRP.
|
||||
uv = clamp(uv, _CameraDepthTexture_TexelSize.xy, 1.0 - _CameraDepthTexture_TexelSize.xy);
|
||||
#endif
|
||||
|
||||
return FoveatedRemapLinearToNonUniform(uv);
|
||||
}
|
||||
|
||||
// We take the unrefracted scene colour as input because having a Scene Colour node in the graph
|
||||
// appears to be necessary to ensure the scene colours are bound?
|
||||
void RefractedScene
|
||||
(
|
||||
const half i_RefractionStrength,
|
||||
const half i_AirIOR,
|
||||
const half i_WaterIOR,
|
||||
const half3 i_NormalWS,
|
||||
const float3 i_PositionWS,
|
||||
const float2 i_PositionNDC,
|
||||
const float4 i_ScreenPositionRaw,
|
||||
const float i_PixelZ,
|
||||
const half3 i_View,
|
||||
const half3 i_SceneColorUnrefracted,
|
||||
const float i_SceneZ,
|
||||
const float i_SceneZRaw,
|
||||
const float i_Scale,
|
||||
const float i_LodAlpha,
|
||||
const bool i_Underwater,
|
||||
const half i_TotalInternalReflectionIntensity,
|
||||
out half3 o_SceneColor,
|
||||
out float o_SceneDistance,
|
||||
out float3 o_ScenePositionWS,
|
||||
out float2 o_PositionSS,
|
||||
out bool o_Caustics
|
||||
)
|
||||
{
|
||||
float2 positionNDC = i_PositionNDC;
|
||||
float sceneDepthRaw = i_SceneZRaw;
|
||||
|
||||
o_Caustics = true;
|
||||
|
||||
half strength = i_RefractionStrength;
|
||||
|
||||
const half _AirToWaterRatio = i_AirIOR / i_WaterIOR;
|
||||
const half _WaterToAirRatio = i_WaterIOR / i_AirIOR;
|
||||
|
||||
// If no TIR, then use same IOR.
|
||||
const bool isA2WR = !i_Underwater || i_TotalInternalReflectionIntensity < 1.0;
|
||||
|
||||
const half eta = isA2WR ? _AirToWaterRatio : _WaterToAirRatio;
|
||||
|
||||
half3 normal = i_NormalWS;
|
||||
|
||||
// Exchanges accuracy for less artifacts.
|
||||
if (isA2WR)
|
||||
// View ray intersects geometry surface either above or below water surface.
|
||||
float2 refractOffset = i_RefractionStrength * i_NormalWS.xz;
|
||||
if (!i_Underwater)
|
||||
{
|
||||
half multiplier = 0.0;
|
||||
|
||||
if (i_Underwater)
|
||||
{
|
||||
multiplier = 1.0;
|
||||
// Max fade when water is 5m deep.
|
||||
multiplier = saturate(g_Crest_WaterDepthAtViewer * 0.2);
|
||||
// Max fade by displacement.
|
||||
multiplier *= saturate(g_Crest_MaximumVerticalDisplacement - 1.0);
|
||||
// Fade towards screen edge where off screen samples happen. + n is fade start.
|
||||
multiplier *= saturate((dot(i_PositionNDC - 0.5, -g_Crest_HorizonNormal) + 0.5) * 2.0);
|
||||
}
|
||||
|
||||
normal.y *= multiplier;
|
||||
// We're above the water, so behind interface is depth fog.
|
||||
refractOffset *= min(1.0, 0.5 * (i_SceneZ - i_PixelZ)) / i_SceneZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// When looking up through water, full strength ends up being quite intense so reduce it a bunch.
|
||||
refractOffset *= 0.3;
|
||||
}
|
||||
|
||||
// Since we lose detail at a distance, boosting refraction helps visually.
|
||||
strength *= lerp(i_Scale, i_Scale * 2.0, i_LodAlpha) * 0.25;
|
||||
// Blend at the edge of the screen to avoid artifacts.
|
||||
refractOffset *= 1.0 - EdgeBlendingFactor(positionNDC, i_PixelZ);
|
||||
|
||||
// Restrict to a reasonable maximum.
|
||||
strength = min(strength, i_RefractionStrength * 4.0);
|
||||
|
||||
float2 uv = GetRefractionCoordinates(i_View, normal, i_PositionWS, eta, strength);
|
||||
|
||||
o_PositionSS = min(uv * _ScreenSize.xy, _ScreenSize.xy - 1.0);
|
||||
|
||||
#if CREST_BIRP
|
||||
float deviceDepth = LoadSceneDepth(o_PositionSS);
|
||||
#else
|
||||
float deviceDepth = SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv);
|
||||
#endif
|
||||
const float2 positionNDCRefracted = FoveatedRemapLinearToNonUniform(positionNDC + refractOffset);
|
||||
float sceneDepthRawRefracted = SHADERGRAPH_SAMPLE_SCENE_DEPTH(positionNDCRefracted);
|
||||
|
||||
#if (CREST_PORTALS != 0)
|
||||
#if _ALPHATEST_ON
|
||||
Portal::EvaluateRefraction(uv, i_SceneZRaw, i_Underwater, deviceDepth, o_Caustics);
|
||||
// Portals
|
||||
Portal::EvaluateRefraction(positionNDCRefracted, i_SceneZRaw, i_Underwater, sceneDepthRawRefracted, o_Caustics);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float linearDepth = Utility::CrestLinearEyeDepth(deviceDepth);
|
||||
float depthDifference = linearDepth - i_PixelZ;
|
||||
|
||||
normal *= saturate(depthDifference);
|
||||
const float sceneZRefract = Utility::CrestLinearEyeDepth(sceneDepthRawRefracted);
|
||||
|
||||
uv = GetRefractionCoordinates(i_View, normal, i_PositionWS, eta, strength);
|
||||
// Depth fog & caustics - only if view ray starts from above water.
|
||||
// Compute depth fog alpha based on refracted position if it landed on an
|
||||
// underwater surface, or on unrefracted depth otherwise.
|
||||
if (sceneZRefract > i_PixelZ)
|
||||
{
|
||||
// Refracted.
|
||||
o_SceneDistance = sceneZRefract - i_PixelZ;
|
||||
o_SceneColor = SHADERGRAPH_SAMPLE_SCENE_COLOR(positionNDCRefracted);
|
||||
|
||||
o_PositionSS = min(uv * _ScreenSize.xy, _ScreenSize.xy - 1.0);
|
||||
positionNDC = positionNDCRefracted;
|
||||
sceneDepthRaw = sceneDepthRawRefracted;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unrefracted.
|
||||
// It seems that when MSAA is enabled this can sometimes be negative.
|
||||
o_SceneDistance = max(i_SceneZ - i_PixelZ, 0.0);
|
||||
o_SceneColor = i_SceneColorUnrefracted;
|
||||
|
||||
#if CREST_BIRP
|
||||
deviceDepth = LoadSceneDepth(o_PositionSS);
|
||||
#else
|
||||
deviceDepth = SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv);
|
||||
#endif
|
||||
// NOTE: Causes refraction artifact with caustics. Cannot remember exactly why this was added.
|
||||
// o_Caustics = false;
|
||||
positionNDC = FoveatedRemapLinearToNonUniform(positionNDC);
|
||||
}
|
||||
|
||||
linearDepth = Utility::CrestLinearEyeDepth(deviceDepth);
|
||||
// It seems that when MSAA is enabled this can sometimes be negative.
|
||||
depthDifference = max(linearDepth - i_PixelZ, 0.0);
|
||||
if (i_Underwater)
|
||||
{
|
||||
// Depth fog is handled by underwater shader.
|
||||
o_SceneDistance = i_PixelZ;
|
||||
}
|
||||
|
||||
#if CREST_BIRP
|
||||
// Sampling artifacts which manifest as a fine outline around refractions. Always
|
||||
// affects BIRP unless we use Load. Does not affect URP unless downsampling or MSAA
|
||||
// is used, but Load exposes us to RT scaling. Best to use Sample with HDRP too.
|
||||
o_SceneColor = LoadSceneColor(o_PositionSS).rgb;
|
||||
#else
|
||||
// Sampling artifacts if downsampling or MSAA used. Load does not help. And we get
|
||||
// outlines around all objects irrespective of refraction.
|
||||
o_SceneColor = SHADERGRAPH_SAMPLE_SCENE_COLOR(uv).rgb;
|
||||
#endif
|
||||
|
||||
o_SceneDistance = depthDifference;
|
||||
o_ScenePositionWS = ComputeWorldSpacePosition(uv, deviceDepth, UNITY_MATRIX_I_VP);
|
||||
o_ScenePositionWS = ComputeWorldSpacePosition(positionNDC, sceneDepthRaw, UNITY_MATRIX_I_VP);
|
||||
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
||||
o_ScenePositionWS += _WorldSpaceCameraPos;
|
||||
#endif
|
||||
@@ -166,4 +111,3 @@ void RefractedScene
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -58,8 +58,4 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(CREST_HDRP) && (SHADERPASS == SHADERPASS_MOTION_VECTORS)
|
||||
#define _TRANSPARENT_WRITES_MOTION_VEC
|
||||
#endif
|
||||
|
||||
#endif // CREST_SHADERGRAPH_CONSTANTS_H
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#ifndef SHADERGRAPH_PREVIEW
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Shim.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Keywords.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Globals.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/InputsDriven.hlsl"
|
||||
@@ -30,7 +29,13 @@
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Depth.hlsl"
|
||||
|
||||
#if d_Crest_MotionVectors
|
||||
#ifndef CREST_HDRP
|
||||
#if (SHADERPASS == SHADERPASS_MOTION_VECTORS)
|
||||
#define _TRANSPARENT_WRITES_MOTION_VEC 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if _TRANSPARENT_WRITES_MOTION_VEC
|
||||
#define m_Slice clamp((int)_Crest_LodIndex + (isMotionVectors ? g_Crest_LodChange : 0), 0, g_Crest_LodCount)
|
||||
#define m_Make(slice) Make(slice, isMotionVectors)
|
||||
#else
|
||||
@@ -45,14 +50,12 @@ void Vertex(m_Properties)
|
||||
// This will get called twice.
|
||||
// With current and previous time respectively.
|
||||
|
||||
o_PositionWS = i_PositionWS;
|
||||
o_UndisplacedXZ = i_PositionWS.xz;
|
||||
o_UndisplacedXZ = 0.0;
|
||||
o_LodAlpha = 0.0;
|
||||
o_WaterLevelOffset = 0.0;
|
||||
o_WaterLevelDerivatives = 0.0;
|
||||
o_Flow = 0.0;
|
||||
|
||||
#if !d_Crest_CustomMesh
|
||||
const bool isMotionVectors = i_Time < _Time.y;
|
||||
|
||||
const float slice0 = m_Slice;
|
||||
@@ -60,6 +63,8 @@ void Vertex(m_Properties)
|
||||
const Cascade cascade0 = Cascade::m_Make(slice0);
|
||||
const Cascade cascade1 = Cascade::m_Make(slice1);
|
||||
|
||||
o_PositionWS = i_PositionWS;
|
||||
|
||||
// Vertex snapping and LOD transition.
|
||||
SnapAndTransitionVertLayout
|
||||
(
|
||||
@@ -94,48 +99,48 @@ void Vertex(m_Properties)
|
||||
// Data that needs to be sampled at the undisplaced position.
|
||||
if (weight0 > m_CrestSampleLodThreshold)
|
||||
{
|
||||
#if d_Crest_MotionVectors
|
||||
#if _TRANSPARENT_WRITES_MOTION_VEC
|
||||
if (isMotionVectors)
|
||||
{
|
||||
Cascade::MakeAnimatedWavesSource(slice0).SampleDisplacement(o_UndisplacedXZ, weight0, o_PositionWS, o_WaterLevelDerivatives, o_WaterLevelOffset);
|
||||
Cascade::MakeAnimatedWavesSource(slice0).SampleDisplacement(o_UndisplacedXZ, weight0, o_PositionWS, o_WaterLevelDerivatives);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
Cascade::MakeAnimatedWaves(slice0).SampleDisplacement(o_UndisplacedXZ, weight0, o_PositionWS, o_WaterLevelDerivatives, o_WaterLevelOffset);
|
||||
Cascade::MakeAnimatedWaves(slice0).SampleDisplacement(o_UndisplacedXZ, weight0, o_PositionWS, o_WaterLevelDerivatives);
|
||||
}
|
||||
}
|
||||
|
||||
if (weight1 > m_CrestSampleLodThreshold)
|
||||
{
|
||||
#if d_Crest_MotionVectors
|
||||
#if _TRANSPARENT_WRITES_MOTION_VEC
|
||||
if (isMotionVectors)
|
||||
{
|
||||
Cascade::MakeAnimatedWavesSource(slice1).SampleDisplacement(o_UndisplacedXZ, weight1, o_PositionWS, o_WaterLevelDerivatives, o_WaterLevelOffset);
|
||||
Cascade::MakeAnimatedWavesSource(slice1).SampleDisplacement(o_UndisplacedXZ, weight1, o_PositionWS, o_WaterLevelDerivatives);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
Cascade::MakeAnimatedWaves(slice1).SampleDisplacement(o_UndisplacedXZ, weight1, o_PositionWS, o_WaterLevelDerivatives, o_WaterLevelOffset);
|
||||
Cascade::MakeAnimatedWaves(slice1).SampleDisplacement(o_UndisplacedXZ, weight1, o_PositionWS, o_WaterLevelDerivatives);
|
||||
}
|
||||
}
|
||||
|
||||
// Data that needs to be sampled at the displaced position.
|
||||
if (weight0 > m_CrestSampleLodThreshold)
|
||||
{
|
||||
#if d_Crest_FlowLod
|
||||
#if CREST_FLOW_ON
|
||||
Cascade::MakeFlow(slice0).SampleFlow(o_UndisplacedXZ, weight0, o_Flow);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (weight1 > m_CrestSampleLodThreshold)
|
||||
{
|
||||
#if d_Crest_FlowLod
|
||||
#if CREST_FLOW_ON
|
||||
Cascade::MakeFlow(slice1).SampleFlow(o_UndisplacedXZ, weight1, o_Flow);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if d_Crest_MotionVectors
|
||||
#if _TRANSPARENT_WRITES_MOTION_VEC
|
||||
if (isMotionVectors)
|
||||
{
|
||||
o_PositionWS.xz -= g_Crest_WaterCenter.xz;
|
||||
@@ -144,7 +149,6 @@ void Vertex(m_Properties)
|
||||
o_PositionWS.xz += g_Crest_WaterCenterDelta;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
|
||||
@@ -179,62 +179,11 @@
|
||||
},
|
||||
{
|
||||
"m_Id": "e4a54526c6204b5badd66e158dcf0b1d"
|
||||
},
|
||||
{
|
||||
"m_Id": "eb89085b4d7c46c7bf82f63a3b43a0c6"
|
||||
},
|
||||
{
|
||||
"m_Id": "a12a11f74d174f1d8a63d18ee8743b25"
|
||||
},
|
||||
{
|
||||
"m_Id": "9f311e65704646e48b52019d389d3cd0"
|
||||
},
|
||||
{
|
||||
"m_Id": "d209a2766f5546688fe4bc92416cd548"
|
||||
},
|
||||
{
|
||||
"m_Id": "8ec616eaa4964d38b92b904775e34f7e"
|
||||
},
|
||||
{
|
||||
"m_Id": "feb1793feb264a239de366d730977489"
|
||||
},
|
||||
{
|
||||
"m_Id": "cc11871fc2f74ea2821e2c9f78d3d58e"
|
||||
},
|
||||
{
|
||||
"m_Id": "a485464528a74269852b53d441f1f0a8"
|
||||
},
|
||||
{
|
||||
"m_Id": "bc35f605d4fc49869c24479f827fbfa8"
|
||||
},
|
||||
{
|
||||
"m_Id": "dd752976323845b0aad610adb0672e38"
|
||||
},
|
||||
{
|
||||
"m_Id": "8c45cfde06fb4d5ca12db7bcfa8f6316"
|
||||
},
|
||||
{
|
||||
"m_Id": "30ad385314c946f5a3cbd7adefe9c270"
|
||||
},
|
||||
{
|
||||
"m_Id": "c06c8782d1b742d189925deba54c21bc"
|
||||
},
|
||||
{
|
||||
"m_Id": "38e9cee298f8483e8ca80e75574c2175"
|
||||
},
|
||||
{
|
||||
"m_Id": "4a21e5afa49f40d38aef98a49226fa6e"
|
||||
},
|
||||
{
|
||||
"m_Id": "a6704108884e487799aa5f653566e56b"
|
||||
}
|
||||
],
|
||||
"m_Keywords": [
|
||||
{
|
||||
"m_Id": "b91141f3e4cf4131ab732e6ae5828231"
|
||||
},
|
||||
{
|
||||
"m_Id": "ada9e52f38cd4e66a4e97c1fd2a5bd65"
|
||||
}
|
||||
],
|
||||
"m_Dropdowns": [],
|
||||
@@ -254,12 +203,6 @@
|
||||
{
|
||||
"m_Id": "9475b0c108bc456eb09f35111542022b"
|
||||
},
|
||||
{
|
||||
"m_Id": "72dfddd5562c42e4bf73f41a47cd4863"
|
||||
},
|
||||
{
|
||||
"m_Id": "0c1d5d0d16af4922b19d366983ea194e"
|
||||
},
|
||||
{
|
||||
"m_Id": "330cb63ecb704ddebac4935cb0b85ab7"
|
||||
},
|
||||
@@ -269,9 +212,6 @@
|
||||
{
|
||||
"m_Id": "76dfbf9d02da4e2b9a7cffa11a17b81d"
|
||||
},
|
||||
{
|
||||
"m_Id": "475b6b25b79b44d19bf94d0af92bc9a1"
|
||||
},
|
||||
{
|
||||
"m_Id": "76a4c02b522d4e1d84eca095e84b1f30"
|
||||
},
|
||||
@@ -280,9 +220,6 @@
|
||||
},
|
||||
{
|
||||
"m_Id": "d65753c4eac547c5a73c35da6956d9e2"
|
||||
},
|
||||
{
|
||||
"m_Id": "9125a3c8387e4d38987cc5707394b95b"
|
||||
}
|
||||
],
|
||||
"m_Nodes": [
|
||||
@@ -913,15 +850,15 @@
|
||||
{
|
||||
"m_Id": "b7891fe7e5a34f03adebd8a45505c5fc"
|
||||
},
|
||||
{
|
||||
"m_Id": "8e8aee51883445f1b08bfbec696cb18d"
|
||||
},
|
||||
{
|
||||
"m_Id": "e207931e020242bba83058a59f3fb07d"
|
||||
},
|
||||
{
|
||||
"m_Id": "01717f91918a4191a16ca9eb0a394f85"
|
||||
},
|
||||
{
|
||||
"m_Id": "8e8aee51883445f1b08bfbec696cb18d"
|
||||
},
|
||||
{
|
||||
"m_Id": "641a42645cc2483bb33d553093357479"
|
||||
},
|
||||
@@ -1273,30 +1210,6 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
|
||||
"m_ObjectId": "0c1d5d0d16af4922b19d366983ea194e",
|
||||
"m_Name": "Reflections (Planar)",
|
||||
"m_ChildObjectList": [
|
||||
{
|
||||
"m_Id": "d6af4ca8280b4d56b6f2bf1c8b7a0bbd"
|
||||
},
|
||||
{
|
||||
"m_Id": "2d31998b356d41179aa5291dcedc7850"
|
||||
},
|
||||
{
|
||||
"m_Id": "eb89085b4d7c46c7bf82f63a3b43a0c6"
|
||||
},
|
||||
{
|
||||
"m_Id": "0d81099c729342968bf4ee002d378dcf"
|
||||
},
|
||||
{
|
||||
"m_Id": "e632a014145542d8a0f6bad7aac6cb63"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
|
||||
@@ -1971,29 +1884,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.BooleanShaderProperty",
|
||||
"m_ObjectId": "30ad385314c946f5a3cbd7adefe9c270",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "23c5d086-28d3-4f64-a7c7-b7bec078341f"
|
||||
},
|
||||
"m_Name": "Foam Bioluminescence Enabled",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Foam Bioluminescence Enabled",
|
||||
"m_DefaultReferenceName": "_Foam_Bioluminescence_Enabled",
|
||||
"m_OverrideReferenceName": "_Crest_FoamBioluminescenceEnabled",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": false
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
|
||||
@@ -2002,6 +1892,12 @@
|
||||
"m_ChildObjectList": [
|
||||
{
|
||||
"m_Id": "14f5135a4bf8f5868cb55001b6472657"
|
||||
},
|
||||
{
|
||||
"m_Id": "bbd2579dfd7f38879fab18706b09b5fb"
|
||||
},
|
||||
{
|
||||
"m_Id": "d33c23a144f9400888ebc0b17741ceea"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2027,34 +1923,6 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
"m_ObjectId": "38e9cee298f8483e8ca80e75574c2175",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "eb0230f0-4d3b-4348-b7af-d0c613693fbe"
|
||||
},
|
||||
"m_Name": "Foam Bioluminescence Intensity",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Foam Bioluminescence Intensity",
|
||||
"m_DefaultReferenceName": "_Foam_Bioluminescence_Intensity",
|
||||
"m_OverrideReferenceName": "_Crest_FoamBioluminescenceIntensity",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": 1.0,
|
||||
"m_FloatType": 0,
|
||||
"m_RangeValues": {
|
||||
"x": 0.0,
|
||||
"y": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
@@ -2093,15 +1961,6 @@
|
||||
},
|
||||
{
|
||||
"m_Id": "e608dd8f43794f5d8b3995446b21467f"
|
||||
},
|
||||
{
|
||||
"m_Id": "a12a11f74d174f1d8a63d18ee8743b25"
|
||||
},
|
||||
{
|
||||
"m_Id": "9f311e65704646e48b52019d389d3cd0"
|
||||
},
|
||||
{
|
||||
"m_Id": "d209a2766f5546688fe4bc92416cd548"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2379,45 +2238,6 @@
|
||||
"m_PositionSource": 0
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
|
||||
"m_ObjectId": "475b6b25b79b44d19bf94d0af92bc9a1",
|
||||
"m_Name": "Bioluminescence",
|
||||
"m_ChildObjectList": [
|
||||
{
|
||||
"m_Id": "30ad385314c946f5a3cbd7adefe9c270"
|
||||
},
|
||||
{
|
||||
"m_Id": "feb1793feb264a239de366d730977489"
|
||||
},
|
||||
{
|
||||
"m_Id": "38e9cee298f8483e8ca80e75574c2175"
|
||||
},
|
||||
{
|
||||
"m_Id": "8c45cfde06fb4d5ca12db7bcfa8f6316"
|
||||
},
|
||||
{
|
||||
"m_Id": "4a21e5afa49f40d38aef98a49226fa6e"
|
||||
},
|
||||
{
|
||||
"m_Id": "cc11871fc2f74ea2821e2c9f78d3d58e"
|
||||
},
|
||||
{
|
||||
"m_Id": "c06c8782d1b742d189925deba54c21bc"
|
||||
},
|
||||
{
|
||||
"m_Id": "dd752976323845b0aad610adb0672e38"
|
||||
},
|
||||
{
|
||||
"m_Id": "a485464528a74269852b53d441f1f0a8"
|
||||
},
|
||||
{
|
||||
"m_Id": "bc35f605d4fc49869c24479f827fbfa8"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
|
||||
@@ -2464,29 +2284,6 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.BooleanShaderProperty",
|
||||
"m_ObjectId": "4a21e5afa49f40d38aef98a49226fa6e",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "b17934e1-f74e-4c4b-8313-3f5274067918"
|
||||
},
|
||||
"m_Name": "Foam Bioluminescence Sea Level Only",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Foam Bioluminescence Sea Level Only",
|
||||
"m_DefaultReferenceName": "_Foam_Bioluminescence_Sea_Level_Only",
|
||||
"m_OverrideReferenceName": "_Crest_FoamBioluminescenceSeaLevelOnly",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": true
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
@@ -3571,7 +3368,7 @@
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": 0.0,
|
||||
"m_Value": 0.03,
|
||||
"m_FloatType": 1,
|
||||
"m_RangeValues": {
|
||||
"x": -1.0,
|
||||
@@ -3602,24 +3399,6 @@
|
||||
"m_Value": false
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
|
||||
"m_ObjectId": "72dfddd5562c42e4bf73f41a47cd4863",
|
||||
"m_Name": "Reflections (Underwater)",
|
||||
"m_ChildObjectList": [
|
||||
{
|
||||
"m_Id": "21db17a76f094b19ba523148b6f7aa41"
|
||||
},
|
||||
{
|
||||
"m_Id": "bbd2579dfd7f38879fab18706b09b5fb"
|
||||
},
|
||||
{
|
||||
"m_Id": "d33c23a144f9400888ebc0b17741ceea"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
@@ -3665,9 +3444,6 @@
|
||||
{
|
||||
"m_Id": "91e9a577d315a3848dfb1f48a6743f9c"
|
||||
},
|
||||
{
|
||||
"m_Id": "a6704108884e487799aa5f653566e56b"
|
||||
},
|
||||
{
|
||||
"m_Id": "4b09daebd022cf89bc77ad473c95586c"
|
||||
},
|
||||
@@ -4220,34 +3996,6 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
"m_ObjectId": "8c45cfde06fb4d5ca12db7bcfa8f6316",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "c201c2da-d89e-4a7b-bc1f-358cac6ea74e"
|
||||
},
|
||||
"m_Name": "Foam Bioluminescence Maximum Depth",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Foam Bioluminescence Maximum Depth",
|
||||
"m_DefaultReferenceName": "_Foam_Bioluminescence_Maximum_Depth",
|
||||
"m_OverrideReferenceName": "_Crest_FoamBioluminescenceMaximumDepth",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": Infinity,
|
||||
"m_FloatType": 0,
|
||||
"m_RangeValues": {
|
||||
"x": 0.0,
|
||||
"y": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
|
||||
@@ -4305,34 +4053,6 @@
|
||||
"m_SerializedDescriptor": "SurfaceDescription.Metallic"
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
"m_ObjectId": "8ec616eaa4964d38b92b904775e34f7e",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "025be3df-ddb1-4553-894c-4cbcafe64fda"
|
||||
},
|
||||
"m_Name": "Transparency Minimum Alpha",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Transparency Minimum Alpha",
|
||||
"m_DefaultReferenceName": "_Transparency_Minimum_Alpha",
|
||||
"m_OverrideReferenceName": "_Crest_TransparencyMinimumAlpha",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": 0.95,
|
||||
"m_FloatType": 1,
|
||||
"m_RangeValues": {
|
||||
"x": 0.0,
|
||||
"y": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
|
||||
@@ -4388,18 +4108,6 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
|
||||
"m_ObjectId": "9125a3c8387e4d38987cc5707394b95b",
|
||||
"m_Name": "Simple Transparency",
|
||||
"m_ChildObjectList": [
|
||||
{
|
||||
"m_Id": "8ec616eaa4964d38b92b904775e34f7e"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot",
|
||||
@@ -4535,6 +4243,9 @@
|
||||
{
|
||||
"m_Id": "c700bce5ef10cf8e9e5b69ba043d383b"
|
||||
},
|
||||
{
|
||||
"m_Id": "21db17a76f094b19ba523148b6f7aa41"
|
||||
},
|
||||
{
|
||||
"m_Id": "7b2f0f23d232ab88bcacd3e88392015a"
|
||||
},
|
||||
@@ -4549,6 +4260,18 @@
|
||||
},
|
||||
{
|
||||
"m_Id": "71f6994de656018baa684da1128e623c"
|
||||
},
|
||||
{
|
||||
"m_Id": "d6af4ca8280b4d56b6f2bf1c8b7a0bbd"
|
||||
},
|
||||
{
|
||||
"m_Id": "2d31998b356d41179aa5291dcedc7850"
|
||||
},
|
||||
{
|
||||
"m_Id": "0d81099c729342968bf4ee002d378dcf"
|
||||
},
|
||||
{
|
||||
"m_Id": "e632a014145542d8a0f6bad7aac6cb63"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -4724,34 +4447,6 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
"m_ObjectId": "9f311e65704646e48b52019d389d3cd0",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "04aa688a-8387-4eda-bda1-edead599c4f0"
|
||||
},
|
||||
"m_Name": "Normal Map Turbulence Strength",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Normal Map Turbulence Strength",
|
||||
"m_DefaultReferenceName": "_Normal_Map_Turbulence_Strength",
|
||||
"m_OverrideReferenceName": "_Crest_NormalMapTurbulenceStrength",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": 0.6,
|
||||
"m_FloatType": 1,
|
||||
"m_RangeValues": {
|
||||
"x": 0.0,
|
||||
"y": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Texture2DShaderProperty",
|
||||
@@ -4782,29 +4477,6 @@
|
||||
"m_DefaultType": 0
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.BooleanShaderProperty",
|
||||
"m_ObjectId": "a12a11f74d174f1d8a63d18ee8743b25",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "709317fe-af13-425b-90cf-63507779f13c"
|
||||
},
|
||||
"m_Name": "Normal Map Turbulence Enabled",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Normal Map Turbulence Enabled",
|
||||
"m_DefaultReferenceName": "_Normal_Map_Turbulence_Enabled",
|
||||
"m_OverrideReferenceName": "_Crest_NormalMapTurbulenceEnabled",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": true
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
@@ -4930,34 +4602,6 @@
|
||||
"m_FunctionBody": "Enter function body here..."
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
"m_ObjectId": "a485464528a74269852b53d441f1f0a8",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "dbd6fa2d-e2ba-4ea9-b67c-e21877462ec6"
|
||||
},
|
||||
"m_Name": "Foam Bioluminescence Sparkles Intensity",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Foam Bioluminescence Sparkles Intensity",
|
||||
"m_DefaultReferenceName": "_Foam_Bioluminescence_Sparkles_Intensity",
|
||||
"m_OverrideReferenceName": "_Crest_FoamBioluminescenceSparklesIntensity",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": 500.0,
|
||||
"m_FloatType": 0,
|
||||
"m_RangeValues": {
|
||||
"x": 0.0,
|
||||
"y": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 2,
|
||||
"m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalLitSubTarget",
|
||||
@@ -5026,29 +4670,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.BooleanShaderProperty",
|
||||
"m_ObjectId": "a6704108884e487799aa5f653566e56b",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "c4fdecae-cdbb-4529-8ad0-3ef2226477a5"
|
||||
},
|
||||
"m_Name": "Caustics Force Distortion",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Caustics Force Distortion",
|
||||
"m_DefaultReferenceName": "_Caustics_Force_Distortion",
|
||||
"m_OverrideReferenceName": "_Crest_CausticsForceDistortion",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": false
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.ViewDirectionNode",
|
||||
@@ -5188,9 +4809,6 @@
|
||||
},
|
||||
{
|
||||
"m_Id": "aa75e7087fa330809fdc753edcd8995b"
|
||||
},
|
||||
{
|
||||
"m_Id": "ada9e52f38cd4e66a4e97c1fd2a5bd65"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -5261,31 +4879,6 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.ShaderKeyword",
|
||||
"m_ObjectId": "ada9e52f38cd4e66a4e97c1fd2a5bd65",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "787edb3a-324f-493b-b3da-febad061005c"
|
||||
},
|
||||
"m_Name": "Custom Mesh",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Custom Mesh",
|
||||
"m_DefaultReferenceName": "_CUSTOM_MESH",
|
||||
"m_OverrideReferenceName": "_CREST_CUSTOM_MESH",
|
||||
"m_GeneratePropertyBlock": false,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_KeywordType": 0,
|
||||
"m_KeywordDefinition": 1,
|
||||
"m_KeywordScope": 0,
|
||||
"m_KeywordStages": 63,
|
||||
"m_Entries": [],
|
||||
"m_Value": 0,
|
||||
"m_IsEditable": true
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot",
|
||||
@@ -5450,7 +5043,7 @@
|
||||
"m_DefaultRefNameVersion": 0,
|
||||
"m_RefNameGeneratedByDisplayName": "",
|
||||
"m_DefaultReferenceName": "BOOLEAN_547DED44_ON",
|
||||
"m_OverrideReferenceName": "_CREST_FLOW_LOD",
|
||||
"m_OverrideReferenceName": "CREST_FLOW_ON",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
@@ -5547,34 +5140,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
"m_ObjectId": "bc35f605d4fc49869c24479f827fbfa8",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "be221cdb-d9a6-46a9-8e5c-899bb77b9ba5"
|
||||
},
|
||||
"m_Name": "Foam Bioluminescence Sparkles Coverage",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Foam Bioluminescence Sparkles Coverage",
|
||||
"m_DefaultReferenceName": "_Foam_Bioluminescence_Sparkles_Coverage",
|
||||
"m_OverrideReferenceName": "_Crest_FoamBioluminescenceSparklesCoverage",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": 0.5,
|
||||
"m_FloatType": 1,
|
||||
"m_RangeValues": {
|
||||
"x": 0.0,
|
||||
"y": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.BooleanShaderProperty",
|
||||
@@ -5626,34 +5191,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
"m_ObjectId": "c06c8782d1b742d189925deba54c21bc",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "ed5634bc-281c-4def-8a6e-9956331f4a20"
|
||||
},
|
||||
"m_Name": "Foam Bioluminescence Glow Coverage",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Foam Bioluminescence Glow Coverage",
|
||||
"m_DefaultReferenceName": "_Foam_Bioluminescence_Glow_Coverage",
|
||||
"m_OverrideReferenceName": "_Crest_FoamBioluminescenceGlowCoverage",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": 0.4,
|
||||
"m_FloatType": 1,
|
||||
"m_RangeValues": {
|
||||
"x": 0.0,
|
||||
"y": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
|
||||
@@ -5807,34 +5344,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
"m_ObjectId": "cc11871fc2f74ea2821e2c9f78d3d58e",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "db78df35-c8ae-45f7-b19b-6873133e270d"
|
||||
},
|
||||
"m_Name": "Foam Bioluminescence Glow Intensity",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Foam Bioluminescence Glow Intensity",
|
||||
"m_DefaultReferenceName": "_Foam_Bioluminescence_Glow_Intensity",
|
||||
"m_OverrideReferenceName": "_Crest_FoamBioluminescenceGlowIntensity",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": 0.7,
|
||||
"m_FloatType": 1,
|
||||
"m_RangeValues": {
|
||||
"x": 0.0,
|
||||
"y": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.ObjectNode",
|
||||
@@ -5997,34 +5506,6 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
"m_ObjectId": "d209a2766f5546688fe4bc92416cd548",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "187a910c-bd28-405b-b1e4-f495ca40e9f9"
|
||||
},
|
||||
"m_Name": "Normal Map Turbulence Coverage",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Normal Map Turbulence Coverage",
|
||||
"m_DefaultReferenceName": "_Normal_Map_Turbulence_Coverage",
|
||||
"m_OverrideReferenceName": "_Crest_NormalMapTurbulenceCoverage",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": 0.8999999761581421,
|
||||
"m_FloatType": 1,
|
||||
"m_RangeValues": {
|
||||
"x": 0.0,
|
||||
"y": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
|
||||
@@ -6357,29 +5838,6 @@
|
||||
"m_DefaultValue": true
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.BooleanShaderProperty",
|
||||
"m_ObjectId": "dd752976323845b0aad610adb0672e38",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "4f72390b-2958-4755-9633-fdce875f1c0e"
|
||||
},
|
||||
"m_Name": "Foam Bioluminescence Sparkles Enabled",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Foam Bioluminescence Sparkles Enabled",
|
||||
"m_DefaultReferenceName": "_Foam_Bioluminescence_Sparkles_Enabled",
|
||||
"m_OverrideReferenceName": "_Crest_FoamBioluminescenceSparklesEnabled",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": true
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
@@ -6575,29 +6033,6 @@
|
||||
"m_Space": 2
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.BooleanShaderProperty",
|
||||
"m_ObjectId": "eb89085b4d7c46c7bf82f63a3b43a0c6",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "bdc2d1fe-238b-4105-83e0-87f8ef392283"
|
||||
},
|
||||
"m_Name": "Planar Reflections Apply Smoothness",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Planar Reflections Apply Smoothness",
|
||||
"m_DefaultReferenceName": "_Planar_Reflections_Apply_Smoothness",
|
||||
"m_OverrideReferenceName": "_Crest_PlanarReflectionsApplySmoothness",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": false
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot",
|
||||
@@ -6910,36 +6345,6 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 3,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.ColorShaderProperty",
|
||||
"m_ObjectId": "feb1793feb264a239de366d730977489",
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "87224bff-8cf6-4adb-83d2-8ec6ed30c979"
|
||||
},
|
||||
"m_Name": "Foam Bioluminescence Color",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "Foam Bioluminescence Color",
|
||||
"m_DefaultReferenceName": "_Foam_Bioluminescence_Color",
|
||||
"m_OverrideReferenceName": "_Crest_FoamBioluminescenceColor",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
"m_CustomSlotLabel": "",
|
||||
"m_DismissedVersion": 0,
|
||||
"m_Precision": 0,
|
||||
"overrideHLSLDeclaration": false,
|
||||
"hlslDeclarationOverride": 0,
|
||||
"m_Hidden": false,
|
||||
"m_Value": {
|
||||
"r": 0.0,
|
||||
"g": 1.55,
|
||||
"b": 6.0,
|
||||
"a": 1.0
|
||||
},
|
||||
"isMainColor": false,
|
||||
"m_ColorMode": 1
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 1,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestAdd
|
||||
|
||||
#pragma multi_compile_local d_Float1 d_Float2 d_Float3 d_Float4
|
||||
|
||||
#if d_Float1
|
||||
#define m_Type float
|
||||
#elif d_Float2
|
||||
#define m_Type float2
|
||||
#elif d_Float3
|
||||
#define m_Type float3
|
||||
#elif d_Float4
|
||||
#define m_Type float4
|
||||
#endif
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Macros.hlsl"
|
||||
|
||||
Texture2DArray<m_Type> _Crest_Source;
|
||||
RWTexture2DArray<m_Type> _Crest_Target;
|
||||
|
||||
m_UtilityNameSpace
|
||||
|
||||
void Add(uint3 id)
|
||||
{
|
||||
_Crest_Target[id] += _Crest_Source[id];
|
||||
}
|
||||
|
||||
m_UtilityNameSpaceEnd
|
||||
|
||||
m_UtilityKernelDefault(Add)
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d18c1734c0d4d4e7b9a09a5da1ad1b2c
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,63 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel BlurHorizontal
|
||||
#pragma kernel BlurVertical
|
||||
|
||||
#pragma multi_compile_local d_Float1 d_Float2 d_Float3 d_Float4
|
||||
|
||||
#if d_Float1
|
||||
#define m_Type float
|
||||
#elif d_Float2
|
||||
#define m_Type float2
|
||||
#elif d_Float3
|
||||
#define m_Type float3
|
||||
#elif d_Float4
|
||||
#define m_Type float4
|
||||
#endif
|
||||
|
||||
Texture2DArray<m_Type> _Crest_Source;
|
||||
RWTexture2DArray<m_Type> _Crest_Target;
|
||||
|
||||
// (width, height, slices)
|
||||
uint _Crest_Resolution;
|
||||
|
||||
// 5-tap Gaussian (sigma ≈ 1)
|
||||
static const float w0 = 0.4026;
|
||||
static const float w1 = 0.2442;
|
||||
static const float w2 = 0.0545;
|
||||
|
||||
uint2 ClampXY(uint2 p)
|
||||
{
|
||||
return clamp(p, 0, _Crest_Resolution - 1);
|
||||
}
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void BlurHorizontal(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
const int3 p = int3(id.x, id.y, id.z);
|
||||
const int2 xy = p.xy;
|
||||
|
||||
_Crest_Target[p] =
|
||||
_Crest_Source[id] * w0 +
|
||||
_Crest_Source[uint3(ClampXY(xy + int2( 1, 0)), p.z)] * w1 +
|
||||
_Crest_Source[uint3(ClampXY(xy + int2(-1, 0)), p.z)] * w1 +
|
||||
_Crest_Source[uint3(ClampXY(xy + int2( 2, 0)), p.z)] * w2 +
|
||||
_Crest_Source[uint3(ClampXY(xy + int2(-2, 0)), p.z)] * w2;
|
||||
}
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void BlurVertical(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
const int3 p = int3(id.x, id.y, id.z);
|
||||
const int2 xy = p.xy;
|
||||
|
||||
_Crest_Target[p] =
|
||||
_Crest_Source[id] * w0 +
|
||||
_Crest_Source[uint3(ClampXY(xy + int2(0, 1)), p.z)] * w1 +
|
||||
_Crest_Source[uint3(ClampXY(xy + int2(0, -1)), p.z)] * w1 +
|
||||
_Crest_Source[uint3(ClampXY(xy + int2(0, 2)), p.z)] * w2 +
|
||||
_Crest_Source[uint3(ClampXY(xy + int2(0, -2)), p.z)] * w2;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a49c73b133c743caa1d82459943eabf
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,33 +3,19 @@
|
||||
|
||||
// Clear specific components using a mask.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestClearTarget
|
||||
#pragma kernel CrestClearTargetBoundaryX d_BoundaryX
|
||||
#pragma kernel CrestClearTargetBoundaryY d_BoundaryY
|
||||
|
||||
#pragma multi_compile_local d_Float1 d_Float2 d_Float3 d_Float4
|
||||
|
||||
#if d_Float1
|
||||
#define m_Type float
|
||||
#elif d_Float2
|
||||
#define m_Type float2
|
||||
#elif d_Float3
|
||||
#define m_Type float3
|
||||
#elif d_Float4
|
||||
#define m_Type float4
|
||||
#endif
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Macros.hlsl"
|
||||
|
||||
RWTexture2DArray<m_Type> _Crest_Target;
|
||||
RWTexture2DArray<float4> _Crest_Target;
|
||||
|
||||
CBUFFER_START(CrestPerMaterial)
|
||||
m_Type _Crest_ClearMask;
|
||||
m_Type _Crest_ClearColor;
|
||||
float4 _Crest_ClearMask;
|
||||
float4 _Crest_ClearColor;
|
||||
uint _Crest_Resolution;
|
||||
uint _Crest_TargetSlice;
|
||||
CBUFFER_END
|
||||
|
||||
@@ -31,8 +31,13 @@
|
||||
m_CrestNameSpace
|
||||
|
||||
static bool s_IsUnderWater;
|
||||
static half3 s_VolumeOpacity;
|
||||
static half3 s_VolumeLighting;
|
||||
static float s_FogDistance;
|
||||
static half s_FogMultiplier;
|
||||
|
||||
static float2 s_PositionSS;
|
||||
static float3 s_PositionWS;
|
||||
static half3 s_ViewWS;
|
||||
static float s_DepthRaw;
|
||||
|
||||
float3 ApplyFog(float3 color)
|
||||
{
|
||||
@@ -41,11 +46,22 @@ float3 ApplyFog(float3 color)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return lerp(color, s_VolumeLighting, s_VolumeOpacity * (s_IsUnderWater ? 1.0 : 0.0));
|
||||
}
|
||||
|
||||
return ApplyUnderwaterEffect
|
||||
(
|
||||
color,
|
||||
s_DepthRaw,
|
||||
0, // Caustics only
|
||||
s_FogDistance,
|
||||
s_ViewWS,
|
||||
s_PositionSS,
|
||||
s_PositionWS,
|
||||
false, // No caustics
|
||||
true, // TODO: implement
|
||||
true, // TODO: implement
|
||||
s_FogMultiplier
|
||||
);
|
||||
}
|
||||
|
||||
float3 NoFog(float3 color)
|
||||
@@ -106,23 +122,12 @@ void SetUpFog(const float2 i_PositionNDC, const float3 i_PositionWS, const float
|
||||
}
|
||||
|
||||
s_IsUnderWater = true;
|
||||
|
||||
ApplyUnderwaterEffect
|
||||
(
|
||||
0, // Color
|
||||
0, // TIR only
|
||||
0, // Caustics only
|
||||
fogDistance,
|
||||
GetWorldSpaceNormalizeViewDir(i_PositionWS),
|
||||
positionSS,
|
||||
i_PositionWS,
|
||||
false, // No caustics
|
||||
true, // TODO: implement
|
||||
true, // TODO: implement
|
||||
i_Multiplier,
|
||||
s_VolumeOpacity,
|
||||
s_VolumeLighting
|
||||
);
|
||||
s_PositionSS = positionSS;
|
||||
s_PositionWS = i_PositionWS;
|
||||
s_ViewWS = GetWorldSpaceNormalizeViewDir(i_PositionWS);
|
||||
s_FogDistance = fogDistance;
|
||||
s_DepthRaw = i_DepthRaw;
|
||||
s_FogMultiplier = i_Multiplier;
|
||||
}
|
||||
|
||||
m_CrestNameSpaceEnd
|
||||
@@ -211,11 +216,6 @@ void CrestNodeIntegrateWaterVolume_float
|
||||
o_Color = i_Color;
|
||||
o_Emission = i_Emission;
|
||||
|
||||
if (i_Multiplier == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef SHADERGRAPH_PREVIEW
|
||||
m_Crest::SetUpFog(i_PositionNDC, i_PositionWS, i_DepthRaw, i_Multiplier);
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel CrestWaterLineBRP _BRP
|
||||
#pragma kernel CrestWaterLineHRP _HRP
|
||||
#pragma kernel CrestWaterLineURP _URP
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
// Checks both orthogonal and diagonal pixels to fill artefacts in the mask. If checked pixels are all the same then it
|
||||
// assumes that the current pixel should also be the same and fixes it.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel FillMaskArtefacts _BRP
|
||||
|
||||
// Built-in will not handle this for us unlike other RPs.
|
||||
|
||||
@@ -5,12 +5,6 @@
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Volume/UnderwaterShared.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Volume/Debug.hlsl"
|
||||
|
||||
#if (CREST_LEGACY_UNDERWATER == 1) || defined(CREST_URP)
|
||||
#define d_Crest_SampleColor 1
|
||||
#else
|
||||
#define d_Crest_SampleColor 0
|
||||
#endif
|
||||
|
||||
#ifndef SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER
|
||||
#define FoveatedRemapLinearToNonUniform(uv) uv
|
||||
#endif
|
||||
@@ -25,7 +19,7 @@ TEXTURE2D_X(_Crest_CameraColorTexture);
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
#if (CREST_LEGACY_UNDERWATER != 0) || d_Crest_CustomColorTexture
|
||||
#if (CREST_LEGACY_UNDERWATER != 0)
|
||||
float3 SampleSceneColor(float2 i_UV)
|
||||
{
|
||||
return LOAD_TEXTURE2D_X(_Crest_CameraColorTexture, i_UV * _ScreenSize.xy).rgb;
|
||||
@@ -153,8 +147,7 @@ half4 Fragment(Varyings input)
|
||||
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
||||
positionWS += _WorldSpaceCameraPos;
|
||||
#endif
|
||||
half3 vo =0; half3 vl = 0;
|
||||
sceneColour = ApplyUnderwaterEffect(sceneColour, rawDepth, sceneZ, fogDistance, view, positionSS, positionWS, hasCaustics, outScatterScene, applyLighting, 1.0, vo, vl);
|
||||
sceneColour = ApplyUnderwaterEffect(sceneColour, rawDepth, sceneZ, fogDistance, view, positionSS, positionWS, hasCaustics, outScatterScene, applyLighting, 1.0);
|
||||
}
|
||||
|
||||
return half4(sceneColour, 1.0);
|
||||
@@ -174,14 +167,18 @@ half4 FragmentPlanarReflections(Varyings input)
|
||||
return half4(_Crest_Scattering.xyz, 1.0);
|
||||
}
|
||||
|
||||
#if d_Crest_SampleColor
|
||||
half3 color = SampleSceneColor(positionNDC).rgb;
|
||||
#else
|
||||
half3 color = LoadSceneColor(positionSS).rgb;
|
||||
#endif
|
||||
|
||||
// Calculate position and account for possible NaNs discovered during testing.
|
||||
float3 positionWS = Utility::SafeComputeWorldSpacePosition(positionNDC, depth, UNITY_MATRIX_I_VP);
|
||||
float3 positionWS;
|
||||
{
|
||||
float4 positionCS = ComputeClipSpacePosition(positionNDC, depth);
|
||||
float4 hpositionWS = mul(UNITY_MATRIX_I_VP, positionCS);
|
||||
|
||||
// w is sometimes zero when using oblique projection.
|
||||
// Zero is better than NaN.
|
||||
positionWS = hpositionWS.w > 0.0 ? hpositionWS.xyz / hpositionWS.w : 0.0;
|
||||
}
|
||||
|
||||
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
|
||||
positionWS += _WorldSpaceCameraPos;
|
||||
@@ -190,8 +187,7 @@ half4 FragmentPlanarReflections(Varyings input)
|
||||
const half3 view = GetWorldSpaceNormalizeViewDir(positionWS);
|
||||
const bool hasCaustics = depth > 0.0;
|
||||
|
||||
half3 vo = 0; half3 vl = 0;
|
||||
color = ApplyUnderwaterEffect(color, depth, 0.0, 0.0, view, positionSS, positionWS, hasCaustics, true, true, 1.0, vo, vl);
|
||||
color = ApplyUnderwaterEffect(color, depth, 0.0, 0.0, view, positionSS, positionWS, hasCaustics, true, true, 1.0);
|
||||
|
||||
return half4(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ Shader "Crest/Underwater"
|
||||
[PerRendererData] _Crest_CausticsDistortionStrength("Caustics Distortion Strength", Range(0, 0.25)) = 0.16
|
||||
[PerRendererData] _Crest_CausticsDistortionScale("Caustics Distortion Scale", Range(0.01, 1000)) = 250
|
||||
[PerRendererData] _Crest_CausticsMotionBlur("Caustics Motion Blur", Range(0, 10)) = 1
|
||||
[PerRendererData] [Toggle(_CREST_FLOW_LOD)] _CREST_FLOW_LOD("Flow Enabled", Float) = 0
|
||||
[PerRendererData] [Toggle] CREST_FLOW("Flow Enabled", Float) = 0
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
@@ -61,7 +61,7 @@ Shader "Crest/Underwater"
|
||||
// #pragma enable_d3d11_debug_symbols
|
||||
|
||||
// Also on the water shader.
|
||||
#pragma multi_compile_local_fragment __ _CREST_FLOW_LOD
|
||||
#pragma multi_compile_local_fragment __ CREST_FLOW_ON
|
||||
|
||||
#pragma shader_feature_local_fragment __ d_Dithering
|
||||
|
||||
@@ -231,6 +231,8 @@ Shader "Crest/Underwater"
|
||||
HLSLPROGRAM
|
||||
#include_with_pragmas "UnderwaterHDRP.hlsl"
|
||||
|
||||
#define d_Crest_CustomColorTexture 1
|
||||
|
||||
#define d_Crest_Portal 1
|
||||
#define d_Crest_Geometry 1
|
||||
#define d_Crest_FogBefore 1
|
||||
@@ -284,6 +286,8 @@ Shader "Crest/Underwater"
|
||||
HLSLPROGRAM
|
||||
#include_with_pragmas "UnderwaterHDRP.hlsl"
|
||||
|
||||
#define d_Crest_CustomColorTexture 1
|
||||
|
||||
#define d_Crest_Portal 1
|
||||
#define d_Crest_PortalNegativeVolume 1
|
||||
#define d_Crest_PortalWithBackFace 1
|
||||
@@ -292,35 +296,6 @@ Shader "Crest/Underwater"
|
||||
#pragma fragment Fragment
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
PackageRequirements
|
||||
{
|
||||
"com.waveharmonic.crest.portals"
|
||||
}
|
||||
|
||||
Name "Fog After (Negative)"
|
||||
|
||||
Cull Front
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#include_with_pragmas "UnderwaterHDRP.hlsl"
|
||||
|
||||
#pragma multi_compile_local _ d_Crest_ComputeMask
|
||||
|
||||
// Needs custom otherwise it will overwrite the fog before.
|
||||
#define d_Crest_CustomColorTexture 1
|
||||
#define d_Crest_Portal 1
|
||||
#define d_Crest_Geometry 1
|
||||
#define d_Crest_FogBefore 1
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Volume/Underwater.hlsl"
|
||||
|
||||
#pragma fragment Fragment
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
SubShader
|
||||
@@ -492,6 +467,8 @@ Shader "Crest/Underwater"
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
|
||||
|
||||
#define d_Crest_CustomColorTexture 1
|
||||
|
||||
#define d_Crest_Portal 1
|
||||
#define d_Crest_Geometry 1
|
||||
#define d_Crest_FogBefore 1
|
||||
@@ -549,6 +526,8 @@ Shader "Crest/Underwater"
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
|
||||
|
||||
#define d_Crest_CustomColorTexture 1
|
||||
|
||||
#define d_Crest_Portal 1
|
||||
#define d_Crest_PortalNegativeVolume 1
|
||||
#define d_Crest_PortalWithBackFace 1
|
||||
@@ -557,37 +536,6 @@ Shader "Crest/Underwater"
|
||||
#pragma fragment Fragment
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
PackageRequirements
|
||||
{
|
||||
"com.waveharmonic.crest.portals"
|
||||
}
|
||||
|
||||
Name "Fog After (Negative)"
|
||||
|
||||
Cull Front
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#include_with_pragmas "UnderwaterURP.hlsl"
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
|
||||
|
||||
#pragma multi_compile_local _ d_Crest_ComputeMask
|
||||
|
||||
// Needs custom otherwise it will overwrite the fog before.
|
||||
#define d_Crest_CustomColorTexture 1
|
||||
#define d_Crest_Portal 1
|
||||
#define d_Crest_Geometry 1
|
||||
#define d_Crest_FogBefore 1
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Volume/Underwater.hlsl"
|
||||
|
||||
#pragma fragment Fragment
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
SubShader
|
||||
@@ -741,6 +689,9 @@ Shader "Crest/Underwater"
|
||||
|
||||
#pragma multi_compile_local _ d_Crest_ComputeMask
|
||||
|
||||
// For negative volumes.
|
||||
#define d_Crest_CustomColorTexture 1
|
||||
|
||||
#define d_Crest_Portal 1
|
||||
#define d_Crest_Geometry 1
|
||||
#define d_Crest_FogBefore 1
|
||||
@@ -794,6 +745,8 @@ Shader "Crest/Underwater"
|
||||
HLSLPROGRAM
|
||||
#include_with_pragmas "UnderwaterBIRP.hlsl"
|
||||
|
||||
#define d_Crest_CustomColorTexture 1
|
||||
|
||||
#define d_Crest_Portal 1
|
||||
#define d_Crest_PortalNegativeVolume 1
|
||||
#define d_Crest_PortalWithBackFace 1
|
||||
@@ -802,35 +755,6 @@ Shader "Crest/Underwater"
|
||||
#pragma fragment Fragment
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
PackageRequirements
|
||||
{
|
||||
"com.waveharmonic.crest.portals"
|
||||
}
|
||||
|
||||
Name "Fog After (Negative)"
|
||||
|
||||
Cull Front
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#include_with_pragmas "UnderwaterBIRP.hlsl"
|
||||
|
||||
#pragma multi_compile_local _ d_Crest_ComputeMask
|
||||
|
||||
// Needs custom otherwise it will overwrite the fog before.
|
||||
#define d_Crest_CustomColorTexture 1
|
||||
|
||||
#define d_Crest_Portal 1
|
||||
#define d_Crest_Geometry 1
|
||||
#define d_Crest_FogBefore 1
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Volume/Underwater.hlsl"
|
||||
|
||||
#pragma fragment Fragment
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
CustomEditor "WaveHarmonic.Crest.Editor.CustomShaderGUI"
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#define CREST_UNDERWATER_EFFECT_SHARED_INCLUDED
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings.Crest.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Keywords.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Constants.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/InputsDriven.hlsl"
|
||||
@@ -14,9 +13,6 @@
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Depth.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Helpers.hlsl"
|
||||
|
||||
#undef d_Crest_CausticsForceDistortion
|
||||
#define d_Crest_CausticsForceDistortion 1
|
||||
|
||||
#if d_Crest_Portal
|
||||
#include "Packages/com.waveharmonic.crest.portals/Runtime/Shaders/Library/Portals.hlsl"
|
||||
#endif
|
||||
@@ -203,9 +199,7 @@ half3 ApplyUnderwaterEffect
|
||||
const bool hasCaustics,
|
||||
const bool i_OutScatterScene,
|
||||
const bool i_ApplyLighting,
|
||||
const half i_multiplier,
|
||||
out half3 volumeOpacity,
|
||||
out half3 volumeLight
|
||||
const half i_multiplier
|
||||
)
|
||||
{
|
||||
const bool isUnderwater = true;
|
||||
@@ -214,8 +208,8 @@ half3 ApplyUnderwaterEffect
|
||||
PrimaryLight(i_positionWS, lightColor, lightDirection);
|
||||
|
||||
// Uniform effect calculated from camera position.
|
||||
volumeLight = 0.0;
|
||||
volumeOpacity = 1.0;
|
||||
half3 volumeLight = 0.0;
|
||||
half3 volumeOpacity = 1.0;
|
||||
{
|
||||
half3 absorption = _Crest_Absorption.xyz;
|
||||
half3 scattering = _Crest_Scattering.xyz;
|
||||
@@ -230,20 +224,19 @@ half3 ApplyUnderwaterEffect
|
||||
absorption *= _Crest_ExtinctionMultiplier;
|
||||
scattering *= _Crest_ExtinctionMultiplier;
|
||||
|
||||
const float4 displacement = Cascade::MakeAnimatedWaves(sliceIndex).Sample(_WorldSpaceCameraPos.xz);
|
||||
const float waterLevel = g_Crest_WaterCenter.y + displacement.y + displacement.w;
|
||||
const float waterLevel = g_Crest_WaterCenter.y + Cascade::MakeAnimatedWaves(sliceIndex).Sample(_WorldSpaceCameraPos.xz).w;
|
||||
|
||||
half shadow = 1.0;
|
||||
#if d_Crest_ShadowLod
|
||||
{
|
||||
// #if CREST_SHADOWS_ON
|
||||
// Camera should be at center of LOD system so no need for blending (alpha, weights, etc). This might not be
|
||||
// the case if there is large horizontal displacement, but the _Crest_DataSliceOffset should help by setting a
|
||||
// large enough slice as minimum.
|
||||
half2 shadowSoftHard = Cascade::MakeShadow(sliceIndex).SampleShadow(_WorldSpaceCameraPos.xz);
|
||||
// Soft in red, hard in green. But hard not computed in HDRP.
|
||||
shadow = 1.0 - shadowSoftHard.x;
|
||||
// #endif
|
||||
}
|
||||
#endif
|
||||
|
||||
half3 ambientLighting = AmbientLight(_Crest_AmbientLighting);
|
||||
|
||||
@@ -296,7 +289,7 @@ half3 ApplyUnderwaterEffect
|
||||
|
||||
const uint slice0 = PositionToSliceIndex(i_positionWS.xz, 0, g_Crest_WaterScale);
|
||||
|
||||
#if d_Crest_FlowLod
|
||||
#ifdef CREST_FLOW_ON
|
||||
half2 flowData = Cascade::MakeFlow(slice0).SampleFlow(i_positionWS.xz);
|
||||
const Flow flow = Flow::Make(flowData, g_Crest_Time);
|
||||
blur = _Crest_CausticsMotionBlur;
|
||||
@@ -307,7 +300,7 @@ half3 ApplyUnderwaterEffect
|
||||
|
||||
sceneColour *= Caustics
|
||||
(
|
||||
#if d_Crest_FlowLod
|
||||
#ifdef CREST_FLOW_ON
|
||||
flow,
|
||||
#endif
|
||||
i_positionWS,
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Inspired by https://github.com/speps/GX-EncinoWaves
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
// First SIZE constant must match FFT_KERNEL_0_RESOLUTION in FFTCompute.cs
|
||||
#pragma kernel ComputeFFT SIZE=8 PASSES=3 CHANNEL=x TX=8 TY=1 FINAL=0
|
||||
#pragma kernel ComputeFFT SIZE=8 PASSES=3 CHANNEL=y TX=1 TY=8 FINAL=1
|
||||
@@ -24,13 +22,11 @@
|
||||
// Must match CASCADE_COUNT in FFTCompute.cs
|
||||
#define CASCADE_COUNT 16
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
|
||||
Texture2D<float2> _Crest_InputButterfly;
|
||||
#if !FINAL
|
||||
RWTexture2DArray<m_Float2> _Crest_Output1;
|
||||
RWTexture2DArray<m_Float2> _Crest_Output2;
|
||||
RWTexture2DArray<m_Float2> _Crest_Output3;
|
||||
RWTexture2DArray<float2> _Crest_Output1;
|
||||
RWTexture2DArray<float2> _Crest_Output2;
|
||||
RWTexture2DArray<float2> _Crest_Output3;
|
||||
#else
|
||||
Texture2DArray<float2> _Crest_InputH;
|
||||
Texture2DArray<float2> _Crest_InputX;
|
||||
@@ -144,9 +140,9 @@ void ComputeFFT(const uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
const uint coord = id.CHANNEL;
|
||||
#if !FINAL
|
||||
_Crest_IntermediatesH[coord] = conj(_Crest_Output1[id].xy);
|
||||
_Crest_IntermediatesX[coord] = conj(_Crest_Output2[id].xy);
|
||||
_Crest_IntermediatesZ[coord] = conj(_Crest_Output3[id].xy);
|
||||
_Crest_IntermediatesH[coord] = conj(_Crest_Output1[id]);
|
||||
_Crest_IntermediatesX[coord] = conj(_Crest_Output2[id]);
|
||||
_Crest_IntermediatesZ[coord] = conj(_Crest_Output3[id]);
|
||||
#else
|
||||
_Crest_IntermediatesH[coord] = _Crest_InputH[id];
|
||||
_Crest_IntermediatesX[coord] = _Crest_InputX[id];
|
||||
@@ -168,9 +164,9 @@ void ComputeFFT(const uint3 id : SV_DispatchThreadID)
|
||||
const float2 resultZ = pingpong ? _Crest_IntermediatesZ[coord] : _Crest_ScratchZ[coord];
|
||||
|
||||
#if !FINAL
|
||||
_Crest_Output1[id] = m_Float2FromFloat2(resultH);
|
||||
_Crest_Output2[id] = m_Float2FromFloat2(resultX);
|
||||
_Crest_Output3[id] = m_Float2FromFloat2(resultZ);
|
||||
_Crest_Output1[id] = resultH;
|
||||
_Crest_Output2[id] = resultX;
|
||||
_Crest_Output3[id] = resultZ;
|
||||
#else
|
||||
const float sign = ((id.x + id.y) % 2) == 1 ? -1.0 : 1.0;
|
||||
const float3 res = float3(sign * resultX.x, sign * resultH.x, sign * resultZ.x);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Inspired by https://github.com/speps/GX-EncinoWaves
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel SpectrumInitalize
|
||||
#pragma kernel SpectrumUpdate
|
||||
|
||||
@@ -20,8 +18,6 @@
|
||||
#define SPECTRUM_OCTAVE_COUNT 14.0
|
||||
#define SPECTRUM_SMALLEST_WL_POW_2 -4.0
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
|
||||
|
||||
uint _Crest_Size;
|
||||
float _Crest_WindSpeed;
|
||||
float _Crest_Turbulence;
|
||||
@@ -224,9 +220,9 @@ float _Crest_Time;
|
||||
float _Crest_Chop;
|
||||
|
||||
Texture2DArray<float4> _Crest_Init0;
|
||||
RWTexture2DArray<m_Float2> _Crest_ResultHeight;
|
||||
RWTexture2DArray<m_Float2> _Crest_ResultDisplaceX;
|
||||
RWTexture2DArray<m_Float2> _Crest_ResultDisplaceZ;
|
||||
RWTexture2DArray<float2> _Crest_ResultHeight;
|
||||
RWTexture2DArray<float2> _Crest_ResultDisplaceX;
|
||||
RWTexture2DArray<float2> _Crest_ResultDisplaceZ;
|
||||
|
||||
float2 cmul(float2 lhs, float2 rhs)
|
||||
{
|
||||
@@ -261,7 +257,7 @@ void SpectrumUpdate(uint3 id : SV_DispatchThreadID)
|
||||
const float4 h0 = _Crest_Init0[id];
|
||||
const float2 h = cmul(h0.xy, fwd) + cmul(h0.zw, bkwd);
|
||||
|
||||
_Crest_ResultHeight[id] = m_Float2FromFloat2(h);
|
||||
_Crest_ResultDisplaceX[id] = m_Float2FromFloat2((_Crest_Chop * float2(-h.y * k.x, h.x * k.x) / (kMag + 0.00001f)));
|
||||
_Crest_ResultDisplaceZ[id] = m_Float2FromFloat2((_Crest_Chop * float2(-h.y * k.y, h.x * k.y) / (kMag + 0.00001f)));
|
||||
_Crest_ResultHeight[id] = h;
|
||||
_Crest_ResultDisplaceX[id] = _Crest_Chop * float2(-h.y * k.x, h.x * k.x) / (kMag + 0.00001f);
|
||||
_Crest_ResultDisplaceZ[id] = _Crest_Chop * float2(-h.y * k.y, h.x * k.y) / (kMag + 0.00001f);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Computes a set of patches of waves, one for each scale.
|
||||
|
||||
#pragma exclude_renderers glcore gles3
|
||||
|
||||
#pragma kernel Gerstner
|
||||
|
||||
#include "HLSLSupport.cginc"
|
||||
|
||||
Reference in New Issue
Block a user