Skip to content

Commit

Permalink
Merge 7b53d9c into fb440d1
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsy committed Apr 21, 2015
2 parents fb440d1 + 7b53d9c commit 5c6be64
Show file tree
Hide file tree
Showing 7 changed files with 481 additions and 8 deletions.
10 changes: 3 additions & 7 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ function (generate_example example_name)
add_executable(${example_name} "${example_name}_example.cc")
target_link_libraries(${example_name} "${LIB_PREFIX}spica_renderer${LIB_SUFFIX}")
configure_file(project.vcxproj.user.in "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${example_name}.vcxproj.user" @ONLY)

endif()
endfunction()

add_executable(simplept simplept_example.cc)
add_executable(simplebpt simplebpt_example.cc)

target_link_libraries(simplept "${LIB_PREFIX}spica_renderer${LIB_SUFFIX}")
target_link_libraries(simplebpt "${LIB_PREFIX}spica_renderer${LIB_SUFFIX}")
generate_example(simplept)
generate_example(simplebpt)
generate_example(simplemlt)

include_directories(${CMAKE_CURRENT_LIST_DIR})
37 changes: 37 additions & 0 deletions example/simplemlt_example.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <iostream>

#include "../include/spica.h"
using namespace spica;


int main(int argc, char **argv) {
std::cout << "Metropolis light transport" << std::endl;

Scene scene;
scene.addSphere(Sphere(5.0, Vector3(50.0, 75.0, 81.6), Color(12, 12, 12), Color(), REFLECTION_DIFFUSE), true); // Light
scene.addSphere(Sphere(1e5, Vector3(1e5 + 1, 40.8, 81.6), Color(), Color(0.75, 0.25, 0.25), REFLECTION_DIFFUSE)); // Left
scene.addSphere(Sphere(1e5, Vector3(-1e5 + 99, 40.8, 81.6), Color(), Color(0.25, 0.25, 0.75), REFLECTION_DIFFUSE)); // Right
scene.addSphere(Sphere(1e5, Vector3(50, 40.8, 1e5), Color(), Color(0.75, 0.75, 0.75), REFLECTION_DIFFUSE)); // Back
scene.addSphere(Sphere(1e5, Vector3(50, 40.8, -1e5 + 170), Color(), Color(), REFLECTION_DIFFUSE)); // Front
scene.addSphere(Sphere(1e5, Vector3(50, 1e5, 81.6), Color(), Color(0.75, 0.75, 0.75), REFLECTION_DIFFUSE)); // Floor
scene.addSphere(Sphere(1e5, Vector3(50, -1e5 + 81.6, 81.6), Color(), Color(0.75, 0.75, 0.75), REFLECTION_DIFFUSE)); // Ceil
scene.addSphere(Sphere(16.5, Vector3(27, 16.5, 47), Color(), Color(1, 1, 1)*.99, REFLECTION_SPECULAR)); // Mirror
scene.addSphere(Sphere(16.5, Vector3(73, 16.5, 78), Color(), Color(1, 1, 1)*.99, REFLECTION_REFRACTION)); // Glass

const int width = 320;
const int height = 240;
const int mutation = 32 * width * height;
const int mlt_num = 32;
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());
Vector3 cx = Vector3(width * 0.5135 / height, 0.0, 0.0);
Vector3 cy = cx.cross(camera.direction()).normalize() * 0.5135;
Image image(width, height);

MLTRenderer renderer;
renderer.render(scene, mlt_num, mutation, image, camera, cx, cy, width, height, maxDepth, rng);

image.savePPM("simplemlt.ppm");
}
1 change: 1 addition & 0 deletions include/spica.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
#include "../src/renderer/scene.h"
#include "../src/renderer/camera.h"
#include "../src/renderer/bpt_renderer.h"
#include "../src/renderer/mlt_renderer.h"

#endif // SPICA_H_
2 changes: 2 additions & 0 deletions src/renderer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(SOURCES
${CMAKE_CURRENT_LIST_DIR}/renderer.cc
${CMAKE_CURRENT_LIST_DIR}/renderer_base.cc
${CMAKE_CURRENT_LIST_DIR}/bpt_renderer.cc
${CMAKE_CURRENT_LIST_DIR}/mlt_renderer.cc
PARENT_SCOPE)

set(HEADERS
Expand All @@ -18,4 +19,5 @@ set(HEADERS
${CMAKE_CURRENT_LIST_DIR}/renderer_base.h
${CMAKE_CURRENT_LIST_DIR}/bpt_renderer.h
${CMAKE_CURRENT_LIST_DIR}/material.h
${CMAKE_CURRENT_LIST_DIR}/mlt_renderer.h
PARENT_SCOPE)
Loading

0 comments on commit 5c6be64

Please sign in to comment.