浏览代码

[PlanarReflection] Renamed to influence space

/main
Frédéric Vauchelles 7 年前
当前提交
c2dbc138
共有 2 个文件被更改,包括 15 次插入15 次删除
  1. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/VolumeProjection.hlsl
  2. 10
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/VolumeProjection.hlsl


return alpha;
}
float InfluenceBoxWeight(EnvLightData lightData, BSDFData bsdfData, float3 positionWS, float3 positionLS, float3 dirLS)
float InfluenceBoxWeight(EnvLightData lightData, BSDFData bsdfData, float3 positionWS, float3 positionIS, float3 dirIS)
{
float3 boxOuterDistance = lightData.influenceExtents;
// 2. Process the position influence

float3 negativeDistance = boxOuterDistance + positionLS;
float3 positiveDistance = boxOuterDistance - positionLS;
float3 negativeDistance = boxOuterDistance + positionIS;
float3 positiveDistance = boxOuterDistance - positionIS;
#endif
#if defined(ENVMAP_FEATURE_PERFACEINFLUENCE)

float alpha = saturate(influenceFalloff);
#else
float distFace = DistancePointBox(positionLS, -lightData.influenceExtents + lightData.blendDistancePositive.x, lightData.influenceExtents - lightData.blendDistancePositive.x);
float distFace = DistancePointBox(positionIS, -lightData.influenceExtents + lightData.blendDistancePositive.x, lightData.influenceExtents - lightData.blendDistancePositive.x);
float alpha = saturate(1.0 - distFace / max(lightData.blendDistancePositive.x, 0.0001));
#endif

// We consider R.x as cos(X) and then fade as angle from 60°(=acos(1/2)) to 75°(=acos(1/4))
// For positive axes: axisFade = (R - 1/4) / (1/2 - 1/4)
// <=> axisFace = 4 * R - 1;
float3 faceFade = saturate((4 * dirLS - 1) * lightData.boxSideFadePositive) + saturate((-4 * dirLS - 1) * lightData.boxSideFadeNegative);
float3 faceFade = saturate((4 * dirIS - 1) * lightData.boxSideFadePositive) + saturate((-4 * dirIS - 1) * lightData.boxSideFadeNegative);
alpha *= saturate(faceFade.x + faceFade.y + faceFade.z);
#endif

float3x3 WorldToLightSpace(EnvLightData lightData)
float3x3 WorldToInfluenceSpace(EnvLightData lightData)
float3 WorldToLightPosition(EnvLightData lightData, float3x3 worldToLS, float3 positionWS)
float3 WorldToInfluencePosition(EnvLightData lightData, float3x3 worldToIS, float3 positionWS)
float3 positionLS = positionWS - lightData.positionWS;
positionLS = mul(positionLS, worldToLS).xyz;
return positionLS;
float3 positionIS = positionWS - lightData.positionWS;
positionIS = mul(positionIS, worldToIS).xyz;
return positionIS;
}
#endif // UNITY_VOLUMEPROJECTION_INCLUDED

10
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


// In Unity the cubemaps are capture with the localToWorld transform of the component.
// This mean that location and orientation matter. So after intersection of proxy volume we need to convert back to world.
float3x3 worldToLS = WorldToLightSpace(lightData);
float3 positionLS = WorldToLightPosition(lightData, worldToLS, positionWS);
float3 dirLS = mul(R, worldToLS);
float3x3 worldToIS = WorldToInfluenceSpace(lightData);
float3 positionIS = WorldToInfluencePosition(lightData, worldToIS, positionWS);
float3 dirIS = mul(R, worldToIS);
float3x3 worldToPS = WorldToProxySpace(proxyData);
float3 positionPS = WorldToProxyPosition(proxyData, worldToPS, positionWS);

// 2. Process the influence
if (influenceShapeType == ENVSHAPETYPE_SPHERE)
weight = InfluenceSphereWeight(lightData, bsdfData, positionWS, positionLS, dirLS);
weight = InfluenceSphereWeight(lightData, bsdfData, positionWS, positionIS, dirIS);
weight = InfluenceBoxWeight(lightData, bsdfData, positionWS, positionLS, dirLS);
weight = InfluenceBoxWeight(lightData, bsdfData, positionWS, positionIS, dirIS);
// When we are rough, we tend to see outward shifting of the reflection when at the boundary of the projection volume
// Also it appear like more sharp. To avoid these artifact and at the same time get better match to reference we lerp to original unmodified reflection.

正在加载...
取消
保存