|
|
|
|
|
|
// Evaluate Int{0, inf}{2 * Pi * r * R(sqrt(r^2 + d^2))}, where R is the diffusion profile. |
|
|
|
// Note: 'volumeAlbedo' should be premultiplied by 0.25. |
|
|
|
// Ref: Approximate Reflectance Profiles for Efficient Subsurface Scattering by Pixar (BSSRDF only). |
|
|
|
float3 ComputeTransmittance(float3 S, float3 volumeAlbedo, float thickness, float radiusScale) |
|
|
|
float3 ComputeTransmittanceDisney(float3 S, float3 volumeAlbedo, float thickness, float radiusScale) |
|
|
|
#if 0 |
|
|
|
#else |
|
|
|
// Help the compiler. |
|
|
|
float k = (-1.0 / 3.0) * LOG2_E; |
|
|
|
float3 p = (k * thickness) * S; |
|
|
|
float3 expOneThird = exp2(p); |
|
|
|
#endif |
|
|
|
|
|
|
|
// Premultiply & optimize: T = (1/4 * A) * (e^(-t * S) + 3 * e^(-1/3 * t * S)) |
|
|
|
return volumeAlbedo * (expOneThird * expOneThird * expOneThird + 3 * expOneThird); |
|
|
|