mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-06-07 23:12:00 +00:00
add dummy global illum
This commit is contained in:
parent
c29cd77567
commit
a62e5eadc5
1 changed files with 13 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "Output.h"
|
||||
#include "Parser.h"
|
||||
#include "Progress.h"
|
||||
#include "Random.h"
|
||||
#include "Ray.h"
|
||||
|
||||
#include <Eigen/Core>
|
||||
|
@ -150,11 +151,22 @@ void writeColor(int i, const Vector3f &color) {
|
|||
Output::current->b(i, color.z());
|
||||
}
|
||||
|
||||
Vector3f trace(Ray r, int bounce, float prob) {}
|
||||
Vector3f trace(Ray r, int bounce, float prob) {
|
||||
float dice = utils::Random::get();
|
||||
if (bounce && (dice > prob)) {
|
||||
return Vector3f(1, 0, 1).array() * trace(r, bounce - 1, prob).array();
|
||||
}
|
||||
|
||||
return Vector3f(1, 1, 1);
|
||||
}
|
||||
|
||||
utils::Optional<Vector3f> trace(Ray r) {
|
||||
Vector3f color =
|
||||
trace(r, Scene::current->maxBounce(), Scene::current->probTerminate());
|
||||
|
||||
if (color != Vector3f::Zero())
|
||||
return utils::Optional<Vector3f>(color);
|
||||
|
||||
return utils::Optional<Vector3f>::nullopt;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue