mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-06-07 23:12:00 +00:00
init
This commit is contained in:
commit
de866d23bf
28 changed files with 46878 additions and 0 deletions
57
CMakeLists.txt
Normal file
57
CMakeLists.txt
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
|
||||||
|
project(raytracer)
|
||||||
|
|
||||||
|
#IMPORTANT COMPILING DIRECTIVES
|
||||||
|
|
||||||
|
# 1
|
||||||
|
# Enable this when you start working on your solution and you add the file RayTracer.h
|
||||||
|
# in the src folder; Without this file the code base will not compile therefore in your
|
||||||
|
# code this define is disabled
|
||||||
|
# Also do not forget to create the src folder under code
|
||||||
|
#add_compile_options(-DSTUDENT_SOLUTION)
|
||||||
|
|
||||||
|
|
||||||
|
# 2
|
||||||
|
# This define is used by the teaching team to compile and run the official solution
|
||||||
|
# Students: for your project this define should always be commented out
|
||||||
|
# If we commit it by mistake please disable it and let us know
|
||||||
|
#add_compile_options(-DCOURSE_SOLUTION)
|
||||||
|
|
||||||
|
|
||||||
|
# When testing large scenes the debug mode will be very slow
|
||||||
|
# so switch to release
|
||||||
|
#set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
#set(CMAKE_BUILD_TYPE Release)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
|
||||||
|
set(CMAKE_PREFIX_PATH
|
||||||
|
/encs # For ENCS lab computers
|
||||||
|
/opt/local # Macports
|
||||||
|
)
|
||||||
|
|
||||||
|
# ENCS Eigen3 CMake setup
|
||||||
|
if (WIN32)
|
||||||
|
include_directories(C:/Users/ambec/Desktop/labs/COMP371_all/COMP371_RaytracerBase/code/eigen-3.4.0/)# for windows you can directly hardcode the paths to your libraries in the include
|
||||||
|
else()
|
||||||
|
set(ENV{EIGEN3_ROOT} /encs/pkg/eigen-3.3.7/root)
|
||||||
|
set(CMAKE_MODULE_PATH /encs/pkg/eigen-3.3.7/root/cmake)
|
||||||
|
|
||||||
|
find_package(Eigen3 REQUIRED)
|
||||||
|
include_directories(${EIGEN3_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
# If you need too manually add the paths to your Eigen library, you can add it here
|
||||||
|
# do not delete the other
|
||||||
|
|
||||||
|
# These folders include some important header files including the header files for your own solution
|
||||||
|
#do not remove
|
||||||
|
include_directories(src/)
|
||||||
|
include_directories(external/)
|
||||||
|
|
||||||
|
#internal includes
|
||||||
|
aux_source_directory(external SOURCE)
|
||||||
|
aux_source_directory(src SOURCE)
|
||||||
|
|
||||||
|
add_executable(raytracer main.cpp ${SOURCE}) #The name of the cpp file and its path can vary
|
||||||
|
|
37
README.txt
Normal file
37
README.txt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
|
||||||
|
This code is used for three purposes:
|
||||||
|
|
||||||
|
1) Build the official course solution
|
||||||
|
2) Build the student solution
|
||||||
|
3) Build a dummy application that showcases some of the codebase.
|
||||||
|
|
||||||
|
Each build is controlled by two defines:
|
||||||
|
COURSE_SOLUTION and STUDENT_SOLUTION.
|
||||||
|
|
||||||
|
If none of these variables are defined the dummy code is built. This is the default behaviour.
|
||||||
|
If COURSE_SOLUTION is defined, the code expects the course solution (this should never be defined)
|
||||||
|
IF STUDENT_SOLUTION is defined the code expects a student solution is implemented in the src folder. Have a look at the main.cpp file for the expected interface.
|
||||||
|
|
||||||
|
You can switch on and off these defines in the CMakeLists.txt file.
|
||||||
|
|
||||||
|
|
||||||
|
Building the dummy test
|
||||||
|
|
||||||
|
1) Create build folder: mkdir build
|
||||||
|
2) cd build
|
||||||
|
3) cmake ../
|
||||||
|
4) make
|
||||||
|
5) ./raytracer
|
||||||
|
|
||||||
|
Building the solution:
|
||||||
|
1) Uncomment the #add_compile_options(-DSTUDENT_SOLUTION) line in the CMakeLists.txt
|
||||||
|
2) Create build folder: mkdir build
|
||||||
|
3) Create the src folder: mkdir src
|
||||||
|
3) cd build
|
||||||
|
3) cmake ../
|
||||||
|
4) make
|
||||||
|
5) ./raytracer <filename.json>
|
||||||
|
|
||||||
|
|
||||||
|
Note that some test scenes are provided in the assets folder. You can do a soft link to the assets folder in the build folder for your convenience.
|
354
assets/cornell_box.json
Normal file
354
assets/cornell_box.json
Normal file
|
@ -0,0 +1,354 @@
|
||||||
|
{
|
||||||
|
"geometry":[{
|
||||||
|
"comment":"back_wall",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p2":[556, 0, -559],
|
||||||
|
"p1":[0, 0, -559],
|
||||||
|
"p4":[0, 548.8, -559],
|
||||||
|
"p3":[556, 548.8, -559],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"right_wall",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[556, 0, -559],
|
||||||
|
"p2":[556, 0, 0],
|
||||||
|
"p3":[556, 548.8, 0],
|
||||||
|
"p4":[556, 548.8, -559],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,0],
|
||||||
|
"dc":[1,0,0],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"left_wall",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p2":[0, 0, -559],
|
||||||
|
"p1":[0, 0, 0],
|
||||||
|
"p4":[0, 548.8, 0],
|
||||||
|
"p3":[0, 548.8, -559],
|
||||||
|
|
||||||
|
"ac":[0,1,0],
|
||||||
|
"dc":[0,1,0],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"ceiling",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[0, 548.8, 0],
|
||||||
|
"p2":[0, 548.8, -559],
|
||||||
|
"p3":[556, 548.8, -559.0],
|
||||||
|
"p4":[556, 548.8, 0],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"floor",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[0, 0, 0],
|
||||||
|
"p4":[0, 0, -559],
|
||||||
|
"p3":[556, 0, -559.0],
|
||||||
|
"p2":[556, 0, 0],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"small block top",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[130, 165, -65],
|
||||||
|
"p4":[82, 165, -225],
|
||||||
|
"p3":[240, 165, -272.0],
|
||||||
|
"p2":[290, 165, -114],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"small block right not visible",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[290, 0, -114],
|
||||||
|
"p4":[290, 165, -114],
|
||||||
|
"p3":[240, 165, -272.0],
|
||||||
|
"p2":[240, 0, -272],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"small block front",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[130, 0, -65],
|
||||||
|
"p4":[130, 165, -65],
|
||||||
|
"p3":[290, 165, -114.0],
|
||||||
|
"p2":[290, 0, -114],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[0,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"small block left side",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[82, 0, -225],
|
||||||
|
"p4":[82, 165, -225],
|
||||||
|
"p3":[130, 165, -65.0],
|
||||||
|
"p2":[130, 0, -65],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"large block top",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[423, 330, -247],
|
||||||
|
"p4":[265, 330, -296],
|
||||||
|
"p3":[314, 330, -456.0],
|
||||||
|
"p2":[472, 330, -406],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,0],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"large block right",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[423, 0, -247],
|
||||||
|
"p4":[423, 330, -247],
|
||||||
|
"p3":[472, 330, -406.0],
|
||||||
|
"p2":[472, 0, -406],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,0],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"large block back",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
|
||||||
|
"p1":[472, 0, -406],
|
||||||
|
"p4":[472, 330, -406],
|
||||||
|
"p3":[314, 330, -456.0],
|
||||||
|
"p2":[314, 0, -456],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"large block left side",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
|
||||||
|
"p1":[314, 0, -456],
|
||||||
|
"p4":[314, 330, -456],
|
||||||
|
"p3":[265, 330, -296.0],
|
||||||
|
"p2":[265, 0, -296],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[0,1,0],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"large block front",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[265, 0, -296],
|
||||||
|
"p4":[265, 330, -296],
|
||||||
|
"p3":[423, 330, -247.0],
|
||||||
|
"p2":[423, 0, -247],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,0],
|
||||||
|
"dc":[1,1,0],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
"light":[
|
||||||
|
|
||||||
|
{
|
||||||
|
"type":"area",
|
||||||
|
"p1":[343, 540,-227],
|
||||||
|
"p2":[343, 540,-332],
|
||||||
|
"p3":[213, 540,-332],
|
||||||
|
"p4":[213, 540,-227],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1],
|
||||||
|
"n": 5,
|
||||||
|
"usecenter": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[278, 273, 800],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1],
|
||||||
|
"use": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"output":[{
|
||||||
|
"filename":"cornell_box.ppm",
|
||||||
|
"size":[500,500],
|
||||||
|
"lookat":[0,0,-1],
|
||||||
|
"up":[0,1,0],
|
||||||
|
"fov":40,
|
||||||
|
"centre":[278, 273, 800],
|
||||||
|
"ai":[1,1,1],
|
||||||
|
"bkc":[0.5,0.5,0.5],
|
||||||
|
|
||||||
|
"globalillum": true,
|
||||||
|
"raysperpixel": [10, 10],
|
||||||
|
"maxbounces": 3,
|
||||||
|
"probterminate": 0.333
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
53
assets/cornell_box.ppm
Normal file
53
assets/cornell_box.ppm
Normal file
File diff suppressed because one or more lines are too long
354
assets/cornell_box_al.json
Normal file
354
assets/cornell_box_al.json
Normal file
|
@ -0,0 +1,354 @@
|
||||||
|
{
|
||||||
|
"geometry":[{
|
||||||
|
"comment":"back_wall",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p2":[556, 0, -559],
|
||||||
|
"p1":[0, 0, -559],
|
||||||
|
"p4":[0, 548.8, -559],
|
||||||
|
"p3":[556, 548.8, -559],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"right_wall",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[556, 0, -559],
|
||||||
|
"p2":[556, 0, 0],
|
||||||
|
"p3":[556, 548.8, 0],
|
||||||
|
"p4":[556, 548.8, -559],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,0],
|
||||||
|
"dc":[1,0,0],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"left_wall",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p2":[0, 0, -559],
|
||||||
|
"p1":[0, 0, 0],
|
||||||
|
"p4":[0, 548.8, 0],
|
||||||
|
"p3":[0, 548.8, -559],
|
||||||
|
|
||||||
|
"ac":[0,1,0],
|
||||||
|
"dc":[0,1,0],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"ceiling",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[0, 548.8, 0],
|
||||||
|
"p2":[0, 548.8, -559],
|
||||||
|
"p3":[556, 548.8, -559.0],
|
||||||
|
"p4":[556, 548.8, 0],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"floor",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[0, 0, 0],
|
||||||
|
"p4":[0, 0, -559],
|
||||||
|
"p3":[556, 0, -559.0],
|
||||||
|
"p2":[556, 0, 0],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"small block top",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[130, 165, -65],
|
||||||
|
"p4":[82, 165, -225],
|
||||||
|
"p3":[240, 165, -272.0],
|
||||||
|
"p2":[290, 165, -114],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"small block right not visible",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[290, 0, -114],
|
||||||
|
"p4":[290, 165, -114],
|
||||||
|
"p3":[240, 165, -272.0],
|
||||||
|
"p2":[240, 0, -272],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"small block front",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[130, 0, -65],
|
||||||
|
"p4":[130, 165, -65],
|
||||||
|
"p3":[290, 165, -114.0],
|
||||||
|
"p2":[290, 0, -114],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[0,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"small block left side",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[82, 0, -225],
|
||||||
|
"p4":[82, 165, -225],
|
||||||
|
"p3":[130, 165, -65.0],
|
||||||
|
"p2":[130, 0, -65],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"large block top",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[423, 330, -247],
|
||||||
|
"p4":[265, 330, -296],
|
||||||
|
"p3":[314, 330, -456.0],
|
||||||
|
"p2":[472, 330, -406],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,0],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"large block right",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[423, 0, -247],
|
||||||
|
"p4":[423, 330, -247],
|
||||||
|
"p3":[472, 330, -406.0],
|
||||||
|
"p2":[472, 0, -406],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,0],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"large block back",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
|
||||||
|
"p1":[472, 0, -406],
|
||||||
|
"p4":[472, 330, -406],
|
||||||
|
"p3":[314, 330, -456.0],
|
||||||
|
"p2":[314, 0, -456],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"large block left side",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
|
||||||
|
"p1":[314, 0, -456],
|
||||||
|
"p4":[314, 330, -456],
|
||||||
|
"p3":[265, 330, -296.0],
|
||||||
|
"p2":[265, 0, -296],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[0,1,0],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"large block front",
|
||||||
|
"type":"rectangle",
|
||||||
|
|
||||||
|
"p1":[265, 0, -296],
|
||||||
|
"p4":[265, 330, -296],
|
||||||
|
"p3":[423, 330, -247.0],
|
||||||
|
"p2":[423, 0, -247],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,0],
|
||||||
|
"dc":[1,1,0],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0,
|
||||||
|
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
"light":[
|
||||||
|
|
||||||
|
{
|
||||||
|
"type":"area",
|
||||||
|
"p1":[343, 540,-227],
|
||||||
|
"p2":[343, 540,-332],
|
||||||
|
"p3":[213, 540,-332],
|
||||||
|
"p4":[213, 540,-227],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1],
|
||||||
|
"n": 5,
|
||||||
|
"usecenter": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[278, 273, 800],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1],
|
||||||
|
"use": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"output":[{
|
||||||
|
"filename":"cornell_box_al.ppm",
|
||||||
|
"size":[500,500],
|
||||||
|
"lookat":[0,0,-1],
|
||||||
|
"up":[0,1,0],
|
||||||
|
"fov":40,
|
||||||
|
"centre":[278, 273, 800],
|
||||||
|
"ai":[1,1,1],
|
||||||
|
"bkc":[0.5,0.5,0.5],
|
||||||
|
|
||||||
|
"globalillum": false,
|
||||||
|
"raysperpixel": [10, 10],
|
||||||
|
"maxbounces": 3,
|
||||||
|
"probterminate": 0.333
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
14760
assets/cornell_box_al.ppm
Normal file
14760
assets/cornell_box_al.ppm
Normal file
File diff suppressed because one or more lines are too long
127
assets/cornell_box_empty_pl.json
Normal file
127
assets/cornell_box_empty_pl.json
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
{
|
||||||
|
"geometry":[{
|
||||||
|
"comment":"back_wall",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p2":[556, 0, -559],
|
||||||
|
"p1":[0, 0, -559],
|
||||||
|
"p4":[0, 548.8, -559],
|
||||||
|
"p3":[556, 548.8, -559],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":0.5,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"right_wall",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[556, 0, -559],
|
||||||
|
"p2":[556, 0, 0],
|
||||||
|
"p3":[556, 548.8, 0],
|
||||||
|
"p4":[556, 548.8, -559],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,0],
|
||||||
|
"dc":[1,0,0],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":0.5,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"left_wall",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p2":[0, 0, -559],
|
||||||
|
"p1":[0, 0, 0],
|
||||||
|
"p4":[0, 548.8, 0],
|
||||||
|
"p3":[0, 548.8, -559],
|
||||||
|
|
||||||
|
"ac":[0,1,0],
|
||||||
|
"dc":[0,1,0],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":0.5,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"ceiling",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[0, 548.8, 0],
|
||||||
|
"p2":[0, 548.8, -559],
|
||||||
|
"p3":[556, 548.8, -559.0],
|
||||||
|
"p4":[556, 548.8, 0],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"comment":"floor",
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[0, 0, 0],
|
||||||
|
"p4":[0, 0, -559],
|
||||||
|
"p3":[556, 0, -559.0],
|
||||||
|
"p2":[556, 0, 0],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[1,1,1],
|
||||||
|
"sc":[0,0,0],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":0.5,
|
||||||
|
"ks":0,
|
||||||
|
|
||||||
|
"pc":0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
"light":[
|
||||||
|
{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[278, 540,-279.5],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"output":[{
|
||||||
|
"filename":"cornell_box_empty_pl.ppm",
|
||||||
|
"size":[500,500],
|
||||||
|
"lookat":[0,0,-1],
|
||||||
|
"up":[0,1,0],
|
||||||
|
"fov":40,
|
||||||
|
"centre":[278, 273, 800],
|
||||||
|
"ai":[1,1,1],
|
||||||
|
"bkc":[0.5,0.5,0.5],
|
||||||
|
|
||||||
|
"globalillum": true,
|
||||||
|
"raysperpixel": [10, 10],
|
||||||
|
"maxbounces": 3,
|
||||||
|
"probterminate": 0.3333
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
11
assets/cornell_box_empty_pl.ppm
Normal file
11
assets/cornell_box_empty_pl.ppm
Normal file
File diff suppressed because one or more lines are too long
70
assets/test_area_light1.json
Normal file
70
assets/test_area_light1.json
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
{
|
||||||
|
"geometry":[{
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[-20, -1, 0],
|
||||||
|
"p2":[20, -1, 0],
|
||||||
|
"p3":[20, -1, -20],
|
||||||
|
"p4":[-20, -1, -20],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,0],
|
||||||
|
"dc":[1,0,0],
|
||||||
|
"sc":[1,1,1],
|
||||||
|
|
||||||
|
"ka":0.1,
|
||||||
|
"kd":1,
|
||||||
|
"ks":1,
|
||||||
|
|
||||||
|
"pc":10
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"sphere",
|
||||||
|
"centre":[0, 0, -4],
|
||||||
|
"radius":1,
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[0,0,1],
|
||||||
|
"sc":[1,1,1],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":1,
|
||||||
|
"pc":100
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
"light":[
|
||||||
|
{
|
||||||
|
"type":"area",
|
||||||
|
"p1":[-2, 7, -6],
|
||||||
|
"p2":[0, 7, -6],
|
||||||
|
"p4":[-2, 7, -4],
|
||||||
|
"p3":[0, 7, -4],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1],
|
||||||
|
"usecenter":false,
|
||||||
|
"n":10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[1,0.5,0],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"output":[{
|
||||||
|
"filename":"test_area_light1.ppm",
|
||||||
|
"size":[500,500],
|
||||||
|
"lookat":[0,0,-1],
|
||||||
|
"up":[0,1,0],
|
||||||
|
"fov":60,
|
||||||
|
"centre":[0,0.5,0],
|
||||||
|
"ai":[1,1,1],
|
||||||
|
"bkc":[0.5,0.5,0.5],
|
||||||
|
|
||||||
|
"globalillum": false,
|
||||||
|
"raysperpixel": [10, 10]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
2279
assets/test_area_light1.ppm
Normal file
2279
assets/test_area_light1.ppm
Normal file
File diff suppressed because one or more lines are too long
36
assets/test_scene1.json
Normal file
36
assets/test_scene1.json
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"geometry":[{
|
||||||
|
"type":"sphere",
|
||||||
|
"centre":[0, 0, -4],
|
||||||
|
"radius":2,
|
||||||
|
|
||||||
|
"ac":[0,1,0],
|
||||||
|
"dc":[1,0,0],
|
||||||
|
"sc":[1,1,1],
|
||||||
|
|
||||||
|
"ka":1,
|
||||||
|
"kd":1,
|
||||||
|
"ks":1,
|
||||||
|
|
||||||
|
"pc":10
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"light":[{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[0, 0, 0],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1]
|
||||||
|
|
||||||
|
}],
|
||||||
|
"output":[{
|
||||||
|
"filename":"test_scene1.ppm",
|
||||||
|
"size":[500,500],
|
||||||
|
"lookat":[0,0,-1],
|
||||||
|
"up":[0,1,0],
|
||||||
|
"fov":90,
|
||||||
|
"centre":[0,0,0],
|
||||||
|
"ai":[1,1,1],
|
||||||
|
"bkc":[1,1,1]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
632
assets/test_scene1.ppm
Normal file
632
assets/test_scene1.ppm
Normal file
File diff suppressed because one or more lines are too long
44
assets/test_scene1B.json
Normal file
44
assets/test_scene1B.json
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
{
|
||||||
|
"geometry":[{
|
||||||
|
"type":"sphere",
|
||||||
|
"centre":[2, 0, -6],
|
||||||
|
"radius":2,
|
||||||
|
|
||||||
|
"ac":[0,1,0],
|
||||||
|
"dc":[0,0,1],
|
||||||
|
"sc":[1,1,1],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":1,
|
||||||
|
|
||||||
|
"pc":100
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"light":[{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[0, 0, 0],
|
||||||
|
"id":[0.5, 0.5, 0.5],
|
||||||
|
"is":[1, 1, 1]
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[2, 4, 0],
|
||||||
|
"id":[0.5, 0.5, 0.5],
|
||||||
|
"is":[1, 1, 1]
|
||||||
|
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"output":[{
|
||||||
|
"filename":"test_scene1B.ppm",
|
||||||
|
"size":[1000,500],
|
||||||
|
"lookat":[0,0,-1],
|
||||||
|
"up":[0,1,0],
|
||||||
|
"fov":60,
|
||||||
|
"centre":[0,0,0],
|
||||||
|
"ai":[1,1,1],
|
||||||
|
"bkc":[0.4,0.4,0.4]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
469
assets/test_scene1B.ppm
Normal file
469
assets/test_scene1B.ppm
Normal file
File diff suppressed because one or more lines are too long
38
assets/test_scene2.json
Normal file
38
assets/test_scene2.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"geometry":[{
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[-2, 2, -4],
|
||||||
|
"p2":[-2, -2, -4],
|
||||||
|
"p3":[2, -2, -4],
|
||||||
|
"p4":[2, 2, -4],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[0,1,0],
|
||||||
|
"dc":[1,0,0],
|
||||||
|
"sc":[1,1,1],
|
||||||
|
|
||||||
|
"ka":0.1,
|
||||||
|
"kd":1,
|
||||||
|
"ks":1,
|
||||||
|
|
||||||
|
"pc":10
|
||||||
|
|
||||||
|
}],
|
||||||
|
"light":[{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[0, 0, 0],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1]
|
||||||
|
}],
|
||||||
|
"output":[{
|
||||||
|
"filename":"test_scene2.ppm",
|
||||||
|
"size":[500,500],
|
||||||
|
"lookat":[0,0,-1],
|
||||||
|
"up":[0,1,0],
|
||||||
|
"fov":90,
|
||||||
|
"centre":[0,0,0],
|
||||||
|
"ai":[1,1,1],
|
||||||
|
"bkc":[1,1,1]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
4
assets/test_scene2.ppm
Normal file
4
assets/test_scene2.ppm
Normal file
File diff suppressed because one or more lines are too long
62
assets/test_scene3.json
Normal file
62
assets/test_scene3.json
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
{
|
||||||
|
"geometry":[{
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[-20, -1, 0],
|
||||||
|
"p2":[20, -1, 0],
|
||||||
|
"p3":[20, -1, -20],
|
||||||
|
"p4":[-20, -1, -20],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[0,1,0],
|
||||||
|
"dc":[1,0,0],
|
||||||
|
"sc":[1,1,1],
|
||||||
|
|
||||||
|
"ka":1,
|
||||||
|
"kd":1,
|
||||||
|
"ks":1,
|
||||||
|
|
||||||
|
"pc":10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"sphere",
|
||||||
|
"centre":[0, 0, -4],
|
||||||
|
"radius":1,
|
||||||
|
"ac":[1,0,0],
|
||||||
|
"dc":[0,0,1],
|
||||||
|
"sc":[1,1,1],
|
||||||
|
|
||||||
|
"ka":0.2,
|
||||||
|
"kd":1,
|
||||||
|
"ks":1,
|
||||||
|
|
||||||
|
"pc":10
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
"light":[
|
||||||
|
{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[0, 7, -5],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[0,0.5,0],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"output":[{
|
||||||
|
"filename":"test_scene3.ppm",
|
||||||
|
"size":[500,500],
|
||||||
|
"lookat":[0,0,-1],
|
||||||
|
"up":[0,1,0],
|
||||||
|
"fov":60,
|
||||||
|
"centre":[0,0.5,0],
|
||||||
|
"ai":[1,1,1],
|
||||||
|
"bkc":[1,1,1]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1160
assets/test_scene3.ppm
Normal file
1160
assets/test_scene3.ppm
Normal file
File diff suppressed because one or more lines are too long
79
assets/test_scene3B.json
Normal file
79
assets/test_scene3B.json
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
{
|
||||||
|
"geometry":[{
|
||||||
|
"type":"rectangle",
|
||||||
|
"p1":[-20, -1, 0],
|
||||||
|
"p2":[20, -1, 0],
|
||||||
|
"p3":[20, -1, -20],
|
||||||
|
"p4":[-20, -1, -20],
|
||||||
|
|
||||||
|
|
||||||
|
"ac":[1,0,0],
|
||||||
|
"dc":[1,0,0],
|
||||||
|
"sc":[1,1,1],
|
||||||
|
|
||||||
|
"ka":0.1,
|
||||||
|
"kd":1,
|
||||||
|
"ks":1,
|
||||||
|
|
||||||
|
"pc":10
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"sphere",
|
||||||
|
"centre":[0, 0, -4],
|
||||||
|
"radius":1,
|
||||||
|
"ac":[1,1,1],
|
||||||
|
"dc":[0,0,1],
|
||||||
|
"sc":[1,1,1],
|
||||||
|
|
||||||
|
"ka":0,
|
||||||
|
"kd":1,
|
||||||
|
"ks":1,
|
||||||
|
"pc":100
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
"light":[
|
||||||
|
{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[-1, 7, -5],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"point",
|
||||||
|
"centre":[1,0.5,0],
|
||||||
|
"id":[1, 1, 1],
|
||||||
|
"is":[1, 1, 1]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"output":[{
|
||||||
|
"filename":"test_scene3B.ppm",
|
||||||
|
"size":[500,500],
|
||||||
|
"lookat":[0,0,-1],
|
||||||
|
"up":[0,1,0],
|
||||||
|
"fov":60,
|
||||||
|
"centre":[0,0.5,0],
|
||||||
|
"ai":[1,1,1],
|
||||||
|
"bkc":[0.5,0.5,0.5],
|
||||||
|
|
||||||
|
"globalillum": false,
|
||||||
|
"raysperpixel": [10, 10]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename":"test_scene3B_aa.ppm",
|
||||||
|
"size":[500,500],
|
||||||
|
"lookat":[0,0,-1],
|
||||||
|
"up":[0,1,0],
|
||||||
|
"fov":60,
|
||||||
|
"centre":[0,0.5,0],
|
||||||
|
"ai":[1,1,1],
|
||||||
|
"bkc":[0.5,0.5,0.5],
|
||||||
|
|
||||||
|
"globalillum": false,
|
||||||
|
"antialiasing":true,
|
||||||
|
"raysperpixel": [10, 10]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1865
assets/test_scene3B.ppm
Normal file
1865
assets/test_scene3B.ppm
Normal file
File diff suppressed because one or more lines are too long
1905
assets/test_scene3B_aa.ppm
Normal file
1905
assets/test_scene3B_aa.ppm
Normal file
File diff suppressed because one or more lines are too long
22100
external/json.hpp
vendored
Normal file
22100
external/json.hpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
25
external/simpleppm.cpp
vendored
Normal file
25
external/simpleppm.cpp
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#include "simpleppm.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
This code was adapted from here:
|
||||||
|
https://rosettacode.org/wiki/Bitmap/Write_a_PPM_file#C.2B.2B
|
||||||
|
*/
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int save_ppm(std::string file_name, const std::vector<double>& buffer, int dimx, int dimy) {
|
||||||
|
|
||||||
|
ofstream ofs(file_name, ios_base::out | ios_base::binary);
|
||||||
|
ofs << "P6" << endl << dimx << ' ' << dimy << endl << "255" << endl;
|
||||||
|
|
||||||
|
for (unsigned int j = 0; j < dimy; ++j)
|
||||||
|
for (unsigned int i = 0; i < dimx; ++i)
|
||||||
|
ofs << (char) (255.0 * buffer[3*j*dimx+3*i+0]) << (char) (255.0 * buffer[3*j*dimx+3*i+1]) << (char) (255.0 * buffer[3*j*dimx+3*i+2]);
|
||||||
|
|
||||||
|
ofs.close();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
9
external/simpleppm.h
vendored
Normal file
9
external/simpleppm.h
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
int save_ppm(std::string file_name, const std::vector<double>& buffer, int dimx, int dimy);
|
||||||
|
|
||||||
|
int test_save_ppm();
|
42
external/test_eigen.cpp
vendored
Normal file
42
external/test_eigen.cpp
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <Eigen/Core>
|
||||||
|
#include <Eigen/Dense>
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
int print_eigen(Eigen::Matrix4d m)
|
||||||
|
{
|
||||||
|
// Eigen Matrices do have rule to print them with std::cout
|
||||||
|
std::cout << m << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_eigen()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
Eigen::Matrix4d test; //4 by 4 double precision matrix initialization
|
||||||
|
|
||||||
|
// Let's make it a symmetric matrix
|
||||||
|
for(int i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
for(int j=0; j<4; j++)
|
||||||
|
test(i,j) = (i+1)*(1+j);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print
|
||||||
|
print_eigen(test);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
169
external/test_json.cpp
vendored
Normal file
169
external/test_json.cpp
vendored
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <Eigen/Core>
|
||||||
|
#include <Eigen/Dense>
|
||||||
|
|
||||||
|
#include "json.hpp"
|
||||||
|
#include "simpleppm.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace nlohmann;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool test_parse_geometry(json& j){
|
||||||
|
cout<<"Geometry: "<<endl;
|
||||||
|
int gc = 0;
|
||||||
|
|
||||||
|
// use iterators to read-in array types
|
||||||
|
for (auto itr = j["geometry"].begin(); itr!= j["geometry"].end(); itr++){
|
||||||
|
|
||||||
|
std::string type;
|
||||||
|
if(itr->contains("type")){
|
||||||
|
// type = static_cast<std::string>((*itr)["type"]);
|
||||||
|
type = (*itr)["type"].get<std::string>();
|
||||||
|
} else {
|
||||||
|
cout<<"Fatal error: geometry shoudl always contain a type!!!"<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type=="sphere"){
|
||||||
|
cout<<"Sphere: "<<endl;
|
||||||
|
Eigen::Vector3f centre(0,0,0);
|
||||||
|
int i = 0;
|
||||||
|
for (auto itr2 =(*itr)["centre"].begin(); itr2!= (*itr)["centre"].end(); itr2++){
|
||||||
|
if(i<3){
|
||||||
|
centre[i++] = (*itr2).get<float>();
|
||||||
|
} else {
|
||||||
|
cout<<"Warning: Too many entries in centre"<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<"Centre: "<<centre<<endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
++gc;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout<<"We have: "<<gc<<" objects!"<<endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool test_parse_lights(json& j){
|
||||||
|
cout<<"Light: "<<endl;
|
||||||
|
int lc = 0;
|
||||||
|
|
||||||
|
// use iterators to read-in array types
|
||||||
|
for (auto itr = j["light"].begin(); itr!= j["light"].end(); itr++){
|
||||||
|
|
||||||
|
std::string type;
|
||||||
|
if(itr->contains("type")){
|
||||||
|
// type = static_cast<std::string>((*itr)["type"]);
|
||||||
|
type = (*itr)["type"].get<std::string>();
|
||||||
|
} else {
|
||||||
|
cout<<"Fatal error: light shoudl always contain a type!!!"<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type=="point"){
|
||||||
|
cout<<"Point based light: "<<endl;
|
||||||
|
Eigen::Vector3f centre(0,0,0);
|
||||||
|
int i = 0;
|
||||||
|
for (auto itr2 =(*itr)["centre"].begin(); itr2!= (*itr)["centre"].end(); itr2++){
|
||||||
|
if(i<3){
|
||||||
|
centre[i++] = (*itr2).get<float>();
|
||||||
|
} else {
|
||||||
|
cout<<"Warning: Too many entries in centre"<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<"Centre: "<<centre<<endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
++lc;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout<<"We have: "<<lc<<" objects!"<<endl;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool test_parse_output(json& j){
|
||||||
|
cout<<"Outputs: "<<endl;
|
||||||
|
int lc = 0;
|
||||||
|
|
||||||
|
// use iterators to read-in array types
|
||||||
|
for (auto itr = j["output"].begin(); itr!= j["output"].end(); itr++){
|
||||||
|
|
||||||
|
std::string filename;
|
||||||
|
if(itr->contains("filename")){
|
||||||
|
// filename = static_cast<std::string>((*itr)["filename"]);
|
||||||
|
filename = (*itr)["filename"].get<std::string>();
|
||||||
|
} else {
|
||||||
|
cout<<"Fatal error: output shoudl always contain a filename!!!"<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int size[2];
|
||||||
|
int i = 0;
|
||||||
|
for (auto itr2 =(*itr)["size"].begin(); itr2!= (*itr)["size"].end(); itr2++){
|
||||||
|
if(i<2){
|
||||||
|
size[i++] = (*itr2).get<float>();
|
||||||
|
} else {
|
||||||
|
cout<<"Warning: Too many entries in size"<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Eigen::Vector3f lookat(0,0,0), up(0,0,0), centre(0,0,0);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
for (auto itr2 =(*itr)["centre"].begin(); itr2!= (*itr)["centre"].end(); itr2++){
|
||||||
|
if(i<3){
|
||||||
|
centre[i++] = (*itr2).get<float>();
|
||||||
|
} else {
|
||||||
|
cout<<"Warning: Too many entries in centre"<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Similarly to the centre array you need to read the lookat and up
|
||||||
|
//Maybe create a separate functiomn to read arrays - ythey are pretty common
|
||||||
|
|
||||||
|
|
||||||
|
// I am retrieving the field of view
|
||||||
|
// this is mandatory field here, but if I dont check if it exists,
|
||||||
|
// the code will throw an exception which if not caught will end the execution of yoru program
|
||||||
|
cout<<"A"<<endl;
|
||||||
|
float fov = (*itr)["fov"].get<float>();
|
||||||
|
cout<<"B"<<endl;
|
||||||
|
|
||||||
|
cout<<"Filename: "<<filename<<endl;
|
||||||
|
cout<<"Camera centre: "<<centre<<endl;
|
||||||
|
cout<<"FOV: "<<fov<<endl;
|
||||||
|
|
||||||
|
++lc;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout<<"We have: "<<lc<<" objects!"<<endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_json(json& j){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 1 - parse geometry
|
||||||
|
test_parse_geometry(j);
|
||||||
|
|
||||||
|
// 2 - parse lights
|
||||||
|
test_parse_lights(j);
|
||||||
|
|
||||||
|
// 3 - parse lights
|
||||||
|
test_parse_output(j);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
43
external/test_ppm.cpp
vendored
Normal file
43
external/test_ppm.cpp
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <Eigen/Core>
|
||||||
|
#include <Eigen/Dense>
|
||||||
|
|
||||||
|
#include "json.hpp"
|
||||||
|
#include "simpleppm.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace nlohmann;
|
||||||
|
|
||||||
|
|
||||||
|
int test_save_ppm(){
|
||||||
|
int dimx = 800;
|
||||||
|
int dimy = 600;
|
||||||
|
|
||||||
|
int w = 100;
|
||||||
|
|
||||||
|
std::vector<double> buffer(3*dimx*dimy);
|
||||||
|
for(int j=0;j<dimy;++j){
|
||||||
|
for(int i=0;i<dimx;++i){
|
||||||
|
if(((i+j)/w)%2==0){
|
||||||
|
buffer[3*j*dimx+3*i+0]=1;
|
||||||
|
buffer[3*j*dimx+3*i+1]=1;
|
||||||
|
buffer[3*j*dimx+3*i+2]=0;
|
||||||
|
} else {
|
||||||
|
buffer[3*j*dimx+3*i+0]=0;
|
||||||
|
buffer[3*j*dimx+3*i+1]=1;
|
||||||
|
buffer[3*j*dimx+3*i+2]=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
save_ppm("test.ppm", buffer, dimx, dimy);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
94
main.cpp
Normal file
94
main.cpp
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef COURSE_SOLUTION
|
||||||
|
#include "src/RayTracer.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STUDENT_SOLUTION
|
||||||
|
#include "src/RayTracer.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <Eigen/Core>
|
||||||
|
#include <Eigen/Dense>
|
||||||
|
|
||||||
|
#include "external/json.hpp"
|
||||||
|
#include "external/simpleppm.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int test_eigen();
|
||||||
|
int test_save_ppm();
|
||||||
|
int test_json(nlohmann::json& j);
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
if(argc!=2){
|
||||||
|
cout<<"Invalid number of arguments"<<endl;
|
||||||
|
cout<<"Usage: ./raytracer [scene] "<<endl;
|
||||||
|
cout<<"Run sanity checks"<<endl;
|
||||||
|
|
||||||
|
test_eigen();
|
||||||
|
test_save_ppm();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
cout<<"Scene: "<<argv[1]<<endl;
|
||||||
|
|
||||||
|
std::ifstream t(argv[1]);
|
||||||
|
if(!t){
|
||||||
|
cout<<"File "<<argv[1]<<" does not exist!"<<endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::stringstream buffer;
|
||||||
|
buffer << t.rdbuf();
|
||||||
|
|
||||||
|
nlohmann::json j = nlohmann::json::parse(buffer.str());
|
||||||
|
cout<<"Parsed successfuly"<<endl;
|
||||||
|
|
||||||
|
#ifdef COURSE_SOLUTION
|
||||||
|
srand(234);
|
||||||
|
cout<<"Running course solution"<<endl;
|
||||||
|
time_t tstart, tend;
|
||||||
|
tstart = time(0);
|
||||||
|
RT371::RayTracer<RT371::Kernelf> rt(j);
|
||||||
|
cout<<"Running!"<<endl;
|
||||||
|
rt.run();
|
||||||
|
tend = time(0);
|
||||||
|
cout << "It took "<< difftime(tend, tstart) <<" second(s)."<< endl;
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifdef STUDENT_SOLUTION
|
||||||
|
cout<<"Running student solution"<<endl;
|
||||||
|
|
||||||
|
time_t tstart, tend;
|
||||||
|
tstart = time(0);
|
||||||
|
RayTracer rt(j);
|
||||||
|
rt.run();
|
||||||
|
tend = time(0);
|
||||||
|
cout << "It took "<< difftime(tend, tstart) <<" second(s)."<< endl;
|
||||||
|
#else
|
||||||
|
// GIven code - a bunch of test functions to showcase the funcitonality
|
||||||
|
test_eigen();
|
||||||
|
test_save_ppm();
|
||||||
|
|
||||||
|
if(test_json(j)==0){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cout<<"Could not load file!"<<endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue