|
|
|
|
|
|
float3 refractedBackPointWS = EstimateRaycast(V, posInput, preLightData.transmissionPositionWS, preLightData.transmissionRefractV); |
|
|
|
|
|
|
|
// Calculate screen space coordinates of refracted point in back plane |
|
|
|
float4 refractedBackPointCS = mul(UNITY_MATRIX_VP, float4(refractedBackPointWS, 1.0)); |
|
|
|
float2 refractedBackPointSS = ComputeNormalizedDeviceCoordinates(refractedBackPointCS); |
|
|
|
float2 refractedBackPointNDC = ComputeNormalizedDeviceCoordinates(refractedBackPointWS, UNITY_MATRIX_VP); |
|
|
|
float refractedBackPointDepth = LinearEyeDepth(LOAD_TEXTURE2D_LOD(_PyramidDepthTexture, refractedBackPointSS * depthSize, 0).r, _ZBufferParams); |
|
|
|
float refractedBackPointDepth = LinearEyeDepth(LOAD_TEXTURE2D_LOD(_PyramidDepthTexture, refractedBackPointNDC * depthSize, 0).r, _ZBufferParams); |
|
|
|
|| any(refractedBackPointSS < 0.0) |
|
|
|
|| any(refractedBackPointSS > 1.0)) |
|
|
|
|| any(refractedBackPointNDC < 0.0) |
|
|
|
|| any(refractedBackPointNDC > 1.0)) |
|
|
|
{ |
|
|
|
// Do nothing and don't update the hierarchy weight so we can fall back on refraction probe |
|
|
|
return lighting; |
|
|
|
|
|
|
lighting.specularTransmitted = SAMPLE_TEXTURE2D_LOD(_GaussianPyramidColorTexture, s_trilinear_clamp_sampler, refractedBackPointSS, preLightData.transmissionSSMipLevel).rgb; |
|
|
|
lighting.specularTransmitted = SAMPLE_TEXTURE2D_LOD(_GaussianPyramidColorTexture, s_trilinear_clamp_sampler, refractedBackPointNDC, preLightData.transmissionSSMipLevel).rgb; |
|
|
|
|
|
|
|
// Beer-Lamber law for absorption |
|
|
|
lighting.specularTransmitted *= preLightData.transmissionTransmittance; |
|
|
|