|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Implements equiangular light sampling. |
|
|
|
// Returns the distance from 0 and the reciprocal of the PDF. |
|
|
|
// Returns the distance from the origin of the ray, the squared (radial) distance from the light, |
|
|
|
// and the reciprocal of the PDF. |
|
|
|
out float dist, out float rcpPdf) |
|
|
|
out float dist, out float rSq, out float rcpPdf) |
|
|
|
float rayToLightDist = sqrt(rayToLightDistSq); |
|
|
|
float a = tMin - originToLightProj; |
|
|
|
float b = tMax - originToLightProj; |
|
|
|
float d = rayToLightDist; |
|
|
|
float a = tMin - originToLightProj; |
|
|
|
float b = tMax - originToLightProj; |
|
|
|
float dSq = rayToLightDistSq; |
|
|
|
float d = sqrt(dSq); |
|
|
|
float dInv = rsqrt(dSq); |
|
|
|
float theta0 = atan(a / d); |
|
|
|
float theta1 = atan(b / d); |
|
|
|
float theta0 = FastATan(a * dInv); |
|
|
|
float theta1 = FastATan(b * dInv); |
|
|
|
float gamma = theta1 - theta0; |
|
|
|
rcpPdf = (theta1 - theta0) * (d + t * tan(theta)); |
|
|
|
rSq = dSq + t * t; |
|
|
|
rcpPdf = gamma * rSq * dInv; |
|
|
|
} |
|
|
|
|
|
|
|
// Absorption coefficient from Disney: http://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf |
|
|
|