升级水插件

This commit is contained in:
2026-01-08 22:30:55 +08:00
parent febff82d24
commit ca68084264
415 changed files with 18138 additions and 7134 deletions

View File

@@ -0,0 +1,41 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
#ifndef d_WaveHarmonic_Crest_SurfaceData
#define d_WaveHarmonic_Crest_SurfaceData
#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/Surface/Utility.hlsl"
TEXTURE2D_FLOAT(_Crest_WaterLine);
float _Crest_WaterLineTexel;
float2 _Crest_WaterLineResolution;
float2 _Crest_WaterLineSnappedPosition;
m_CrestNameSpace
float SampleWaterLineHeight(const float2 i_PositionWS)
{
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)
{
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
));
}
m_CrestNameSpaceEnd
#endif

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 23b1ac5d9553947b69f3b3cfa0e3551d
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
#ifndef d_WaveHarmonic_Crest_SurfaceFacing
#define d_WaveHarmonic_Crest_SurfaceFacing
#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/Settings.Crest.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Helpers.hlsl"
TEXTURE2D_X(_Crest_WaterMaskTexture);
m_CrestNameSpace
bool IsUnderWater(const bool i_FrontFace, const int i_ForceUnderwater, const uint2 i_PositionSS)
{
bool underwater = false;
// Use mask.
if (i_ForceUnderwater == 0)
{
underwater = LOAD_TEXTURE2D_X(_Crest_WaterMaskTexture, i_PositionSS).r <= CREST_MASK_BELOW_SURFACE;
}
else
{
underwater = IsUnderWater(i_FrontFace, i_ForceUnderwater);
}
return underwater;
}
m_CrestNameSpaceEnd
#endif // d_WaveHarmonic_Crest_SurfaceFacing

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e6b28bd595bf6434facba01c0b5d41b9
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,67 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
#ifndef d_WaveHarmonic_Crest_SurfaceFog
#define d_WaveHarmonic_Crest_SurfaceFog
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings.Crest.hlsl"
#define d_Crest_WaterSurface 1
#if (CREST_LEGACY_UNDERWATER != 1)
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Volume/Graph/IntegrateWaterVolume.hlsl"
#endif
m_CrestNameSpace
#if (CREST_LEGACY_UNDERWATER != 0)
static bool s_IsUnderWater;
#endif
void SetUpFog(bool i_Underwater, float3 i_PositionWS, float i_Multiplier, float i_FogDistance, half3 i_ViewWS, float2 i_PositionSS)
{
s_IsUnderWater = i_Underwater;
#if (CREST_LEGACY_UNDERWATER != 1)
s_PositionSS = i_PositionSS;
s_PositionWS = i_PositionWS;
s_ViewWS = i_ViewWS;
s_FogDistance = i_FogDistance;
s_DepthRaw = 0;
s_FogMultiplier = i_Multiplier;
#endif
}
m_CrestNameSpaceEnd
#if (CREST_LEGACY_UNDERWATER != 0)
#if (CREST_DISCARD_ATMOSPHERIC_SCATTERING != 0)
#if CREST_BIRP
#ifdef UNITY_PASS_FORWARDADD
#define m_Unity_FogColor fixed4(0, 0, 0, 0)
#else
#define m_Unity_FogColor unity_FogColor
#endif // UNITY_PASS_FORWARDADD
#undef UNITY_APPLY_FOG
#define UNITY_APPLY_FOG(coord, color) \
if (!m_Crest::s_IsUnderWater) \
{ \
UNITY_APPLY_FOG_COLOR(coord, color, m_Unity_FogColor); \
}
#endif // CREST_BIRP
#if CREST_HDRP
#define EvaluateAtmosphericScattering(i, V, color) m_Crest::s_IsUnderWater ? color : EvaluateAtmosphericScattering(i, V, color)
#endif
#if CREST_URP
#define MixFog(color, coord) m_Crest::s_IsUnderWater ? color : MixFog(color, coord)
#endif
#endif // CREST_DISCARD_ATMOSPHERIC_SCATTERING
#endif // CREST_LEGACY_UNDERWATER
#endif // d_WaveHarmonic_Crest_SurfaceFog

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 944710ebd91d247cca9b0a31307f6b87
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -30,6 +30,8 @@
// Guard against Shader Graph preview.
#ifndef SHADERGRAPH_PREVIEW
#define d_Crest_WaterSurface 1
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Shim.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Macros.hlsl"
@@ -45,6 +47,8 @@
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Flow.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Lighting.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Shadows.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Facing.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Normal.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Reflection.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Refraction.hlsl"
@@ -53,19 +57,12 @@
#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"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Surface/Fog.hlsl"
#if (CREST_PORTALS != 0)
#include "Packages/com.waveharmonic.crest.portals/Runtime/Shaders/Library/Portals.hlsl"
#endif
#if (CREST_SHADOWS_BUILT_IN_RENDER_PIPELINE != 0)
#if CREST_BIRP
#define SHADOWS_SPLIT_SPHERES 1
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Legacy/Core.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Legacy/Shadows.hlsl"
#endif
#endif
bool _Crest_DrawBoundaryXZ;
float4 _Crest_BoundaryXZ;
@@ -92,6 +89,7 @@ void Fragment(m_Properties)
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)
@@ -107,7 +105,7 @@ void Fragment(m_Properties)
}
}
const bool underwater = IsUnderwater(i_Facing, g_Crest_ForceUnderwater);
bool underwater = IsUnderWater(i_Facing, g_Crest_ForceUnderwater, positionSS);
// TODO: Should we use PosToSIs or check for overflow?
float slice0 = _Crest_LodIndex;
@@ -121,6 +119,7 @@ void Fragment(m_Properties)
const Cascade cascade1 = Cascade::Make(slice1);
float sceneRawZ = i_SceneDepthRaw;
float negativeFog = _ProjectionParams.y;
#if (CREST_PORTALS != 0)
#ifndef CREST_SHADOWPASS
@@ -128,7 +127,7 @@ void Fragment(m_Properties)
if (m_CrestPortal)
{
const float pixelRawZ = i_ScreenPositionRaw.z / i_ScreenPositionRaw.w;
if (OutsideOfPortal(i_ScreenPosition.xy, pixelRawZ, sceneRawZ))
if (Portal::EvaluateSurface(i_ScreenPosition.xy, pixelRawZ, i_PositionWS, underwater, sceneRawZ, negativeFog))
{
o_Alpha = 0.0;
return;
@@ -242,15 +241,6 @@ void Fragment(m_Properties)
// Normal.
{
WaterNormal
(
i_WaterLevelDerivatives,
i_ViewDirectionWS,
_Crest_MinimumReflectionDirectionY,
underwater,
o_NormalWS
);
if (_Crest_NormalMapEnabled)
{
o_NormalWS.xz += SampleNormalMaps
@@ -268,6 +258,17 @@ void Fragment(m_Properties)
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);
@@ -282,11 +283,7 @@ void Fragment(m_Properties)
float sceneDistance = 1000.0;
float3 scenePositionWS = 0.0;
half3 ambientLight = 0.0;
AmbientLight
(
ambientLight
);
const half3 ambientLight = AmbientLight();
float3 lightIntensity = 0.0;
half3 lightDirection = 0.0;
@@ -300,15 +297,8 @@ void Fragment(m_Properties)
half3 additionalLight = AdditionalLighting(i_PositionWS, i_ScreenPositionRaw, i_StaticLightMapUV);
#if d_Crest_ReceiveShadowsTransparent
// Sample shadow maps.
float4 shadowCoord = GET_SHADOW_COORDINATES(float4(i_PositionWS, 1.0));
half shadows = UNITY_SAMPLE_SHADOW(_ShadowMapTexture, shadowCoord);
shadows = lerp(_LightShadowData.r, 1.0, shadows);
shadows = min(shadow.y, shadows);
#endif
#if d_Transparent
#ifndef d_SkipRefraction
bool caustics;
RefractedScene
(
@@ -325,11 +315,24 @@ void Fragment(m_Properties)
scenePositionWS,
caustics
);
#endif
float refractedSeaLevel = 0;
float3 refractedSurfacePosition = 0;
if (!underwater)
#if CREST_BIRP
#if SHADERPASS == SHADERPASS_FORWARD_BASE
if (g_Crest_PrimaryLightHasCookie)
{
// If light has a cookie, it is zero for the ForwardBase pass. We need to split
// emission over ForwardBase and ForwardAdd. Ambient is done in the former, while
// direct (eg caustics) is done in ForwardAdd.
o_Emission = 0;
}
#endif
#endif
#endif // d_SkipRefraction
#endif // d_Transparent
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);
@@ -347,15 +350,11 @@ void Fragment(m_Properties)
}
#if d_Transparent
#ifndef d_SkipRefraction
// Caustics
if (_Crest_CausticsEnabled && !underwater && caustics)
{
float3 position = scenePositionWS;
#if CREST_BIRP
position = float3(i_ScreenPosition.xy * _ScreenSize.xy, 0);
#endif
half lightOcclusion = PrimaryLightShadows(position);
half lightOcclusion = PrimaryLightShadows(scenePositionWS, positionSS);
half blur = 0.0;
#ifdef CREST_FLOW_ON
@@ -384,7 +383,8 @@ void Fragment(m_Properties)
underwater
);
}
#endif
#endif // d_SkipRefraction
#endif // d_Transparent
half3 sss = 0.0;
@@ -404,11 +404,11 @@ void Fragment(m_Properties)
}
// Volume Lighting
half3 volumeLight = 0.0;
half3 volumeOpacity = 0.0;
VolumeLighting
const half3 extinction = VolumeExtinction(absorption, scattering);
const half3 volumeOpacity = VolumeOpacity(extinction, sceneDistance);
const half3 volumeLight = VolumeLighting
(
absorption,
extinction,
scattering,
_Crest_Anisotropy,
shadow.x,
@@ -419,11 +419,8 @@ void Fragment(m_Properties)
additionalLight,
_Crest_AmbientTerm,
_Crest_DirectTerm,
sceneDistance,
sss,
_Crest_ShadowsAffectsAmbientFactor,
volumeLight,
volumeOpacity
_Crest_ShadowsAffectsAmbientFactor
);
// Fresnel
@@ -531,11 +528,6 @@ void Fragment(m_Properties)
half3 intensity = _Crest_FoamIntensityAlbedo;
#if d_Crest_ReceiveShadowsTransparent
// @HACK: Scale intensity as BIRP does not support shadows for transparent objects.
intensity = max(_Crest_FoamIntensityAlbedo * saturate(ShadeSH9(float4(o_NormalWS, 1.0))), _Crest_FoamIntensityAlbedo * shadows);
#endif
ApplyFoamToSurface
(
albedo,
@@ -589,12 +581,15 @@ void Fragment(m_Properties)
o_Alpha = min(o_Alpha, 1.0);
}
#if d_Crest_ReceiveShadowsTransparent
// @HACK: Dull highlights as BIRP does not support shadows for transparent objects.
o_Smoothness *= lerp(1, shadows, foam * 100);
// @FIXME: 0.2 to difference when high. Likely incorrect shadow sampling.
o_Specular = shadows < 0.2 ? 1.0 - max(shadows, 0.3) : o_Specular;
#endif
SetUpFog
(
underwater,
i_PositionWS,
1.0, // N/A: multiplier for fog nodes
sceneDistance - negativeFog,
i_ViewDirectionWS,
positionSS
);
}
m_CrestNameSpaceEnd

