21 const float sign = copysignf(1.0f, n.z);
22 const float a = -1.0f / (sign + n.z);
23 const float b = n.x * n.y * a;
24 float3 t (1.0f + sign * n.x* n.x * a, sign * b, -sign * n.x);
25 float3 bt(b, sign + n.y * n.y * a, -n.y);
38 inline float uniform_sphere_pdf() {
39 return 1.0f / (4.0f * pi);
43 inline DirSample sample_uniform_sphere(
float u,
float v) {
44 const float c = 2.0f * v - 1.0f;
45 const float s = std::sqrt(1.0f - c * c);
46 const float phi = 2.0f * pi * u;
47 const float x = s * std::cos(phi);
48 const float y = s * std::sin(phi);
54 inline float cosine_hemisphere_pdf(
float c) {
69 inline float cosine_power_hemisphere_pdf(
float c,
float k) {
76 inline DirSample sample_cosine_power_hemisphere(
const LocalCoords& coords,
float k,
float u,
float v) {
86 inline float russian_roulette(
const rgb& c,
float max = 0.75f) {
87 return std::min(max, dot(c, luminance) * 2.0f);
float3 n
Normal.
Definition: random.h:11
Direction sample, from sampling a set of directions.
Definition: random.h:30
float3 t
Tangent.
Definition: random.h:12
Local coordinates for shading.
Definition: random.h:10
float3 bt
Bitangent.
Definition: random.h:13