gam0022 / hanamaru-renderer

PathTracing in Rust
62 stars 2 forks source link

レイトレ合宿6 #24

Open gam0022 opened 6 years ago

gam0022 commented 6 years ago

memo

Amazon Linux用バイナリ作成

これを参考にセットアップ。

cargo build --release --target x86_64-unknown-linux-musl

for Mac

cargo build --release --target x86_64-apple-darwin

tar

#圧縮
# tar zcvf camp-2018-08-28.tar.gz hanamaru-renderer-submit
COPYFILE_DISABLE=1 tar zcvf camp-2018-08-30.tar.gz --exclude ".DS_Store" hanamaru-renderer-submit

# 解凍
tar zxvf camp-2018-08-28.tar.gz

テスト実行

# 本番の品質を検証したい
cargo run --release -- -t 1047

# 低品質で出したい
cargo run --release -- -w 480 -h 270 -s 1

# デバッグ出力したい
cargo run --release -- -d
gam0022 commented 6 years ago

ライブラリバージョン

 ~/Dropbox/hanamaru-renderer  rtcamp6●  (;_;) 1  cargo outdated                                                                                                08:59:33
Name                           Project  Compat   Latest   Kind    Platform
----                           -------  ------   ------   ----    --------
coco->either                   1.1.0    Removed  Removed  Normal  ---
coco->scopeguard               0.3.2    Removed  Removed  Normal  ---
conv->custom_derive            0.1.7    Removed  Removed  Normal  ---
deflate->adler32               1.0.0    1.0.3    1.0.3    Normal  ---
deflate->byteorder             1.1.0    1.2.6    1.2.6    Normal  ---
enum_primitive->num-traits     0.1.40   Removed  Removed  Normal  ---
gif->color_quant               1.0.0    1.0.1    1.0.1    Normal  ---
image                          0.14.0   0.19.0   0.19.0   Normal  ---
image->byteorder               1.1.0    1.2.6    1.2.6    Normal  ---
image->enum_primitive          0.1.1    Removed  Removed  Normal  ---
image->gif                     0.9.2    0.10.0   0.10.0   Normal  ---
image->jpeg-decoder            0.1.13   0.1.15   0.1.15   Normal  ---
image->num-iter                0.1.34   0.1.37   0.1.37   Normal  ---
image->num-rational            0.1.39   0.1.42   0.1.42   Normal  ---
image->num-traits              0.1.40   0.2.5    0.2.5    Normal  ---
image->png                     0.8.0    0.12.0   0.12.0   Normal  ---
image->scoped_threadpool       0.1.7    0.1.9    0.1.9    Normal  ---
jpeg-decoder->byteorder        1.1.0    1.2.6    1.2.6    Normal  ---
jpeg-decoder->rayon            0.8.2    1.0.2    1.0.2    Normal  ---
kernel32-sys->winapi           0.2.8    Removed  Removed  Normal  ---
kernel32-sys->winapi-build     0.1.1    Removed  Removed  Build   ---
magenta->conv                  0.3.3    Removed  Removed  Normal  ---
magenta->magenta-sys           0.1.1    Removed  Removed  Normal  ---
magenta-sys->bitflags          0.7.0    Removed  Removed  Normal  ---
num                            0.1.40   0.2.0    0.2.0    Normal  ---
num->num-bigint                0.1.40   0.2.0    0.2.0    Normal  ---
num->num-complex               0.1.40   0.2.0    0.2.0    Normal  ---
num->num-integer               0.1.35   0.1.39   0.1.39   Normal  ---
num->num-iter                  0.1.34   0.1.37   0.1.37   Normal  ---
num->num-rational              0.1.39   0.2.1    0.2.1    Normal  ---
num->num-traits                0.1.40   0.2.5    0.2.5    Normal  ---
num-bigint->num-integer        0.1.35   0.1.39   0.1.39   Normal  ---
num-bigint->num-integer        0.1.35   Removed  Removed  Normal  ---
num-bigint->num-traits         0.1.40   0.2.5    0.2.5    Normal  ---
num-bigint->num-traits         0.1.40   Removed  Removed  Normal  ---
num-bigint->rand               0.3.16   Removed  Removed  Normal  ---
num-bigint->rustc-serialize    0.3.24   Removed  Removed  Normal  ---
num-complex->num-traits        0.1.40   0.2.5    0.2.5    Normal  ---
num-complex->rustc-serialize   0.3.24   Removed  Removed  Normal  ---
num-integer->num-traits        0.1.40   0.2.5    0.2.5    Normal  ---
num-integer->num-traits        0.1.40   Removed  Removed  Normal  ---
num-iter->num-integer          0.1.35   0.1.39   0.1.39   Normal  ---
num-iter->num-traits           0.1.40   0.2.5    0.2.5    Normal  ---
num-rational->num-bigint       0.1.40   0.2.0    0.2.0    Normal  ---
num-rational->num-bigint       0.1.40   Removed  Removed  Normal  ---
num-rational->num-integer      0.1.35   0.1.39   0.1.39   Normal  ---
num-rational->num-traits       0.1.40   0.2.5    0.2.5    Normal  ---
num-rational->rustc-serialize  0.3.24   Removed  Removed  Normal  ---
num_cpus->libc                 0.2.28   0.2.43   0.2.43   Normal  ---
png->bitflags                  0.9.1    1.0.4    1.0.4    Normal  ---
png->deflate                   0.7.14   0.7.18   0.7.18   Normal  ---
png->inflate                   0.2.0    0.4.3    0.4.3    Normal  ---
png->num-iter                  0.1.34   0.1.37   0.1.37   Normal  ---
rand                           0.3.16   0.3.22   0.5.5    Normal  ---
rand->libc                     0.2.28   0.2.43   0.2.43   Normal  ---
rand->libc                     0.2.28   Removed  Removed  Normal  ---
rand->magenta                  0.1.1    Removed  Removed  Normal  cfg(target_os = "fuchsia")
rayon                          0.8.2    ---      1.0.2    Normal  ---
rayon->rayon-core              1.2.1    1.4.1    1.4.1    Normal  ---
rayon-core->coco               0.1.1    Removed  Removed  Normal  ---
rayon-core->futures            0.1.14   Removed  Removed  Normal  ---
rayon-core->lazy_static        0.2.8    1.1.0    1.1.0    Normal  ---
rayon-core->libc               0.2.28   0.2.43   0.2.43   Normal  ---
rayon-core->num_cpus           1.6.2    1.8.0    1.8.0    Normal  ---
rayon-core->rand               0.3.16   Removed  Removed  Normal  ---
time                           0.1.38   0.1.40   0.1.40   Normal  ---
time->kernel32-sys             0.2.2    Removed  Removed  Normal  cfg(windows)
time->libc                     0.2.28   0.2.43   0.2.43   Normal  ---
time->redox_syscall            0.1.29   0.1.40   0.1.40   Normal  cfg(target_os = "redox")
time->winapi                   0.2.8    0.3.5    0.3.5    Normal  cfg(windows)
gam0022 commented 6 years ago
バージョンアップ前 20x4spp: total 57.017 sec. used 0.40 % (x 252.56)
gam0022 commented 6 years ago
  ...

