Returns a point inside of a unit sphere
| 230 | |
| 231 | // Returns a point inside of a unit sphere |
| 232 | Float3 SampleSphere(float x1, float x2, float x3, float u1) |
| 233 | { |
| 234 | Float3 xyz = Float3(x1, x2, x3) * 2.0f - 1.0f; |
| 235 | float scale = std::pow(u1, 1.0f / 3.0f) / Float3::Length(xyz); |
| 236 | return xyz * scale; |
| 237 | } |
| 238 | |
| 239 | // Returns a random direction on the unit sphere |
| 240 | Float3 SampleDirectionSphere(float u1, float u2) |