added 2nd test scene

main
Codinget 4 years ago
parent 2156577923
commit f50a22ecff
  1. 1
      README.md
  2. BIN
      prod/2.png
  3. 17
      src/main.rs
  4. 2
      src/object/mod.rs

@ -24,6 +24,7 @@ A ray marching renderer in rust
## Examples
![1st test scene](prod/1.png)
![2nd test scene](prod/2.png)
## License
MIT

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

@ -9,13 +9,12 @@ use crate::consts::*;
use crate::structs::*;
use crate::material::*;
use image::{ColorType, ImageFormat};
use image::codecs::png::FilterType::Sub;
fn default_cam() -> Cam {
Cam::new_pointing(Y*3. - X*5., O, 0.5)
}
fn default_scene() -> Scene {
fn default_scene1() -> Scene {
let s0 = WithMaterial::new(
Sphere::new_xyz(0., 0., 0., 1.),
RED
@ -53,9 +52,21 @@ fn default_scene() -> Scene {
Scene::new(scene)
}
fn default_scene2() -> Scene {
let s1 = Sphere::new_xyz(0., 0., 0., 1.);
let scaled = AffineTransform::new_linear(s1, scale(1.2));
let moved = AffineTransform::new_translate(scaled, Vec3::new(3., 1., 1.));
let sphere = WithMaterial::new(moved, BLUE);
let wall = WithMaterial::new(Plane::new_xyz(0., 0., -1., 2.5), GREEN);
let backwall = WithMaterial::new(Plane::new_xyz(-1., 0., 0., 3.), WHITE);
let mirror = WithMaterial::new(Plane::new_xyz(0., 1., 0., 2.), MIRROR);
let light = WithMaterial::new(Sphere::new_xyz(-1., 1.5, 1., 0.5), LIGHTSOURCE);
Scene::new(Union::new(Union::new(sphere, Union::new(wall, backwall)), Union::new(light, mirror)))
}
fn main() {
// get scene and camera
let scene = default_scene();
let scene = default_scene2();
let cam = default_cam();
// get stats on the scene we're about to render

@ -67,5 +67,5 @@ pub use torus::Torus;
pub use waves::Waves;
pub use with_material::{WithMaterial, WithDynamicMaterial};
pub use with_lights::{WithLights, WithLight};
pub use transform::AffineTransform;
pub use transform::*;
pub use scene::Scene;
Loading…
Cancel
Save