error[E0061]: this function takes 1 parameter but 2 parameters were supplied
   --> src\main.rs:807:38
    |
807 |     let _ = image::ImageRgb8(imgbuf).save(fout, image::PNG);
    |                                      ^^^^ expected 1 parameter

error[E0061]: this function takes 1 parameter but 2 parameters were supplied
  --> src\renderer.rs:88:50
   |
88 |         let _ = image::ImageRgb8(imgbuf.clone()).save(fout, image::PNG);
   |                                                  ^^^^ expected 1 parameter

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0061`.
error: Could not compile `hanamaru-renderer`.

To learn more, run the command again with --verbose.
gam0022 commented 6 years ago

cargo updae後

sampled: 20x4 spp.
total 57.156 sec. used 0.40 % (x 251.94)
gam0022 commented 6 years ago
 ~/Dropbox/hanamaru-renderer  rtcamp6  ('-') 0  cargo outdated                                                                                                 09:14:04
Name                                  Project  Compat  Latest   Kind    Platform
----                                  -------  ------  ------   ----    --------
fuchsia-zircon->bitflags              1.0.4    ---     Removed  Normal  ---
fuchsia-zircon->fuchsia-zircon-sys    0.3.3    ---     Removed  Normal  ---
rand                                  0.3.22   ---     0.5.5    Normal  ---
rand->fuchsia-zircon                  0.3.3    ---     Removed  Normal  cfg(target_os = "fuchsia")
rand->libc                            0.2.43   ---     Removed  Normal  cfg(unix)
rand->rand                            0.4.3    ---     Removed  Normal  ---
rand->winapi                          0.3.5    ---     Removed  Normal  cfg(windows)
rayon                                 0.8.2    ---     1.0.2    Normal  ---
winapi->winapi-i686-pc-windows-gnu    0.4.0    ---     Removed  Normal  i686-pc-windows-gnu
winapi->winapi-x86_64-pc-windows-gnu  0.4.0    ---     Removed  Normal  x86_64-pc-windows-gnu
gam0022 commented 6 years ago

rayon 0.8.2 -> 1.0.2 total 57.005 sec. used 0.40 % (x 252.61)

gam0022 commented 6 years ago
 ~/Dropbox/hanamaru-renderer  rtcamp6  ('-') 0  cargo outdated                                                                                                 10:02:50
Name                                  Project  Compat  Latest   Kind    Platform
----                                  -------  ------  ------   ----    --------
fuchsia-zircon->bitflags              1.0.4    ---     Removed  Normal  ---
fuchsia-zircon->fuchsia-zircon-sys    0.3.3    ---     Removed  Normal  ---
rand                                  0.3.22   ---     0.5.5    Normal  ---
rand->fuchsia-zircon                  0.3.3    ---     Removed  Normal  cfg(target_os = "fuchsia")
rand->libc                            0.2.43   ---     Removed  Normal  cfg(unix)
rand->rand                            0.4.3    ---     Removed  Normal  ---
rand->winapi                          0.3.5    ---     Removed  Normal  cfg(windows)
winapi->winapi-i686-pc-windows-gnu    0.4.0    ---     Removed  Normal  i686-pc-windows-gnu
winapi->winapi-x86_64-pc-windows-gnu  0.4.0    ---     Removed  Normal  x86_64-pc-windows-gnu
gam0022 commented 6 years ago

rand の アップデートは断念。 seed の指定が [u8; 32] になったため、コードの修正が大きそうだったので。

gam0022 commented 6 years ago

警告一覧

C:\Users\gam0022\Dropbox\hanamaru-renderer (rtcamp6)
λ cargo run --release
   Compiling hanamaru-renderer v0.1.0 (file:///C:/Users/gam0022/Dropbox/hanamaru-renderer)
warning: unused import: `std::fs::File`
 --> src\renderer.rs:6:5
  |
6 | use std::fs::File;
  |     ^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused import: `std::path::Path`
 --> src\renderer.rs:7:5
  |
7 | use std::path::Path;
  |     ^^^^^^^^^^^^^^^

warning: unused import: `Intersection`
  --> src\renderer.rs:15:40
   |
15 | use scene::{SceneTrait, Intersectable, Intersection};
   |                                        ^^^^^^^^^^^^

warning: unused import: `material::SurfaceType`
  --> src\renderer.rs:17:5
   |
17 | use material::SurfaceType;
   |     ^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `bsdf`
  --> src\renderer.rs:18:5
   |
18 | use bsdf;
   |     ^^^^

warning: unused import: `math::saturate`
  --> src\renderer.rs:20:5
   |
20 | use math::saturate;
   |     ^^^^^^^^^^^^^^

warning: unnecessary parentheses around assigned value
  --> src\material.rs:77:27
   |
77 |                 let tmp = (1.0 - (1.0 - alpha2) * h_dot_n * h_dot_n);
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
   |
   = note: #[warn(unused_parens)] on by default

warning: unused import: `scene::Intersection`
 --> src\bsdf.rs:3:5
  |
3 | use scene::Intersection;
  |     ^^^^^^^^^^^^^^^^^^^

warning: unused import: `camera::Ray`
 --> src\bsdf.rs:4:5
  |
4 | use camera::Ray;
  |     ^^^^^^^^^^^

warning: unused import: `color::Color`
 --> src\bsdf.rs:5:5
  |
5 | use color::Color;
  |     ^^^^^^^^^^^^

warning: unused import: `math::saturate`
 --> src\bsdf.rs:6:5
  |
6 | use math::saturate;
  |     ^^^^^^^^^^^^^^

warning: unnecessary parentheses around method argument
   --> src\main.rs:427:44
    |
427 |           if scene.add_with_check_collisions((Box::new(Sphere {
    |  ____________________________________________^
428 | |             center: Vector3::new(px, r + py, pz),
429 | |             radius: r,
430 | |             material: Material {
...   |
435 | |             },
436 | |         }))) {
    | |___________^
help: remove these parentheses
    |
427 |         if scene.add_with_check_collisions(Box::new(Sphere{center: Vector3::new(px, r + py, pz),
428 |                  radius: r,
429 |                  material:
430 |                      Material{surface: SurfaceType::GGX{f0: 0.8,},
431 |                               albedo:
432 |                                   Texture::from_color(hsv_to_rgb(Color::new(0.2
  ...

warning: unnecessary parentheses around method argument
   --> src\main.rs:649:44
    |
649 |           if scene.add_with_check_collisions((Box::new(Sphere {
    |  ____________________________________________^
650 | |             center: Vector3::new(px, r + py, pz),
651 | |             radius: r,
652 | |             material: Material {
...   |
657 | |             },
658 | |         }))) {
    | |___________^
help: remove these parentheses
    |
649 |         if scene.add_with_check_collisions(Box::new(Sphere{center: Vector3::new(px, r + py, pz),
650 |                  radius: r,
651 |                  material:
652 |                      Material{surface: SurfaceType::GGX{f0: 0.8,},
653 |                               albedo:
654 |                                   Texture::from_color(hsv_to_rgb(Color::new(0.2
  ...

warning: unused variable: `renderer`
   --> src\main.rs:830:17
    |
830 |         let mut renderer = DebugRenderer { mode: DebugRenderMode::Shading };
    |                 ^^^^^^^^ help: consider using `_renderer` instead
    |
    = note: #[warn(unused_variables)] on by default

warning: unused variable: `random`
   --> src\scene.rs:141:33
    |
141 |     fn sample_on_surface(&self, random: (f64, f64)) -> Surface {
    |                                 ^^^^^^ help: consider using `_random` instead

warning: unused variable: `random`
   --> src\scene.rs:191:33
    |
191 |     fn sample_on_surface(&self, random: (f64, f64)) -> Surface {
    |                                 ^^^^^^ help: consider using `_random` instead

warning: unused variable: `random`
   --> src\scene.rs:231:33
    |
231 |     fn sample_on_surface(&self, random: (f64, f64)) -> Surface {
    |                                 ^^^^^^ help: consider using `_random` instead

warning: unused variable: `random`
   --> src\scene.rs:252:33
    |
252 |     fn sample_on_surface(&self, random: (f64, f64)) -> Surface {
    |                                 ^^^^^^ help: consider using `_random` instead

warning: unused variable: `emissions`
   --> src\renderer.rs:105:63
    |
105 |     fn calc_pixel(&self, scene: &SceneTrait, camera: &Camera, emissions: &Vec<&Box<Intersectable>>, normalized_coord: &Vector2, _: u32) -> Color {
    |                                                               ^^^^^^^^^ help: consider using `_emissions` instead

warning: unused variable: `f0`
  --> src\material.rs:46:32
   |
46 |             SurfaceType::GGX { f0 } => true,
   |                                ^^ help: try ignoring the field: `f0: _`

warning: unused variable: `refractive_index`
  --> src\material.rs:49:39
   |
49 |             SurfaceType::Refraction { refractive_index } => false,
   |                                       ^^^^^^^^^^^^^^^^ help: try ignoring the field: `refractive_index: _`

warning: unused variable: `f0`
  --> src\material.rs:50:42
   |
50 |             SurfaceType::GGXRefraction { f0, refractive_index } => false,
   |                                          ^^ help: try ignoring the field: `f0: _`

warning: unused variable: `refractive_index`
  --> src\material.rs:50:46
   |
50 |             SurfaceType::GGXRefraction { f0, refractive_index } => false,
   |                                              ^^^^^^^^^^^^^^^^ help: try ignoring the field: `refractive_index: _`

warning: unused variable: `refractive_index`
  --> src\material.rs:58:39
   |
58 |             SurfaceType::Refraction { refractive_index } => unimplemented!(),
   |                                       ^^^^^^^^^^^^^^^^ help: try ignoring the field: `refractive_index: _`

warning: unused variable: `f0`
  --> src\material.rs:88:42
   |
88 |             SurfaceType::GGXRefraction { f0, refractive_index } => unimplemented!()
   |                                          ^^ help: try ignoring the field: `f0: _`

warning: unused variable: `refractive_index`
  --> src\material.rs:88:46
   |
88 |             SurfaceType::GGXRefraction { f0, refractive_index } => unimplemented!()
   |                                              ^^^^^^^^^^^^^^^^ help: try ignoring the field: `refractive_index: _`

warning: unused variable: `f0`
   --> src\material.rs:147:42
    |
147 |             SurfaceType::GGXRefraction { f0, refractive_index } => {
    |                                          ^^ help: try ignoring the field: `f0: _`

warning: variable does not need to be mutable
   --> src\main.rs:830:13
    |
830 |         let mut renderer = DebugRenderer { mode: DebugRenderMode::Shading };
    |             ----^^^^^^^^
    |             |
    |             help: remove this `mut`
    |
    = note: #[warn(unused_mut)] on by default

warning: variable does not need to be mutable
  --> src\camera.rs:65:30
   |
65 |     fn sample_on_lens(&self, mut rng: &mut StdRng) -> Vector2 {
   |                              ----^^^
   |                              |
   |                              help: remove this `mut`

warning: method is never used: `scale_linear`
  --> src\matrix.rs:20:5
   |
20 |     pub fn scale_linear(s: f64) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(dead_code)] on by default

warning: method is never used: `scale`
  --> src\matrix.rs:25:5
   |
25 |     pub fn scale(sx: f64, sy: f64, sz: f64) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `rotate_x`
  --> src\matrix.rs:35:5
   |
35 |     pub fn rotate_x(t: f64) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `rotate_y`
  --> src\matrix.rs:47:5
   |
47 |     pub fn rotate_y(t: f64) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `rotate_z`
  --> src\matrix.rs:59:5
   |
59 |     pub fn rotate_z(t: f64) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `translate`
  --> src\matrix.rs:71:5
   |
71 |     pub fn translate(tx: f64, ty: f64, tz: f64) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `inverse`
  --> src\matrix.rs:80:5
   |
80 |     pub fn inverse(&self) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: struct is never used: `BvhMesh`
   --> src\scene.rs:236:1
    |
236 | pub struct BvhMesh {
    | ^^^^^^^^^^^^^^^^^^

warning: method is never used: `from_mesh`
   --> src\scene.rs:258:5
    |
258 |     pub fn from_mesh(mesh: Mesh) -> BvhMesh {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `one`
   --> src\scene.rs:291:5
    |
291 |     pub fn one(px_path: &str, nx_path: &str, py_path: &str, ny_path: &str, pz_path: &str, nz_path: &str) -> Skybox {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `add`
   --> src\scene.rs:362:5
    |
362 |     pub fn add(&mut self, element: Box<Intersectable>) {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `add_with_check_collisions`
   --> src\scene.rs:366:5
    |
366 |     pub fn add_with_check_collisions(&mut self, element: Box<Intersectable>) -> bool {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: variant is never constructed: `Square`
  --> src\camera.rs:33:5
   |
33 |     Square,
   |     ^^^^^^

warning: variant is never constructed: `Normal`
  --> src\renderer.rs:93:5
   |
93 |     Normal,
   |     ^^^^^^

warning: variant is never constructed: `Depth`
  --> src\renderer.rs:94:5
   |
94 |     Depth,
   |     ^^^^^

warning: variant is never constructed: `FocalPlane`
  --> src\renderer.rs:95:5
   |
95 |     FocalPlane,
   |     ^^^^^^^^^^

warning: variant is never constructed: `Specular`
  --> src\material.rs:12:5
   |
12 |     Specular,
   |     ^^^^^^^^

warning: variant is never constructed: `Refraction`
  --> src\material.rs:13:5
   |
13 |     Refraction { refractive_index: f64 },
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: variant is never constructed: `GGXRefraction`
  --> src\material.rs:15:5
   |
15 |     GGXRefraction { f0: f64, refractive_index: f64 },
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `hsv_to_rgb`
  --> src\color.rs:51:1
   |
51 | pub fn hsv_to_rgb(color: Color) -> Color {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `hue`
  --> src\color.rs:55:1
   |
55 | fn hue(h: f64) -> Color {
   | ^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `sample_nearest`
  --> src\texture.rs:51:5
   |
51 |     pub fn sample_nearest(&self, u: f64, v: f64) -> Vector3 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `new`
  --> src\texture.rs:78:5
   |
78 |     pub fn new(path: &str, color: Color) -> Texture {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `mix`
  --> src\math.rs:34:1
   |
34 | pub fn mix(x: &Vector3, y: &Vector3, a: f64) -> Vector3 {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: struct is never used: `ObjLoader`
 --> src\loader.rs:9:1
  |
9 | pub struct ObjLoader;
  | ^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `load`
  --> src\loader.rs:12:5
   |
12 |     pub fn load(path: &str, matrix: Matrix44, material: Material) -> Mesh {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `intersect_aabb`
  --> src\bvh.rs:14:5
   |
14 |     pub fn intersect_aabb(&self, other: &Aabb) -> bool {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `from_triangle`
  --> src\bvh.rs:51:5
   |
51 |     pub fn from_triangle(v0: &Vector3, v1: &Vector3, v2: &Vector3) -> Aabb {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `set_aabb_from_mesh`
  --> src\bvh.rs:91:5
   |
91 |     fn set_aabb_from_mesh(&mut self, mesh: &Mesh, face_indexes: &Vec<usize>) {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `build_from_mesh_with_indexes`
   --> src\bvh.rs:107:5
    |
107 |     fn build_from_mesh_with_indexes(mesh: &Mesh, face_indexes: &mut Vec<usize>) -> BvhNode {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `build_from_mesh`
   --> src\bvh.rs:203:5
    |
203 |     pub fn build_from_mesh(mesh: &Mesh) -> BvhNode {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `init_scene_material_examples`
   --> src\main.rs:131:1
    |
131 | fn init_scene_material_examples() -> (Camera, Scene) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `init_scene_rtcamp5`
   --> src\main.rs:243:1
    |
243 | fn init_scene_rtcamp5() -> (Camera, Scene) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `init_scene_tbf3`
   --> src\main.rs:492:1
    |
492 | fn init_scene_tbf3() -> (Camera, Scene) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `init_scene_rtcamp6`
   --> src\main.rs:714:1
    |
714 | fn init_scene_rtcamp6() -> (Camera, Scene) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `inspect_image`
   --> src\main.rs:861:1
    |
861 | fn inspect_image() {
    | ^^^^^^^^^^^^^^^^^^

    Finished release [optimized] target(s) in 2.36s
     Running `target\release\hanamaru-renderer.exe`
num threads: 8.
resolution: 960x540.
max sampling: 20x4 spp.
time limit: 14400.00 sec.
init scene: 0.20 sec.
rendering: 1x4 sampled (last 0.986 sec). total: 0.986 sec (0.01 %).
rendering: 2x4 sampled (last 0.708 sec). total: 1.694 sec (0.01 %).
rendering: 3x4 sampled (last 0.739 sec). total: 2.433 sec (0.02 %).
rendering: 4x4 sampled (last 0.669 sec). total: 3.102 sec (0.02 %).
rendering: 5x4 sampled (last 0.658 sec). total: 3.760 sec (0.03 %).
rendering: 6x4 sampled (last 0.681 sec). total: 4.442 sec (0.03 %).
rendering: 7x4 sampled (last 0.669 sec). total: 5.111 sec (0.04 %).
rendering: 8x4 sampled (last 0.652 sec). total: 5.763 sec (0.04 %).
rendering: 9x4 sampled (last 0.680 sec). total: 6.443 sec (0.04 %).
rendering: 10x4 sampled (last 0.706 sec). total: 7.149 sec (0.05 %).
rendering: 11x4 sampled (last 0.678 sec). total: 7.828 sec (0.05 %).
rendering: 12x4 sampled (last 0.656 sec). total: 8.484 sec (0.06 %).
rendering: 13x4 sampled (last 0.657 sec). total: 9.141 sec (0.06 %).
rendering: 14x4 sampled (last 0.658 sec). total: 9.799 sec (0.07 %).
rendering: 15x4 sampled (last 0.656 sec). total: 10.456 sec (0.07 %).
rendering: 16x4 sampled (last 0.665 sec). total: 11.121 sec (0.08 %).
rendering: 17x4 sampled (last 0.656 sec). total: 11.777 sec (0.08 %).
rendering: 18x4 sampled (last 0.659 sec). total: 12.436 sec (0.09 %).
rendering: 19x4 sampled (last 0.678 sec). total: 13.114 sec (0.09 %).
rendering: 20x4 sampled (last 0.652 sec). total: 13.767 sec (0.10 %).
reached max sampling
output final image: progress_000.png
remain: 14386.233 sec.
update_imgbuf: 0.006 sec
sampled: 20x4 spp.
total 13.819 sec. used 0.10 % (x 1042.04)
gam0022 commented 6 years ago
λ cargo run --release
   Compiling hanamaru-renderer v0.1.0 (file:///C:/Users/gam0022/Dropbox/hanamaru-renderer)
warning: unnecessary parentheses around method argument
   --> src\main.rs:649:44
    |
649 |           if scene.add_with_check_collisions((Box::new(Sphere {
    |  ____________________________________________^
650 | |             center: Vector3::new(px, r + py, pz),
651 | |             radius: r,
652 | |             material: Material {
...   |
657 | |             },
658 | |         }))) {
    | |___________^
    |
    = note: #[warn(unused_parens)] on by default
help: remove these parentheses
    |
649 |         if scene.add_with_check_collisions(Box::new(Sphere{center: Vector3::new(px, r + py, pz),
650 |                  radius: r,
651 |                  material:
652 |                      Material{surface: SurfaceType::GGX{f0: 0.8,},
653 |                               albedo:
654 |                                   Texture::from_color(hsv_to_rgb(Color::new(0.2
  ...

warning: unused variable: `refractive_index`
  --> src\material.rs:58:39
   |
58 |             SurfaceType::Refraction { refractive_index } => unimplemented!(),
   |                                       ^^^^^^^^^^^^^^^^ help: try ignoring the field: `refractive_index: _`
   |
   = note: #[warn(unused_variables)] on by default

warning: unused variable: `f0`
  --> src\material.rs:88:42
   |
88 |             SurfaceType::GGXRefraction { f0, refractive_index } => unimplemented!()
   |                                          ^^ help: try ignoring the field: `f0: _`

warning: unused variable: `refractive_index`
  --> src\material.rs:88:46
   |
88 |             SurfaceType::GGXRefraction { f0, refractive_index } => unimplemented!()
   |                                              ^^^^^^^^^^^^^^^^ help: try ignoring the field: `refractive_index: _`

warning: unused variable: `f0`
   --> src\material.rs:147:42
    |
147 |             SurfaceType::GGXRefraction { f0, refractive_index } => {
    |                                          ^^ help: try ignoring the field: `f0: _`

warning: constant item is never used: `TONE_MAPPING_EXPOSURE`
  --> src\config.rs:21:1
   |
21 | pub const TONE_MAPPING_EXPOSURE: f64 = 2.0;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(dead_code)] on by default

warning: constant item is never used: `TONE_MAPPING_WHITE_POINT`
  --> src\config.rs:22:1
   |
22 | pub const TONE_MAPPING_WHITE_POINT: f64 = 100.0;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `rotate_z`
  --> src\matrix.rs:59:5
   |
59 |     pub fn rotate_z(t: f64) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `inverse`
  --> src\matrix.rs:80:5
   |
80 |     pub fn inverse(&self) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `add`
   --> src\scene.rs:362:5
    |
362 |     pub fn add(&mut self, element: Box<Intersectable>) {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: variant is never constructed: `Square`
  --> src\camera.rs:33:5
   |
33 |     Square,
   |     ^^^^^^

warning: variant is never constructed: `Normal`
  --> src\renderer.rs:88:5
   |
88 |     Normal,
   |     ^^^^^^

warning: variant is never constructed: `Depth`
  --> src\renderer.rs:89:5
   |
89 |     Depth,
   |     ^^^^^

warning: variant is never constructed: `FocalPlane`
  --> src\renderer.rs:90:5
   |
90 |     FocalPlane,
   |     ^^^^^^^^^^

warning: variant is never constructed: `Specular`
  --> src\material.rs:12:5
   |
12 |     Specular,
   |     ^^^^^^^^

warning: variant is never constructed: `GGXRefraction`
  --> src\material.rs:15:5
   |
15 |     GGXRefraction { f0: f64, refractive_index: f64 },
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `sample_nearest`
  --> src\texture.rs:51:5
   |
51 |     pub fn sample_nearest(&self, u: f64, v: f64) -> Vector3 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `mix`
  --> src\math.rs:34:1
   |
34 | pub fn mix(x: &Vector3, y: &Vector3, a: f64) -> Vector3 {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `reinhard`
 --> src\tonemap.rs:8:1
  |
8 | pub fn reinhard(color: &Vector3) -> Vector3 {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `init_scene_simple`
  --> src\main.rs:47:1
   |
47 | fn init_scene_simple() -> (Camera, Scene) {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `init_scene_material_examples`
   --> src\main.rs:131:1
    |
131 | fn init_scene_material_examples() -> (Camera, Scene) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `init_scene_tbf3`
   --> src\main.rs:492:1
    |
492 | fn init_scene_tbf3() -> (Camera, Scene) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `init_scene_rtcamp6`
   --> src\main.rs:714:1
    |
714 | fn init_scene_rtcamp6() -> (Camera, Scene) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `inspect_image`
   --> src\main.rs:862:1
    |
862 | fn inspect_image() {
    | ^^^^^^^^^^^^^^^^^^
gam0022 commented 6 years ago

警告消した

λ cargo run --release
   Compiling hanamaru-renderer v0.1.0 (file:///C:/Users/gam0022/Dropbox/hanamaru-renderer)
warning: method is never used: `rotate_z`
  --> src\matrix.rs:59:5
   |
59 |     pub fn rotate_z(t: f64) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(dead_code)] on by default

warning: method is never used: `inverse`
  --> src\matrix.rs:80:5
   |
80 |     pub fn inverse(&self) -> Matrix44 {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method is never used: `add`
   --> src\scene.rs:362:5
    |
362 |     pub fn add(&mut self, element: Box<Intersectable>) {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: `mix`
  --> src\math.rs:34:1
   |
34 | pub fn mix(x: &Vector3, y: &Vector3, a: f64) -> Vector3 {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gam0022 commented 6 years ago

テスト実行

Microsoft Windows Server 2016 Base / c5.18xlarge

num threads: 36.
resolution: 1920x1080.
max sampling: 1000x4 spp.
time limit: 123.00 sec.
init scene: 0.09 sec.
sampled: 33x4 spp.
total 120.70700000000001 sec. used 98.14 % (x 1.02)

Amazon Linux AMI 2018.03.0 / c5.18xlarge

num threads: 72.
resolution: 1920x1080.
max sampling: 1000x4 spp.
time limit: 123.00 sec.
init scene: 0.07 sec.
sampled: 70x4 spp.
total 121.785 sec. used 99.01 % (x 1.01)

開発環境

123秒

num threads: 8.
resolution: 1920x1080.
max sampling: 1000x4 spp.
time limit: 123.00 sec.
init scene: 0.07 sec.
sampled: 8x4 spp.
total 120.906 sec. used 98.30 % (x 1.02)

70spp

num threads: 8.
resolution: 1920x1080.
max sampling: 70x4 spp.
time limit: 1230000.00 sec.
init scene: 0.07 sec.
sampled: 70x4 spp.
total 1037.171 sec. used 0.08 % (x 1185.92)
gam0022 commented 6 years ago

開発環境での制限時間の設定について

70x4 spp の所要時間

開発環境 / 本番環境 = 1037.171 / 121.785 = 8.51641006692

制限時間

123 * 1037.171 / 121.785 = 1047.51843823

開発環境では制限時間を1047 秒で設定しておけばだいたい本番環境と同じサンプリング数を確保できそう

gam0022 commented 6 years ago
// 解像度とサンプリング数
//pub const RESOLUTION: (u32, u32, u32) = (1280, 720, 10);// 16:9 HD 921,600 pixel
//pub const RESOLUTION: (u32, u32, u32) = (800, 600, 10);// 4:3 SVGA 480,000 pixel
//pub const RESOLUTION: (u32, u32, u32) = (1280, 960, 1000);// 4:3 960p 1,228,800 pixel
//pub const RESOLUTION: (u32, u32, u32) = (1440, 1080, 1000);// 4:3 1080p 1,555,200 pixel
//pub const RESOLUTION: (u32, u32, u32) = (2592, 3625, 1000);// B5 + とんぼ(2508 + 42 *2, 3541 + 42 *2)
//pub const RESOLUTION: (u32, u32, u32) = (2592/4, 3625/4, 100);// B5 + とんぼ(2508 + 42 *2, 3541 + 42 *2)
//pub const RESOLUTION: (u32, u32, u32) = (1024, 1024, 1000);
//pub const RESOLUTION: (u32, u32, u32) = (1920 / 4, 1080 / 4, 4);// 16:9 Half FHD
pub const RESOLUTION: (u32, u32, u32) = (1920, 1080, 1000);// 16:9 FHD 2,073,600 pixel

// レイトレ合宿6のレギュレーション用
// https://sites.google.com/site/raytracingcamp6/
pub const REPORT_INTERVAL_SEC: f64 = 15.0;// 15秒ごとに途中結果を出力
pub const TIME_LIMIT_SEC: f64 = (123) as f64;// 123秒以内に自動で終了
//pub const TIME_LIMIT_SEC: f64 = (1047) as f64;// 開発環境と本番環境の性能差を考慮した制限時間