|
|
|
|
|
|
float distFromP = depth - posInput.depthVS; |
|
|
|
|
|
|
|
float VoR = dot(-V, R); |
|
|
|
refractedBackPointWS = posInput.positionWS + R*distFromP / VoR; |
|
|
|
refractedBackPointWS = posInput.positionWS + R * distFromP / VoR; |
|
|
|
opticalDepth = bsdfData.thickness; |
|
|
|
|
|
|
|
#elif defined(_REFRACTION_THICKSPHERE) |
|
|
|
|
|
|
// Refracted ray |
|
|
|
float3 R1 = refract(-V, bsdfData.normalWS, 1.0 / bsdfData.ior); |
|
|
|
// Center of the tangent sphere |
|
|
|
float3 C = posInput.positionWS - bsdfData.normalWS*bsdfData.thickness*0.5; |
|
|
|
float3 C = posInput.positionWS - bsdfData.normalWS * bsdfData.thickness * 0.5; |
|
|
|
opticalDepth = -NoR1*bsdfData.thickness; |
|
|
|
opticalDepth = -NoR1 * bsdfData.thickness; |
|
|
|
float3 P1 = posInput.positionWS + R1*opticalDepth; |
|
|
|
float3 P1 = posInput.positionWS + R1 * opticalDepth; |
|
|
|
// Out normal |
|
|
|
float3 N1 = normalize(C - P1); |
|
|
|
// Out refracted ray |
|
|
|
|
|
|
|
|
|
|
// Refracted source point |
|
|
|
refractedBackPointWS = P1 - R2*(depthFromPosition - NoR1*VoR1*bsdfData.thickness) / N1oR2; |
|
|
|
refractedBackPointWS = P1 - R2 * (depthFromPosition - NoR1 * VoR1 * bsdfData.thickness) / N1oR2; |
|
|
|
|
|
|
|
#elif defined(_REFRACTION_THINPLANE) |
|
|
|
/* |
|
|
|
|
|
|
// The refracted ray exiting the thin plane is the same as the incident ray (parallel interfaces and same ior) |
|
|
|
float VoR = dot(-V, R); |
|
|
|
float VoN = dot(V, bsdfData.normalWS); |
|
|
|
refractedBackPointWS = posInput.positionWS + R*opticalDepth - V*(distFromP - VoR*opticalDepth); |
|
|
|
refractedBackPointWS = posInput.positionWS + R * opticalDepth - V * (distFromP - VoR * opticalDepth); |
|
|
|
#endif |
|
|
|
|
|
|
|
// Calculate screen space coordinates of refracted point in back plane |
|
|
|