浏览代码

Removed contact shadows on light transmission

/main
Antoine Lelievre 7 年前
当前提交
f8468529
共有 4 个文件被更改,包括 17 次插入10 次删除
  1. 7
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightEvaluation.hlsl
  2. 10
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Volumetrics/VolumetricLighting.compute
  3. 5
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl
  4. 5
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.hlsl

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


void EvaluateLight_Punctual(LightLoopContext lightLoopContext, PositionInputs posInput,
LightData lightData, BakeLightingData bakeLightingData,
float3 N, float3 L, float3 lightToSample, float4 distances,
out float3 color, out float attenuation)
out float3 color, out float attenuation, out float attenuationWithoutContactShadows)
{
float3 positionWS = posInput.positionWS;
float shadow = 1.0;

// TODO: make projector lights cast shadows.
shadow = GetPunctualShadowAttenuation(lightLoopContext.shadowContext, positionWS, N, lightData.shadowIndex, L, distances.x, posInput.positionSS);
contactShadow = GetContactShadow(lightLoopContext, lightData.contactShadowIndex);
shadow = min(shadow, contactShadow);
#ifdef SHADOWS_SHADOWMASK
// Note: Legacy Unity have two shadow mask mode. ShadowMask (ShadowMask contain static objects shadow and ShadowMap contain only dynamic objects shadow, final result is the minimun of both value)

#else
shadow = lerp(1.0, shadow, lightData.shadowDimmer);
#endif
attenuationWithoutContactShadows = attenuation * shadow;
shadow = min(shadow, contactShadow);
}
attenuation *= shadow;

10
com.unity.render-pipelines.high-definition/HDRP/Lighting/Volumetrics/VolumetricLighting.compute


float4 distances = float4(dist, distSq, distRcp, distProj);
float3 L = -lightToSample * distRcp;
float3 color; float attenuation;
float3 color; float attenuation; float attenuationWithoutContactShadow;
0, L, lightToSample, distances, color, attenuation);
0, L, lightToSample, distances, color,
attenuation, attenuationWithoutContactShadow);
// Important:
// Ideally, all scattering calculations should use the jittered versions

float distProj = dot(lightToSample, light.forward);
float4 distances = float4(1, 1, 1, distProj);
float3 color; float attenuation;
float3 color; float attenuation; float attenuationWithoutContactShadow;
0, L, lightToSample, distances, color, attenuation);
0, L, lightToSample, distances, color,
attenuation, attenuationWithoutContactShadow);
// Important:
// Ideally, all scattering calculations should use the jittered versions

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


float3 color;
float attenuation;
float attenuationWithoutContactShadow;
lightToSample, distances, color, attenuation);
lightToSample, distances, color, attenuation, attenuationWithoutContactShadow);
// Restore the original shadow index.
lightData.shadowIndex = originalShadowIndex;

// Note: we do not modify the distance to the light, or the light angle for the back face.
// This is a performance-saving optimization which makes sense as long as the thickness is small.
// We use diffuse lighting for accumulation since it is going to be blurred during the SSS pass.
lighting.diffuse += EvaluateTransmission(bsdfData, transmittance, NdotL, NdotV, LdotV, attenuation * lightData.diffuseScale);
lighting.diffuse += EvaluateTransmission(bsdfData, transmittance, NdotL, NdotV, LdotV, attenuationWithoutContactShadow * lightData.diffuseScale);
}
// Save ALU by applying light and cookie colors only once.

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


float3 color;
float attenuation;
float attenuationWithoutContactShadow;
lightToSample, distances, color, attenuation);
lightToSample, distances, color, attenuation, attenuationWithoutContactShadow);
// Restore the original shadow index.
lightData.shadowIndex = originalShadowIndex;

// Note: we do not modify the distance to the light, or the light angle for the back face.
// This is a performance-saving optimization which makes sense as long as the thickness is small.
// We use diffuse lighting for accumulation since it is going to be blurred during the SSS pass.
lighting.diffuse += EvaluateTransmission(bsdfData, transmittance, NdotL, NdotV, LdotV, attenuation * lightData.diffuseScale);
lighting.diffuse += EvaluateTransmission(bsdfData, transmittance, NdotL, NdotV, LdotV, attenuationWithoutContactShadow * lightData.diffuseScale);
}
// Save ALU by applying light and cookie colors only once.

正在加载...
取消
保存