|
|
|
|
|
|
return r * real2(cosPhi, sinPhi); |
|
|
|
} |
|
|
|
|
|
|
|
real3 SampleSphereUniform(real u1, real u2) |
|
|
|
{ |
|
|
|
real phi = TWO_PI * u2; |
|
|
|
real cosTheta = 1.0 - 2.0 * u1; |
|
|
|
|
|
|
|
return SphericalToCartesian(phi, cosTheta); |
|
|
|
} |
|
|
|
|
|
|
|
// Performs cosine-weighted sampling of the hemisphere. |
|
|
|
// Ref: PBRT v3, p. 780. |
|
|
|
real3 SampleHemisphereCosine(real u1, real u2) |
|
|
|
|
|
|
return localL; |
|
|
|
} |
|
|
|
|
|
|
|
real3 SampleHemisphereUniform(real u1, real u2) |
|
|
|
// Cosine-weighted sampling without the tangent frame. |
|
|
|
// Ref: http://www.amietia.com/lambertnotangent.html |
|
|
|
real3 SampleHemisphereCosine(real u1, real u2, real3 normal) |
|
|
|
real phi = TWO_PI * u2; |
|
|
|
real cosTheta = 1.0 - u1; |
|
|
|
|
|
|
|
return SphericalToCartesian(phi, cosTheta); |
|
|
|
real3 pointOnSphere = SampleSphereUniform(u1, u2); |
|
|
|
return normalize(normal + pointOnSphere); |
|
|
|
real3 SampleSphereUniform(real u1, real u2) |
|
|
|
real3 SampleHemisphereUniform(real u1, real u2) |
|
|
|
real cosTheta = 1.0 - 2.0 * u1; |
|
|
|
real cosTheta = 1.0 - u1; |
|
|
|
|
|
|
|
return SphericalToCartesian(phi, cosTheta); |
|
|
|
} |
|
|
|