Added AdvanceScope;
Added energy conservation to diffuse lighting; Clean up shader properties;
This commit is contained in:
@@ -34,8 +34,9 @@ float GetColorAttenuation(float3 lightColor)
|
||||
|
||||
float3 GetLimitedLightColor(float3 lightColor)
|
||||
{
|
||||
lightColor = ApplyCurrentExposureMultiplier(lightColor);
|
||||
float3 result = lerp(lightColor, saturate(lightColor), _Is_Filter_LightColor);
|
||||
// In a hemisphere, The engery of full radiance is L * 2pi, and the engery of lambert is L * pi. We multiply by 0.5 here to apply the energy conservation.
|
||||
lightColor = ApplyCurrentExposureMultiplier(lightColor) * 0.5;
|
||||
float3 result = lerp(lightColor, normalize(lightColor), _ClampLightColor);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -57,7 +58,7 @@ DirectLighting UtsEvaluateBSDF_Directional(LightLoopContext lightLoopContext, Po
|
||||
// TODO: Colored shadow will overwrite the first and second shading diffuse color
|
||||
//float3 shadowColor = ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint);
|
||||
float4 lightColor = EvaluateLight_Directional(lightLoopContext, posInput, lightData);
|
||||
lightColor.rgb = GetLimitedLightColor(lightColor.rgb * lightColor.a * _Light_Intensity_Multiplier);
|
||||
lightColor.rgb = GetLimitedLightColor(lightColor.rgb * lightColor.a * _LightIntensityMultiplier);
|
||||
|
||||
UtsClampRoughness(preLightData, bsdfData, lightData.minRoughness);
|
||||
|
||||
@@ -86,7 +87,7 @@ DirectLighting UtsEvaluateBSDF_Punctual(LightLoopContext lightLoopContext, Posit
|
||||
// TODO: Colored shadow will overwrite the first and second shading diffuse color
|
||||
//float3 shadowColor = ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint);
|
||||
float4 lightColor = EvaluateLight_Punctual(lightLoopContext, posInput, lightData, L, distances);
|
||||
lightColor.rgb = GetLimitedLightColor(lightColor.rgb * lightColor.a * _Light_Intensity_Multiplier);
|
||||
lightColor.rgb = GetLimitedLightColor(lightColor.rgb * lightColor.a * _LightIntensityMultiplier);
|
||||
|
||||
UtsClampRoughness(preLightData, bsdfData, lightData.minRoughness);
|
||||
|
||||
|
||||
@@ -87,8 +87,7 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
||||
float3 L = -light.forward;
|
||||
|
||||
// Is it worth sampling the shadow map?
|
||||
if ((light.lightDimmer > 0) && (light.shadowDimmer > 0) && // Note: Volumetric can have different dimmer, thus why we test it here
|
||||
dot(bsdfData.normalWS, L) > 0.0)
|
||||
if ((light.lightDimmer > 0) && (light.shadowDimmer > 0))
|
||||
{
|
||||
context.shadowValue = GetDirectionalShadowAttenuation(context.shadowContext,
|
||||
posInput.positionSS, posInput.positionWS + L * _ShadowDistanceBias, UtsGetShadowNormal(bsdfData),
|
||||
|
||||
@@ -54,7 +54,7 @@ float3 ComputeSpecularTerm(UtsBSDFData bsdfData, PreLightData preLightData, floa
|
||||
|
||||
#elif _PBR_MODE_HAIR
|
||||
float3 t = ShiftTangent(bsdfData.bitangentWS, N, bsdfData.anisotropy);
|
||||
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.coatRoughness));
|
||||
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness));
|
||||
DV = D_KajiyaKay(t, H, specularExponent);
|
||||
|
||||
float normalizeSpec = DV * rcp(specularExponent + 2) * 2 * PI;
|
||||
@@ -69,9 +69,7 @@ float3 ComputeSpecularTerm(UtsBSDFData bsdfData, PreLightData preLightData, floa
|
||||
//return specTerm * ColorSpaceDielectricSpec.rgb * clampedNdotL;
|
||||
#endif
|
||||
|
||||
specTerm = DV * preLightData.specularFGD;
|
||||
specTerm = specTerm * clampedNdotL;
|
||||
|
||||
specTerm = DV * preLightData.specularFGD * clampedNdotL;
|
||||
return specTerm;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user