浏览代码

Fixed contact shadows on transparent objects

/main
Antoine Lelievre 7 年前
当前提交
c8a540d3
共有 4 个文件被更改,包括 15 次插入15 次删除
  1. 22
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightEvaluation.hlsl
  2. 4
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  3. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl
  4. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.hlsl

22
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightEvaluation.hlsl


void EvaluateLight_Directional(LightLoopContext lightLoopContext, PositionInputs posInput,
DirectionalLightData lightData, BakeLightingData bakeLightingData,
float3 N, float3 L,
out float3 color, out float attenuation, out float attenuationNoContactShadow)
out float3 color, out float attenuation, out float attenuationNoContactShadows)
float contactShadow = 1.0;
color = lightData.color;
attenuation = 1.0; // Note: no volumetric attenuation along shadow rays for directional lights

// Note: There is no shadowDimmer when there is no shadow mask
#endif
attenuationNoContactShadow = attenuation * shadow;
#if (SHADERPASS != SHADERPASS_VOLUMETRIC_LIGHTING)
float contactShadow = GetContactShadow(lightLoopContext, lightData.contactShadowIndex);
shadow = min(shadow, contactShadow);
#if (SHADERPASS != SHADERPASS_VOLUMETRIC_LIGHTING && !defined(_SURFACE_TYPE_TRANSPARENT))
contactShadow = GetContactShadow(lightLoopContext, lightData.contactShadowIndex);
attenuation *= shadow;
attenuationNoContactShadows = shadow * attenuation;
attenuation *= min(shadow, contactShadow);
}
//-----------------------------------------------------------------------------

float shadowMask = 1.0;
float contactShadow = 1.0;
attenuationNoContactShadows = 1;
color = lightData.color;
attenuation = SmoothPunctualLightAttenuation(distances, lightData.invSqrAttenuationRadius,
lightData.angleScale, lightData.angleOffset);

shadow = lerp(1.0, shadow, lightData.shadowDimmer);
#endif
attenuationNoContactShadows = shadow * attenuation;
#if (SHADERPASS != SHADERPASS_VOLUMETRIC_LIGHTING)
#if (SHADERPASS != SHADERPASS_VOLUMETRIC_LIGHTING && !defined(_SURFACE_TYPE_TRANSPARENT))
shadow = min(shadow, contactShadow);
attenuation *= shadow;
attenuationNoContactShadows = shadow * attenuation;
attenuation *= min(shadow, contactShadow);
}

4
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl


return _EnvLightDatas[j];
}
float GetContactShadow(LightLoopContext lightLoopContact, int contactShadowIndex)
float GetContactShadow(LightLoopContext lightLoopContext, int contactShadowIndex)
{
// Here we take the contact shadow value using the contactShadowIndex of the light
// If the contact shadows are diasbled, it's value is -1 so this function will only

return max(lightLoopContact.shadowContext.contactShadow, abs(contactShadowIndex));
return max(lightLoopContext.shadowContext.contactShadow, abs(contactShadowIndex));
}

2
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl


{
// Make sure we do not sample the shadow map twice.
lightData.shadowIndex = -1;
//No need to restore as we dont use it later
lightData.contactShadowIndex = -1;
}
float3 color;

2
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.hlsl


{
// Make sure we do not sample the shadow map twice.
lightData.shadowIndex = -1;
//No need to restore as we dont use it later
lightData.contactShadowIndex = -1;
}
float3 color;

正在加载...
取消
保存