Seed derived from pixel coords + sample index + global seed so each (pixel, sample) pair gets an independent RNG stream without needing to allocate or synchronize anything. The 0x9E3779B97F4A7C15 golden- ratio constant decorrelates nearby pixels.
(pixel: UVec2, sample: u32, global_seed: u64)
| 1055 | /// to allocate or synchronize anything. The 0x9E3779B97F4A7C15 golden- |
| 1056 | /// ratio constant decorrelates nearby pixels. |
| 1057 | fn seed_for(pixel: UVec2, sample: u32, global_seed: u64) -> u64 { |
| 1058 | let mut x = global_seed; |
| 1059 | x ^= (pixel.x as u64).wrapping_mul(0x9E3779B97F4A7C15); |
| 1060 | x ^= (pixel.y as u64).wrapping_mul(0xBF58476D1CE4E5B9); |
| 1061 | x ^= (sample as u64).wrapping_mul(0x94D049BB133111EB); |
| 1062 | x |
| 1063 | } |
| 1064 | |
| 1065 | // ============================================================ |
| 1066 | // BRDF (GGX + Burley diffuse, metalness-aware) |