升级水插件
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user