View File

@@ -8,6 +8,14 @@
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Globals.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Cascade.hlsl"
// 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
// i_meshScaleAlpha is passed in as it is provided per tile and is set only for LOD0
@@ -49,7 +57,8 @@ void SnapAndTransitionVertLayout(in const float4x4 i_objectMatrix, in const floa
objectPosXZWS += _WorldSpaceCameraPos.xz;
#endif
io_worldPos.xz -= frac(objectPosXZWS / GRID_SIZE_2) * GRID_SIZE_2; // caution - sign of frac might change in non-hlsl shaders
const float2 gridOffset = frac(objectPosXZWS / GRID_SIZE_2) * GRID_SIZE_2;
io_worldPos.xz -= gridOffset; // caution - sign of frac might change in non-hlsl shaders
// compute lod transition alpha
o_lodAlpha = ComputeLodAlpha(io_worldPos, i_meshScaleAlpha, i_cascadeData0);
@@ -63,6 +72,20 @@ void SnapAndTransitionVertLayout(in const float4x4 i_objectMatrix, in const floa
const float minRadius = 0.375;
if (abs(offset.x) < minRadius) io_worldPos.x += offset.x * o_lodAlpha * GRID_SIZE_4;
if (abs(offset.y) < minRadius) io_worldPos.z += offset.y * o_lodAlpha * GRID_SIZE_4;
#if SHADER_API_VULKAN
#if CREST_HDRP
#if _TRANSPARENT_WRITES_MOTION_VEC
// Fixes artifacts where parts of the surface appear to be clipped. It appears to
// be a precision issue (LOD resolution not power of 2), but only when the MV code
// path is active - even though it writes to a separate target.
if (any(isinf(gridOffset)))
{
o_lodAlpha = 0.0;
}
#endif
#endif
#endif
}
void SnapAndTransitionVertLayout(in const float i_meshScaleAlpha, in const Cascade i_cascadeData0, in const float i_geometryGridSize, inout float3 io_worldPos, out float o_lodAlpha)

View File

@@ -13,6 +13,10 @@
#include "Packages/com.waveharmonic.crest.shifting-origin/Runtime/Shaders/ShiftingOrigin.hlsl"
#endif
// These are per cascade, set per chunk instance.
float _Crest_ChunkFarNormalsWeight;
float2 _Crest_ChunkNormalScrollSpeed;
m_CrestNameSpace
half2 SampleNormalMaps

View File

@@ -65,7 +65,7 @@ void RefractedScene
#if (CREST_PORTALS != 0)
#if _ALPHATEST_ON
// Portals
ApplyPortalRefractions(positionNDCRefracted, i_SceneZRaw, i_Underwater, sceneDepthRawRefracted, o_Caustics);
Portal::EvaluateRefraction(positionNDCRefracted, i_SceneZRaw, i_Underwater, sceneDepthRawRefracted, o_Caustics);
#endif
#endif

View File

@@ -10,13 +10,12 @@
#ifndef CREST_SHADERGRAPH_CONSTANTS_H
#define CREST_SHADERGRAPH_CONSTANTS_H
// "pow(f,e) will not work for negative f"
#pragma warning (disable : 3571)
#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED
#define CREST_URP 1
#if (SHADERPASS == SHADERPASS_SHADOWCASTER)
#define CREST_SHADOWPASS 1
#endif
#if _SURFACE_TYPE_TRANSPARENT
#define d_Transparent 1
#endif
@@ -24,18 +23,11 @@
#elif BUILTIN_TARGET_API
#define CREST_BIRP 1
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Legacy/InputsDriven.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Legacy/Common.hlsl"
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Legacy/Core.hlsl"
#if _BUILTIN_SURFACE_TYPE_TRANSPARENT
#define d_Transparent 1
#endif
// SHADERPASS is currently broken:
// https://forum.unity.com/threads/built-in-renderer-shaderpass-include-in-wrong-place.1444156/
// #if (SHADERPASS == SHADERPASS_SHADOWCASTER)
// #define CREST_SHADOWPASS 1
// #endif
#else
// HDRP does not appear to have a reliable keyword to target.
#define CREST_HDRP 1
@@ -49,8 +41,21 @@
#endif
#endif
#if defined(CREST_BIRP) || defined(CREST_URP)
#if (SHADERPASS == SHADERPASS_SHADOWCASTER)
#define CREST_SHADOWPASS 1
#endif
#endif
#if defined(CREST_HDRP) && (SHADERPASS == SHADERPASS_FORWARD)
#define CREST_HDRP_FORWARD_PASS 1
#endif
#if defined(CREST_BIRP) && (SHADERPASS == SHADERPASS_FORWARD_ADD)
#ifndef DIRECTIONAL_COOKIE
#define d_SkipRefraction 1
#define d_IsAdditionalLight 1
#endif
#endif
#endif // CREST_SHADERGRAPH_CONSTANTS_H

View File

@@ -29,14 +29,14 @@
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Depth.hlsl"
#if CREST_URP
#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(_Crest_LodIndex + (isMotionVectors ? g_Crest_LodChange : 0), 0, g_Crest_LodCount)
#define m_Slice clamp((int)_Crest_LodIndex + (isMotionVectors ? g_Crest_LodChange : 0), 0, g_Crest_LodCount)
#define m_Make(slice) Make(slice, isMotionVectors)
#else
#define m_Slice _Crest_LodIndex
@@ -146,7 +146,7 @@ void Vertex(m_Properties)
o_PositionWS.xz -= g_Crest_WaterCenter.xz;
o_PositionWS.xz *= g_Crest_WaterScaleChange;
o_PositionWS.xz += g_Crest_WaterCenter.xz;
o_PositionWS += g_Crest_WaterCenterDelta;
o_PositionWS.xz += g_Crest_WaterCenterDelta;
}
#endif
}

