Many changes to jensen.

This commit is contained in:
2017-03-15 10:40:34 -04:00
parent 1faaaf0d63
commit c29d64583f
9 changed files with 167 additions and 63 deletions

View File

@@ -44,19 +44,7 @@ vec3 Sphere::normal_at_int(Ray & r, float & t) const {
}
vec3 Sphere::sample_at_surface() const {
float theta;
float u, sqrt1muu, x, y, z;
// Sampling formula from Wolfram Mathworld:
// http://mathworld.wolfram.com/SpherePointPicking.html
theta = random01()* (2.0f * pi<float>());
u = (random01() * 2.0f) - 1.0f;
sqrt1muu = glm::sqrt(1.0f - (u * u));
x = m_radius * sqrt1muu * cos(theta);
y = m_radius * sqrt1muu * sin(theta);
z = m_radius * u;
return vec3(x, y, z) + m_center;
return sample_sphere(m_center, m_radius);
}
void Sphere::calculate_inv_area() {