|
|
|
|
|
|
|
|
|
|
void EvaluateSample(uint i, uint n, uint profileID, uint iR, uint iP, float2 centerCoord, int2 cacheAnchor, |
|
|
|
float3 shapeParam, float3 centerPosVS, float mmPerUnit, float2 pixelsPerMm, |
|
|
|
bool useTangentPlane, float3 tangentX, float3 tangentY, float4x4 projMatrix, |
|
|
|
float3 tangentX, float3 tangentY, float4x4 projMatrix, |
|
|
|
inout float3 totalIrradiance, inout float3 totalWeight) |
|
|
|
{ |
|
|
|
float r = _FilterKernels[profileID][i][iR]; |
|
|
|
|
|
|
// Compute the screen-space position and the squared distance (in mm) in the image plane. |
|
|
|
int2 position; float xy2; |
|
|
|
|
|
|
|
if (useTangentPlane) |
|
|
|
{ |
|
|
|
#if SSS_USE_TANGENT_PLANE != 0 |
|
|
|
float3 relPosVS = vec.x * tangentX + vec.y * tangentY; |
|
|
|
float3 positionVS = centerPosVS + relPosVS; |
|
|
|
float4 positionCS = mul(projMatrix, float4(positionVS, 1)); |
|
|
|
|
|
|
xy2 = dot(relPosVS.xy, relPosVS.xy); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
#else |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
float4 textureSample = LoadSample(position, cacheAnchor); |
|
|
|
float3 irradiance = textureSample.rgb; |
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
bool useTangentPlane = SSS_USE_TANGENT_PLANE != 0; |
|
|
|
|
|
|
|
float4x4 viewMatrix, projMatrix; |
|
|
|
GetLeftHandedViewSpaceMatrices(viewMatrix, projMatrix); |
|
|
|
|
|
|
|
|
|
|
// Integrate over the image or tangent plane in the view space. |
|
|
|
EvaluateSample(i, n, profileID, iR, iP, pixelCoord + 0.5, cacheAnchor, |
|
|
|
shapeParam, centerPosVS, mmPerUnit, pixelsPerMm, |
|
|
|
useTangentPlane, tangentX, tangentY, projMatrix, |
|
|
|
tangentX, tangentY, projMatrix, |
|
|
|
totalIrradiance, totalWeight); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
// Integrate over the image or tangent plane in the view space. |
|
|
|
EvaluateSample(i, n, profileID, iR, iP, pixelCoord + 0.5, cacheAnchor, |
|
|
|
shapeParam, centerPosVS, mmPerUnit, pixelsPerMm, |
|
|
|
useTangentPlane, tangentX, tangentY, projMatrix, |
|
|
|
tangentX, tangentY, projMatrix, |
|
|
|
totalIrradiance, totalWeight); |
|
|
|
} |
|
|
|
|