yocto/yocto_gl.cpp
inline vec2f sample_next2f(sampler& smp) {
      switch (smp.rtype) {
        case trace_rng_type::uniform: {
          return {next_rand1f(smp.rng), next_rand1f(smp.rng)};
        } break;
        case trace_rng_type::stratified: {
          smp.d += 2;
          auto p = hash_uint64_32(
              (uint64_t)smp.pixel_hash | (uint64_t)smp.d << 32);
          auto s = hash_permute(smp.s, smp.ns, p);
          return {clamp((s % smp.ns2 + next_rand1f(smp.rng)) / smp.ns2, 0.0f,
                        1 - flt_eps),
                  clamp((s / smp.ns2 + next_rand1f(smp.rng)) / smp.ns2, 0.0f,
                        1 - flt_eps)};
        } break;
        default: {
          assert(false);
          return {0, 0};
        }
      }
    }
// Generates a 2-dimensional sample.
//
// Implementation notes: see above. Note that using deterministic keyed
// permutaton we can use stratified sampling without preallocating samples.
Generates a 2-dimensional sample.
Implementation notes: see above. Note that using deterministic keyed
permutaton we can use stratified sampling without preallocating samples.
Generates a 2 - dimensional sample . Implementation notes : see above . Note that using deterministic keyed permutaton we can use stratified sampling without preallocating samples .
inline vec2f sample_next2f(sampler& smp) {
      switch (smp.rtype) {
        case trace_rng_type::uniform: {
          return {next_rand1f(smp.rng), next_rand1f(smp.rng)};
        } break;
        case trace_rng_type::stratified: {
          smp.d += 2;
          auto p = hash_uint64_32(
              (uint64_t)smp.pixel_hash | (uint64_t)smp.d << 32);
          auto s = hash_permute(smp.s, smp.ns, p);
          return {clamp((s % smp.ns2 + next_rand1f(smp.rng)) / smp.ns2, 0.0f,
                        1 - flt_eps),
                  clamp((s / smp.ns2 + next_rand1f(smp.rng)) / smp.ns2, 0.0f,
                        1 - flt_eps)};
        } break;
        default: {
          assert(false);
          return {0, 0};
        }
      }
    }
inline vec2f sample_next2f ( sampler & smp ) { switch ( smp . rtype ) { case trace_rng_type :: uniform : { return { next_rand1f ( smp . rng ) , next_rand1f ( smp . rng ) } ; } break ; case trace_rng_type :: stratified : { smp . d += 2 ; auto p = hash_uint64_32 ( ( uint64_t ) smp . pixel_hash | ( uint64_t ) smp . d << 32 ) ; auto s = hash_permute ( smp . s , smp . ns , p ) ; return { clamp ( ( s % smp . ns2 + next_rand1f ( smp . rng ) ) / smp . ns2 , 0.0f , 1 - flt_eps ) , clamp ( ( s / smp . ns2 + next_rand1f ( smp . rng ) ) / smp . ns2 , 0.0f , 1 - flt_eps ) } ; } break ; default : { assert ( false ) ; return { 0 , 0 } ; } } }
Generates a 2-dimensional sample.
Generates a 2 - dimensional sample .