View File

@@ -18,9 +18,22 @@ float SchlickPhase(float phaseG, float cosTheta)
return (1.0 - schlickK * schlickK) / (4.0 * PI * phaseFactor * phaseFactor);
}
void VolumeLighting
half3 VolumeExtinction(const half3 i_Absorption, const half3 i_Scattering)
{
// Extinction is light absorbed plus light scattered out.
return i_Absorption + i_Scattering;
}
half3 VolumeOpacity(const half3 i_Extinction, const half i_WaterRayLength)
{
// Like 'alpha' value or obscurance. Volume light needs multiplying by this value
// to be correct in shallows.
return 1.0 - exp(-i_Extinction * max(0.0, i_WaterRayLength));
}
half3 VolumeLighting
(
const half3 i_Absorption,
const half3 i_Extinction,
const half3 i_Scattering,
const half i_PhaseG,
const half i_DirectionalLightShadow,
@@ -31,15 +44,11 @@ void VolumeLighting
const half3 i_AdditionalLight,
const half i_AmbientLightingTerm,
const half i_PrimaryLightingTerm,
const half i_WaterRayLength,
const half3 i_SunBoost,
const half i_ShadowsAffectAmbientLightingFactor,
out half3 o_VolumeLight,
out half3 o_VolumeOpacity
const half i_ShadowsAffectAmbientLightingFactor
)
{
// Extinction is light absorbed plus light scattered out.
const half3 extinction = i_Absorption + i_Scattering;
const half3 extinction = i_Extinction;
const float ambientLightShadow = lerp
(
@@ -48,6 +57,9 @@ void VolumeLighting
saturate(min(min(extinction.x, extinction.y), extinction.z) * i_ShadowsAffectAmbientLightingFactor * g_Crest_DynamicSoftShadowsFactor)
);
#ifdef d_IsAdditionalLight
const float3 inscattered = i_PrimaryLightIntensity;
#else
// Sun
const float sunPhase = SchlickPhase(i_PhaseG, dot(i_PrimaryLightDirection, i_ViewDirectionWS));
const float3 inScatteredSun = (1.0 + i_SunBoost) * sunPhase * i_PrimaryLightIntensity * i_PrimaryLightingTerm;
@@ -55,11 +67,11 @@ void VolumeLighting
// Total inscattered
const float3 inscattered = (inScatteredAmbient + i_AdditionalLight + inScatteredSun * i_DirectionalLightShadow);
const float3 scatteringAmount = saturate(i_Scattering / max(extinction, 0.00001));
o_VolumeLight = inscattered * scatteringAmount;
#endif
// Like 'alpha' value or obscurance. Volume light needs multiplying by this value to be correct in shallows.
o_VolumeOpacity = 1.0 - exp(-extinction * max(0.0, i_WaterRayLength));
const float3 scatteringAmount = saturate(i_Scattering / max(extinction, 0.00001));
return inscattered * scatteringAmount;
}
half PinchSSS

