mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-06-08 07:22:01 +00:00
write background color
This commit is contained in:
parent
d808e05449
commit
812317f2ee
3 changed files with 10 additions and 0 deletions
|
@ -40,6 +40,13 @@ void RayTracer::render(Scene *scene) {
|
|||
Vector3f pxUpperLeft = vpUpperLeft + (du + dv) / 2.0;
|
||||
|
||||
Buffer buffer(width * height * 3);
|
||||
Vector3f bgc = scene->getBackgroundColor();
|
||||
for (int i = 0; i < width * height; ++i) {
|
||||
buffer[i * 3] = bgc.x();
|
||||
buffer[i * 3 + 1] = bgc.y();
|
||||
buffer[i * 3 + 2] = bgc.z();
|
||||
}
|
||||
|
||||
for (int y = 0; y < height; ++y)
|
||||
for (int x = 0; x < width; ++x) {
|
||||
Ray ray = getRay(x, y, cameraPos, pxUpperLeft, du, dv);
|
||||
|
|
|
@ -14,6 +14,8 @@ Vector3f Scene::getUpVector() const { return up; }
|
|||
|
||||
Vector3f Scene::getLookAt() const { return lookAt; }
|
||||
|
||||
Vector3f Scene::getBackgroundColor() const { return backgroundColor; }
|
||||
|
||||
void Scene::setRaysPerPixel(const Eigen::VectorXi &raysPerPixel) {
|
||||
this->raysPerPixel = raysPerPixel;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
Vector3f getCenter() const;
|
||||
Vector3f getUpVector() const;
|
||||
Vector3f getLookAt() const;
|
||||
Vector3f getBackgroundColor() const;
|
||||
void setRaysPerPixel(const Eigen::VectorXi &);
|
||||
void setAntialiasing(bool);
|
||||
void setTwoSideRender(bool);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue