升级6.4.升级水,升级天气
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#ifndef CREST_WATER_VOLUME_LIGHTING_H
|
||||
#define CREST_WATER_VOLUME_LIGHTING_H
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/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/Surface/Utility.hlsl"
|
||||
@@ -11,10 +12,10 @@
|
||||
m_CrestNameSpace
|
||||
|
||||
// Schlick phase function.
|
||||
float SchlickPhase(float phaseG, float cosTheta)
|
||||
half SchlickPhase(half phaseG, half cosTheta)
|
||||
{
|
||||
const float schlickK = 1.5 * phaseG - 0.5 * phaseG * phaseG * phaseG;
|
||||
const float phaseFactor = 1.0 + schlickK * cosTheta;
|
||||
const half schlickK = 1.5 * phaseG - 0.5 * phaseG * phaseG * phaseG;
|
||||
const half phaseFactor = 1.0 + schlickK * cosTheta;
|
||||
return (1.0 - schlickK * schlickK) / (4.0 * PI * phaseFactor * phaseFactor);
|
||||
}
|
||||
|
||||
@@ -42,36 +43,49 @@ half3 VolumeLighting
|
||||
const half3 i_PrimaryLightDirection,
|
||||
const half3 i_PrimaryLightIntensity,
|
||||
const half3 i_AdditionalLight,
|
||||
const half i_AdditionalLightBlend,
|
||||
const half i_AmbientLightingTerm,
|
||||
const half i_PrimaryLightingTerm,
|
||||
const half i_AdditionalLightingTerm,
|
||||
const half3 i_SunBoost,
|
||||
const half i_ShadowsAffectAmbientLightingFactor
|
||||
)
|
||||
{
|
||||
const half3 extinction = i_Extinction;
|
||||
|
||||
const float ambientLightShadow = lerp
|
||||
half ambientLightShadow = 1.0;
|
||||
|
||||
#if d_Crest_ShadowLod
|
||||
ambientLightShadow = lerp
|
||||
(
|
||||
1.0,
|
||||
i_DirectionalLightShadow,
|
||||
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;
|
||||
const float3 inScatteredAmbient = i_AmbientLighting * i_AmbientLightingTerm * ambientLightShadow;
|
||||
|
||||
// Total inscattered
|
||||
const float3 inscattered = (inScatteredAmbient + i_AdditionalLight + inScatteredSun * i_DirectionalLightShadow);
|
||||
#endif
|
||||
|
||||
const float3 scatteringAmount = saturate(i_Scattering / max(extinction, 0.00001));
|
||||
#ifdef d_IsAdditionalLight
|
||||
half3 inScattered = 0.0;
|
||||
half3 inScatteredAdditional = i_PrimaryLightIntensity;
|
||||
#else
|
||||
// Sun
|
||||
const half sunPhase = SchlickPhase(i_PhaseG, dot(i_PrimaryLightDirection, i_ViewDirectionWS));
|
||||
const half3 inScatteredSun = (1.0 + i_SunBoost) * sunPhase * i_PrimaryLightIntensity * i_PrimaryLightingTerm;
|
||||
const half3 inScatteredAmbient = i_AmbientLighting * i_AmbientLightingTerm * ambientLightShadow;
|
||||
|
||||
return inscattered * scatteringAmount;
|
||||
half3 inScattered = inScatteredAmbient + inScatteredSun * i_DirectionalLightShadow;
|
||||
half3 inScatteredAdditional = i_AdditionalLight;
|
||||
#endif
|
||||
|
||||
const half3 scatteringAmount = saturate(i_Scattering / max(extinction, 0.00001));
|
||||
inScattered *= scatteringAmount;
|
||||
|
||||
#if d_Crest_AdditionalLights
|
||||
inScatteredAdditional *= i_AdditionalLightingTerm;
|
||||
inScatteredAdditional *= (1.0 - i_AdditionalLightBlend) + scatteringAmount * i_AdditionalLightBlend;
|
||||
#endif
|
||||
|
||||
return inScattered + inScatteredAdditional;
|
||||
}
|
||||
|
||||
half PinchSSS
|
||||
|
||||
Reference in New Issue
Block a user