|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1) Gives good estimate of illumination as if light would've been shadowed during the bake. |
|
|
|
// Preserves bounce and other baked lights |
|
|
|
// No shadows on the geometry facing away from the light |
|
|
|
// We only subtract the main direction light. This is accounted in the contribution term below. |
|
|
|
half NdotL = saturate(dot(mainLight.direction, normalWS)); |
|
|
|
half3 lambert = mainLight.color * NdotL; |
|
|
|
half contributionTerm = saturate(dot(mainLight.direction, normalWS)) * (1.0 - _MainLightPosition.w); |
|
|
|
half3 lambert = mainLight.color * contributionTerm; |
|
|
|
half3 estimatedLightContributionMaskedByInverseOfShadow = lambert * (1.0 - mainLight.attenuation); |
|
|
|
half3 subtractedLightmap = bakedGI - estimatedLightContributionMaskedByInverseOfShadow; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MixRealtimeAndBakedGI(inout Light light, half3 normalWS, inout half3 bakedGI, half4 shadowMask) |
|
|
|
{ |
|
|
|
#if defined(_MIXED_LIGHTING_SUBTRACTIVE) && defined(LIGHTMAP_ON) && defined(_SHADOWS_ENABLED) |
|
|
|
bakedGI = lerp(SubtractDirectMainLightFromLightmap(light, normalWS, bakedGI), bakedGI, _MainLightPosition.w); |
|
|
|
#if defined(_MIXED_LIGHTING_SUBTRACTIVE) && defined(LIGHTMAP_ON) |
|
|
|
bakedGI = SubtractDirectMainLightFromLightmap(light, normalWS, bakedGI); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(LIGHTMAP_ON) |
|
|
|