升级6.4.升级水,升级天气
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#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"
|
||||
@@ -13,6 +14,9 @@
|
||||
#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
|
||||
@@ -72,7 +76,7 @@ half _Crest_SunBoost;
|
||||
float _Crest_OutScatteringFactor;
|
||||
float _Crest_OutScatteringExtinctionFactor;
|
||||
half3 _Crest_AmbientLighting;
|
||||
int _Crest_DataSliceOffset;
|
||||
uint _Crest_DataSliceOffset;
|
||||
|
||||
half _Crest_DitheringIntensity;
|
||||
CBUFFER_END
|
||||
@@ -96,6 +100,8 @@ static const m_Crest::TiledTexture _Crest_CausticsDistortionTiledTexture =
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
#if d_Crest_OutScattering
|
||||
|
||||
// Get the out-scattering term.
|
||||
half3 EvaluateOutScattering
|
||||
(
|
||||
@@ -137,6 +143,7 @@ half3 EvaluateOutScattering
|
||||
// benefit of both approaches.
|
||||
return lerp(outScatteringTerm, 1.0, _Crest_UnderwaterEnvironmentalLightingWeight);
|
||||
}
|
||||
#endif // d_Crest_OutScattering
|
||||
|
||||
void GetWaterSurfaceAndUnderwaterData
|
||||
(
|
||||
@@ -199,7 +206,9 @@ half3 ApplyUnderwaterEffect
|
||||
const bool hasCaustics,
|
||||
const bool i_OutScatterScene,
|
||||
const bool i_ApplyLighting,
|
||||
const half i_multiplier
|
||||
const half i_multiplier,
|
||||
out half3 volumeOpacity,
|
||||
out half3 volumeLight
|
||||
)
|
||||
{
|
||||
const bool isUnderwater = true;
|
||||
@@ -208,42 +217,55 @@ half3 ApplyUnderwaterEffect
|
||||
PrimaryLight(i_positionWS, lightColor, lightDirection);
|
||||
|
||||
// Uniform effect calculated from camera position.
|
||||
half3 volumeLight = 0.0;
|
||||
half3 volumeOpacity = 1.0;
|
||||
volumeLight = 0.0;
|
||||
volumeOpacity = 1.0;
|
||||
{
|
||||
half3 absorption = _Crest_Absorption.xyz;
|
||||
half3 scattering = _Crest_Scattering.xyz;
|
||||
|
||||
// We sample shadows at the camera position. Pass a user defined slice offset for smoothing out detail.
|
||||
// Offset slice so that we dont get high freq detail. But never use last lod as this has crossfading.
|
||||
int sliceIndex = clamp(_Crest_DataSliceOffset, 0, g_Crest_LodCount - 2);
|
||||
uint sliceIndex = clamp(_Crest_DataSliceOffset, 0, g_Crest_LodCount - 2);
|
||||
|
||||
if (g_Crest_SampleAbsorptionSimulation) absorption = Cascade::MakeAbsorption(sliceIndex).Sample(_WorldSpaceCameraPos.xz).xyz;
|
||||
if (g_Crest_SampleScatteringSimulation) scattering = Cascade::MakeScattering(sliceIndex).Sample(_WorldSpaceCameraPos.xz).xyz;
|
||||
#if d_Crest_AbsorptionLod
|
||||
if (g_Crest_SampleAbsorptionSimulation)
|
||||
{
|
||||
absorption = Cascade::MakeAbsorption(sliceIndex).Sample(_WorldSpaceCameraPos.xz).xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if d_Crest_ScatteringLod
|
||||
if (g_Crest_SampleScatteringSimulation)
|
||||
{
|
||||
scattering = Cascade::MakeScattering(sliceIndex).Sample(_WorldSpaceCameraPos.xz).xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
absorption *= _Crest_ExtinctionMultiplier;
|
||||
scattering *= _Crest_ExtinctionMultiplier;
|
||||
|
||||
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);
|
||||
|
||||
const half3 extinction = VolumeExtinction(absorption, scattering);
|
||||
|
||||
#if d_Crest_OutScattering
|
||||
// Out-Scattering Term.
|
||||
{
|
||||
const float4 displacement = Cascade::MakeAnimatedWaves(sliceIndex).Sample(_WorldSpaceCameraPos.xz);
|
||||
const float waterLevel = g_Crest_WaterCenter.y + displacement.y + displacement.w;
|
||||
|
||||
const half3 outScatteringTerm = EvaluateOutScattering
|
||||
(
|
||||
extinction,
|
||||
@@ -261,6 +283,7 @@ half3 ApplyUnderwaterEffect
|
||||
ambientLighting *= outScatteringTerm;
|
||||
#endif
|
||||
}
|
||||
#endif // d_Crest_OutScattering
|
||||
|
||||
volumeOpacity = VolumeOpacity(extinction, fogDistance);
|
||||
volumeLight = VolumeLighting
|
||||
@@ -274,8 +297,10 @@ half3 ApplyUnderwaterEffect
|
||||
lightDirection,
|
||||
lightColor,
|
||||
half3(0.0, 0.0, 0.0),
|
||||
1.0, // Additional lights blend
|
||||
_Crest_AmbientTerm,
|
||||
_Crest_DirectTerm,
|
||||
1.0, // Additional lights term
|
||||
_Crest_SunBoost,
|
||||
_Crest_ShadowsAffectsAmbientFactor
|
||||
);
|
||||
@@ -289,9 +314,9 @@ half3 ApplyUnderwaterEffect
|
||||
|
||||
const uint slice0 = PositionToSliceIndex(i_positionWS.xz, 0, g_Crest_WaterScale);
|
||||
|
||||
#ifdef CREST_FLOW_ON
|
||||
#if d_Crest_FlowLod
|
||||
half2 flowData = Cascade::MakeFlow(slice0).SampleFlow(i_positionWS.xz);
|
||||
const Flow flow = Flow::Make(flowData, g_Crest_Time);
|
||||
const Flow flow = Flow::Make(flowData, g_Crest_Flow);
|
||||
blur = _Crest_CausticsMotionBlur;
|
||||
#endif
|
||||
|
||||
@@ -300,7 +325,7 @@ half3 ApplyUnderwaterEffect
|
||||
|
||||
sceneColour *= Caustics
|
||||
(
|
||||
#ifdef CREST_FLOW_ON
|
||||
#if d_Crest_FlowLod
|
||||
flow,
|
||||
#endif
|
||||
i_positionWS,
|
||||
|
||||
Reference in New Issue
Block a user