View File

@@ -522,20 +522,6 @@
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "6fb510b9ca124cf881fe849664df5924"
},
"m_SlotId": 2
},
"m_InputSlot": {
"m_Node": {
"m_Id": "8e8aee51883445f1b08bfbec696cb18d"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
@@ -862,10 +848,10 @@
"m_Id": "4bb923e45f9f48bab142707a3af6e4bd"
},
{
"m_Id": "8e8aee51883445f1b08bfbec696cb18d"
"m_Id": "b7891fe7e5a34f03adebd8a45505c5fc"
},
{
"m_Id": "b7891fe7e5a34f03adebd8a45505c5fc"
"m_Id": "8e8aee51883445f1b08bfbec696cb18d"
},
{
"m_Id": "e207931e020242bba83058a59f3fb07d"
@@ -1170,7 +1156,7 @@
"m_ObjectId": "0b12e9fc0b164611b7fa17e0c6955043",
"m_Title": "Interpolators",
"m_Position": {
"x": 590.9999389648438,
"x": 591.0,
"y": 208.5
}
}
@@ -2458,7 +2444,7 @@
"m_SGVersion": 0,
"m_Type": "UnityEditor.Rendering.HighDefinition.ShaderGraph.SystemData",
"m_ObjectId": "4d02d98ad13c416c989fa4a1c65d2550",
"m_MaterialNeedsUpdateHash": 279864,
"m_MaterialNeedsUpdateHash": 279880,
"m_SurfaceType": 1,
"m_RenderingPass": 4,
"m_BlendMode": 0,
@@ -2483,7 +2469,7 @@
"m_TessellationShapeFactor": 0.75,
"m_TessellationBackFaceCullEpsilon": -0.25,
"m_TessellationMaxDisplacement": 0.009999999776482582,
"m_Version": 1,
"m_Version": 2,
"inspectorFoldoutMask": 11
}
@@ -3382,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,
@@ -3677,7 +3663,7 @@
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": 0.4000000059604645,
"m_Value": 0.8,
"m_FloatType": 1,
"m_RangeValues": {
"x": 0.0,
@@ -4620,7 +4606,7 @@
"m_SGVersion": 2,
"m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalLitSubTarget",
"m_ObjectId": "a52dd0dd7c42405cabd2b96b877532a3",
"m_WorkflowMode": 0,
"m_WorkflowMode": 1,
"m_NormalDropOffSpace": 2,
"m_ClearCoat": false,
"m_BlendModePreserveSpecular": false
@@ -5096,10 +5082,11 @@
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.Rendering.BuiltIn.ShaderGraph.BuiltInLitSubTarget",
"m_Type": "WaveHarmonic.Crest.Editor.ShaderGraph.BuiltInLitSubTarget",
"m_ObjectId": "bb3b0e5f6ef041aebb81194f38a5d07c",
"m_WorkflowMode": 1,
"m_NormalDropOffSpace": 2
"m_NormalDropOffSpace": 2,
"m_TransparentReceiveShadows": true
}
{
@@ -5349,7 +5336,7 @@
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": 10.0,
"m_Value": 3.0,
"m_FloatType": 0,
"m_RangeValues": {
"x": 0.0,
@@ -5433,7 +5420,8 @@
"m_Type": "UnityEditor.Rendering.HighDefinition.ShaderGraph.HDLitData",
"m_ObjectId": "cee72db709954dd38e8039e087fe5744",
"m_RayTracing": false,
"m_MaterialType": 4,
"m_MaterialType": 0,
"m_MaterialTypeMask": 18,
"m_RefractionModel": 1,
"m_SSSTransmission": true,
"m_EnergyConservingSpecular": false,