compute final light level (per vertex) #3

Closed
noteuclid wants to merge 37 commits from vertex-light into two-way
2 changed files with 10 additions and 1 deletions
Showing only changes of commit 0065a45e7d - Show all commits

View File

@ -20,6 +20,12 @@ impl OrbitalCamera {
self.distance * vec3(xy * x, xy * y, z)
}
pub fn direction(&self) -> Vec3 {
let (y, x) = self.position_yaw.sin_cos();
let (z, xy) = self.position_pitch.sin_cos();
-vec3(xy * x, xy * y, z)
}
pub fn transform(&self) -> Mat4 {
// for yaw=0, pitch=0:
// X -> -Z

View File

@ -393,7 +393,10 @@ impl Core {
.map(|&v| {
let pos = obj.position + obj.radius * v;
let normal = v;
let dir = (pos - camera.position()).normalize();
let mut dir = (pos - camera.position()).normalize();
if !dir.is_finite() {
dir = camera.direction();
}
let light = light_at(Hit {
incident: Ray::new(pos, dir),
normal,