erebus

annotate liberebus/src/brdf.cc @ 4:93894c232d65

more changes across the board
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 29 Apr 2014 07:38:40 +0300
parents 474a0244f57d
children e49f4d7ad04c
rev   line source
nuclear@2 1 #include "brdf.h"
nuclear@2 2 #include "erebus_impl.h"
nuclear@2 3
nuclear@2 4 // ---- class Reflectance ----
nuclear@2 5 Reflectance::Reflectance()
nuclear@2 6 {
nuclear@2 7 }
nuclear@2 8
nuclear@2 9 float Reflectance::sample(const Vector3 &norm, const Vector3 &outdir, Vector3 *indir) const
nuclear@2 10 {
nuclear@2 11 *indir = sample_dir(norm, outdir);
nuclear@2 12 return eval(norm, outdir, *indir);
nuclear@2 13 }
nuclear@2 14
nuclear@2 15 // --- class LambertRefl ---
nuclear@2 16 Vector3 LambertRefl::sample_dir(const Vector3 &norm, const Vector3 &outdir) const
nuclear@2 17 {
nuclear@2 18 Vector3 dir = Vector3{randf(-1, 1), randf(-1, 1), randf(-1, 1)}.normalized();
nuclear@2 19 return dot_product(dir, norm) < 0.0 ? -dir : dir;
nuclear@2 20 }
nuclear@2 21
nuclear@2 22 float LambertRefl::eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const
nuclear@2 23 {
nuclear@2 24 return dot_product(norm, outdir);
nuclear@2 25 }