Skip to content

Commit

Permalink
Merge pull request #3 from tatsy/develop
Browse files Browse the repository at this point in the history
Path tracing codes are refactored
  • Loading branch information
tatsy committed Apr 26, 2015
2 parents 587c031 + e32c1d4 commit d9c77eb
Show file tree
Hide file tree
Showing 29 changed files with 499 additions and 643 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ after_success:
- coveralls-lcov --repo-token RiYcPJSCbPZoogMd1PE10696EAqG8sl5q coverage.info
- ./build/bin/simplept
- sh ./update-gh-pages.sh
branches:
only:
- master
- develop
notifications:
email:
recipients: tatsy.mail@gmail.com
Expand Down
7 changes: 5 additions & 2 deletions example/simplebpt_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ int main(int argc, char **argv) {
5.0,
28.0);

BPTRenderer renderer(width, height, 50, 2);
renderer.render(scene, camera);
Random rng = Random::getRNG();
const int samplePerPixel = 32;

BPTRenderer renderer;
renderer.render(scene, camera, rng, samplePerPixel);

return 0;
}
4 changes: 2 additions & 2 deletions example/simplemlt_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ int main(int argc, char **argv) {
const int maxDepth = 5;
Random rng = Random::getRNG();

Ray camera(Vector3(50.0, 52.0, 295.6), Vector3(0.0, -0.042612, -1.0).normalize());
Ray camera(Vector3(50.0, 52.0, 295.6), Vector3(0.0, -0.042612, -1.0).normalized());
Vector3 cx = Vector3(width * 0.5135 / height, 0.0, 0.0);
Vector3 cy = cx.cross(camera.direction()).normalize() * 0.5135;
Vector3 cy = cx.cross(camera.direction()).normalized() * 0.5135;
Image image(width, height);

MLTRenderer renderer;
Expand Down
25 changes: 20 additions & 5 deletions example/simplept_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,28 @@ int main(int argc, char **argv) {
scene.addSphere(Sphere(1.0e5, Vector3(50.0, 40.8, -1.0e5 + 250), Color(), Color(), REFLECTION_DIFFUSE)); // Front wall (black)
scene.addSphere(Sphere(1.0e5, Vector3(50.0, 1.0e5, 81.6), Color(), Color(0.75, 0.75, 0.75), REFLECTION_DIFFUSE)); // Floor (white)
scene.addSphere(Sphere(1.0e5, Vector3(50.0, -1.0e5 + 81.6, 81.6), Color(), Color(0.75, 0.75, 0.75), REFLECTION_DIFFUSE)); // Ceil (white)
scene.addSphere(Sphere(20.0, Vector3(65.0, 20.0, 20.0), Color(), Color(0.25, 0.75, 0.25), REFLECTION_DIFFUSE)); // Green ball
scene.addSphere(Sphere(16.5, Vector3(27.0, 16.5, 47.0), Color(), Color(0.99, 0.99, 0.99), REFLECTION_SPECULAR)); // Mirror
scene.addSphere(Sphere(16.5, Vector3(77.0, 16.5, 78), Color(), Color(0.99, 0.99, 0.99), REFLECTION_REFRACTION)); // Glass ball
scene.addSphere(Sphere(20.0, Vector3(50.0, 20.0, 50.0), Color(), Color(0.25, 0.75, 0.25), REFLECTION_DIFFUSE)); // Green ball
scene.addSphere(Sphere(16.5, Vector3(19.0, 16.5, 25.0), Color(), Color(0.99, 0.99, 0.99), REFLECTION_SPECULAR)); // Mirror ball
scene.addSphere(Sphere(16.5, Vector3(77.0, 16.5, 78.0), Color(), Color(0.99, 0.99, 0.99), REFLECTION_REFRACTION)); // Glass ball
scene.addSphere(Sphere( 7.5, Vector3(50.0, 72.5, 81.6), Color(16, 16, 16), Color(), REFLECTION_DIFFUSE), true); // Light

Renderer renderer(256, 256, 4, 2);
renderer.render(scene);
const int width = 320;
const int height = 240;
Camera camera(width, height,
Vector3(50.0, 40.8, 220.0),
Vector3(0.0, 0.0, -1.0),
Vector3(0.0, 1.0, 0.0),
30.0,
30.0,
140.0,
5.0,
28.0);

Random rng = Random::getRNG();
const int samplePerPixel = 128;

PTRenderer renderer;
renderer.render(scene, camera, rng, samplePerPixel);

return 0;
}
7 changes: 6 additions & 1 deletion include/spica.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
#include "../src/geometry/primitive.h"
#include "../src/geometry/plane.h"
#include "../src/geometry/sphere.h"
#include "../src/renderer/renderer.h"
#include "../src/renderer/scene.h"
#include "../src/renderer/camera.h"

// --------------------------------------------
// Renderers
// --------------------------------------------

#include "../src/renderer/pt_renderer.h"
#include "../src/renderer/bpt_renderer.h"
#include "../src/renderer/mlt_renderer.h"

Expand Down
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
if(MSVC)
find_package(OpenMP)
if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
endif()

add_subdirectory(renderer)
add_subdirectory(geometry)
add_subdirectory(utils)
Expand Down
2 changes: 1 addition & 1 deletion src/geometry/sphere.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace spica {
}

hitpoint.setPosition(ray.origin() + hitpoint.distance() * ray.direction());
hitpoint.setNormal((hitpoint.position() - _center).normalize());
hitpoint.setNormal((hitpoint.position() - _center).normalized());

return true;
}
Expand Down
8 changes: 3 additions & 5 deletions src/renderer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ set(SOURCES
${CMAKE_CURRENT_LIST_DIR}/ray.cc
${CMAKE_CURRENT_LIST_DIR}/camera.cc
${CMAKE_CURRENT_LIST_DIR}/scene.cc
${CMAKE_CURRENT_LIST_DIR}/renderer.cc
${CMAKE_CURRENT_LIST_DIR}/renderer_base.cc
${CMAKE_CURRENT_LIST_DIR}/pt_renderer.cc
${CMAKE_CURRENT_LIST_DIR}/bpt_renderer.cc
${CMAKE_CURRENT_LIST_DIR}/mlt_renderer.cc
PARENT_SCOPE)
Expand All @@ -15,9 +14,8 @@ set(HEADERS
${CMAKE_CURRENT_LIST_DIR}/ray.h
${CMAKE_CURRENT_LIST_DIR}/camera.h
${CMAKE_CURRENT_LIST_DIR}/scene.h
${CMAKE_CURRENT_LIST_DIR}/renderer.h
${CMAKE_CURRENT_LIST_DIR}/renderer_base.h
${CMAKE_CURRENT_LIST_DIR}/bpt_renderer.h
${CMAKE_CURRENT_LIST_DIR}/material.h
${CMAKE_CURRENT_LIST_DIR}/pt_renderer.h
${CMAKE_CURRENT_LIST_DIR}/bpt_renderer.h
${CMAKE_CURRENT_LIST_DIR}/mlt_renderer.h
PARENT_SCOPE)
Loading

0 comments on commit d9c77eb

Please sign in to comment.