Skip to content

Commit

Permalink
Simple path tracer implementation is done.
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsy committed Apr 15, 2015
1 parent 0467a09 commit 2c1ec6f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/simplept_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using namespace rainy;
int main(int argc, char **argv) {
std::cout << "Path tracing" << std::endl << std::endl;

Renderer renderer(200, 200, 16, 2);
Renderer renderer(200, 200, 100, 5);
renderer.render();

return 0;
Expand Down
6 changes: 3 additions & 3 deletions src/Renderer/Renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ namespace rainy {
ofs << width << " " << height << " 255" << std::endl;

for (int i = 0; i < width * height; i++) {
int r = std::max(0, std::min((int)image[i].x(), 255));
int g = std::max(0, std::min((int)image[i].y(), 255));
int b = std::max(0, std::min((int)image[i].z(), 255));
int r = (int)(255.0 * std::max(0.0, std::min(image[i].x(), 1.0)));
int g = (int)(255.0 * std::max(0.0, std::min(image[i].y(), 1.0)));
int b = (int)(255.0 * std::max(0.0, std::min(image[i].z(), 1.0)));
ofs << r << " " << g << " " << b << std::endl;
}
ofs.close();
Expand Down
3 changes: 2 additions & 1 deletion src/Renderer/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace rainy {
Sphere(1.0e5, Vector3(50.0, 40.8, -1.0e5 + 250), Color(), Color(), REFLECTION_DIFFUSE), // Front wall (black)
Sphere(1.0e5, Vector3(50.0, 1.0e5, 81.6), Color(), Color(0.75, 0.75, 0.75), REFLECTION_DIFFUSE), // Floor (white)
Sphere(1.0e5, Vector3(50.0, -1.0e5 + 81.6, 81.6), Color(), Color(0.75, 0.75, 0.75), REFLECTION_DIFFUSE), // Ceil (white)
Sphere(20.0, Vector3(65.0, 20.0, 20.0), Color(), Color(25.0, 75.0, 25.0), REFLECTION_DIFFUSE), // Green ball
Sphere(20.0, Vector3(65.0, 20.0, 20.0), Color(), Color(0.25, 0.75, 0.25), REFLECTION_DIFFUSE), // Green ball
Sphere(16.5, Vector3(27.0, 16.5, 47.0), Color(), Color(0.99, 0.99, 0.99), REFLECTION_SPECULAR), // Mirror
Sphere(16.5, Vector3(77.0, 16.5, 78), Color(), Color(0.99, 0.99, 0.99), REFLECTION_REFRACTION), // Glass ball
Sphere(15.0, Vector3(50.0, 90.0, 81.6), Color(36, 36, 36), Color(), REFLECTION_DIFFUSE), // Light
};
Expand Down

0 comments on commit 2c1ec6f

Please sign in to comment.