|
|
|
|
|
|
preLightData.transparentTransmittance = exp(-bsdfData.absorptionCoefficient * refraction.dist); |
|
|
|
// Empirical remap to try to match a bit the refraction probe blurring for the fallback |
|
|
|
// Use IblPerceptualRoughness so we can handle approx of clear coat. |
|
|
|
preLightData.transparentSSMipLevel = pow(preLightData.iblPerceptualRoughness, 1.3) * uint(max(_ColorPyramidScale.z - 1, 0)); |
|
|
|
preLightData.transparentSSMipLevel = PositivePow(preLightData.iblPerceptualRoughness, 1.3) * uint(max(_ColorPyramidScale.z - 1, 0)); |
|
|
|
#endif |
|
|
|
|
|
|
|
return preLightData; |
|
|
|
|
|
|
// TODO: Fade pixels marked as foreground in stencil |
|
|
|
float weight = weightNDC.x * weightNDC.y * hitWeight; |
|
|
|
|
|
|
|
float hitDeviceDepth = LOAD_TEXTURE2D_LOD(_DepthPyramidTexture, hit.positionSS, 0).r; |
|
|
|
float hitLinearDepth = LinearEyeDepth(hitDeviceDepth, _ZBufferParams); |
|
|
|
|
|
|
|
float hitDeviceDepth = LOAD_TEXTURE2D_LOD(_DepthPyramidTexture, hit.positionSS, 0).r; |
|
|
|
float hitLinearDepth = LinearEyeDepth(hitDeviceDepth, _ZBufferParams); |
|
|
|
|
|
|
|
float2 samplingPositionNDC = hit.positionNDC; |
|
|
|
#if HAS_REFRACTION |
|
|
|
if (GPUImageBasedLightingType == GPUIMAGEBASEDLIGHTINGTYPE_REFRACTION |
|
|
|
&& hitLinearDepth < posInput.linearDepth) |
|
|
|
samplingPositionNDC = posInput.positionNDC; |
|
|
|
#endif |
|
|
|
|
|
|
|
// Reproject color pyramid |
|
|
|
float4 hitVelocityBuffer = LOAD_TEXTURE2D_LOD( |
|
|
|
_CameraMotionVectorsTexture, |
|
|
|
hit.positionSS, |
|
|
|
0.0 |
|
|
|
); |
|
|
|
|
|
|
|
float2 hitVelocityNDC; |
|
|
|
DecodeVelocity(hitVelocityBuffer, hitVelocityNDC); |
|
|
|
float2 hitVelocityNDC = 0; |
|
|
|
if (GPUImageBasedLightingType == GPUIMAGEBASEDLIGHTINGTYPE_REFLECTION) |
|
|
|
{ |
|
|
|
// Reproject color pyramid |
|
|
|
float4 hitVelocityBuffer = LOAD_TEXTURE2D_LOD( |
|
|
|
_CameraMotionVectorsTexture, |
|
|
|
hit.positionSS, |
|
|
|
0.0 |
|
|
|
); |
|
|
|
DecodeVelocity(hitVelocityBuffer, hitVelocityNDC); |
|
|
|
} |
|
|
|
(hit.positionNDC - hitVelocityNDC) * _ColorPyramidScale.xy + _ColorPyramidSize.zw * 0.5, |
|
|
|
(samplingPositionNDC - hitVelocityNDC) * _ColorPyramidScale.xy + _ColorPyramidSize.zw * 0.5, |
|
|
|
if (projectionModel == PROJECTIONMODEL_HI_Z) |
|
|
|
if (GPUImageBasedLightingType == GPUIMAGEBASEDLIGHTINGTYPE_REFLECTION && projectionModel == PROJECTIONMODEL_HI_Z) |
|
|
|
{ |
|
|
|
float4 currentVelocityBuffer = LOAD_TEXTURE2D_LOD( |
|
|
|
_CameraMotionVectorsTexture, |
|
|
|