sphere and disk area lights mostly ready (I think :S).
This commit is contained in:
23
disk.cpp
23
disk.cpp
@@ -1,6 +1,12 @@
|
||||
#include "disk.hpp"
|
||||
#include <glm/gtc/constants.hpp>
|
||||
|
||||
#include "disk.hpp"
|
||||
#include "sampling.hpp"
|
||||
|
||||
using glm::cos;
|
||||
using glm::sin;
|
||||
using glm::dot;
|
||||
using glm::pi;
|
||||
|
||||
bool Disk::intersect(Ray & r, float & t) const {
|
||||
float _t;
|
||||
@@ -15,3 +21,18 @@ bool Disk::intersect(Ray & r, float & t) const {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
vec3 Disk::sample_at_surface() const {
|
||||
float theta = random01() * (2.0f * pi<float>());
|
||||
float r = glm::sqrt(random01() * m_radius);
|
||||
float x = r * cos(theta);
|
||||
float y = r * sin(theta);
|
||||
float z = 0.0f;
|
||||
vec3 sample = vec3(x, y, z);
|
||||
rotate_sample(sample, m_normal);
|
||||
return sample;
|
||||
}
|
||||
|
||||
void Disk::calculate_inv_area() {
|
||||
m_inv_area = 1.0f / pi<float>() * (m_radius * m_radius);
|
||||
}
|
||||
|
Reference in New Issue
Block a user