This commit is contained in:
STP
2023-11-26 07:56:36 -05:00
parent 2e70fc9a68
commit 8ab9be8056
11 changed files with 334 additions and 35 deletions

213
Cargo.lock generated
View File

@@ -133,6 +133,12 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]]
name = "bit_field"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
[[package]]
name = "bitflags"
version = "1.3.2"
@@ -163,6 +169,12 @@ version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "calloop"
version = "0.10.6"
@@ -247,6 +259,12 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "color_quant"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "com-rs"
version = "0.2.1"
@@ -334,6 +352,39 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
dependencies = [
"cfg-if",
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"memoffset 0.9.0",
"scopeguard",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
dependencies = [
"cfg-if",
]
[[package]]
name = "crossfont"
version = "0.5.1"
@@ -450,6 +501,12 @@ dependencies = [
"wio",
]
[[package]]
name = "either"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "env_logger"
version = "0.10.1"
@@ -495,6 +552,22 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "exr"
version = "1.71.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "832a761f35ab3e6664babfbdc6cef35a4860e816ec3916dcfd0882954e98a8a8"
dependencies = [
"bit_field",
"flume",
"half",
"lebe",
"miniz_oxide",
"rayon-core",
"smallvec",
"zune-inflate",
]
[[package]]
name = "fdeflate"
version = "0.3.1"
@@ -514,6 +587,15 @@ dependencies = [
"miniz_oxide",
]
[[package]]
name = "flume"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181"
dependencies = [
"spin",
]
[[package]]
name = "fnv"
version = "1.0.7"
@@ -595,6 +677,16 @@ dependencies = [
"wasi",
]
[[package]]
name = "gif"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045"
dependencies = [
"color_quant",
"weezl",
]
[[package]]
name = "gimli"
version = "0.28.0"
@@ -665,6 +757,15 @@ dependencies = [
"bitflags 2.4.1",
]
[[package]]
name = "half"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0"
dependencies = [
"crunchy",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
@@ -720,6 +821,25 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "image"
version = "0.24.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711"
dependencies = [
"bytemuck",
"byteorder",
"color_quant",
"exr",
"gif",
"jpeg-decoder",
"num-rational",
"num-traits",
"png",
"qoi",
"tiff",
]
[[package]]
name = "imgui"
version = "0.11.0"
@@ -817,6 +937,15 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "jpeg-decoder"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e"
dependencies = [
"rayon",
]
[[package]]
name = "js-sys"
version = "0.3.65"
@@ -843,6 +972,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lebe"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
[[package]]
name = "libc"
version = "0.2.150"
@@ -934,6 +1069,15 @@ dependencies = [
"autocfg",
]
[[package]]
name = "memoffset"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
dependencies = [
"autocfg",
]
[[package]]
name = "metal"
version = "0.24.0"
@@ -1096,7 +1240,7 @@ dependencies = [
"bitflags 1.3.2",
"cfg-if",
"libc",
"memoffset",
"memoffset 0.6.5",
]
[[package]]
@@ -1109,7 +1253,7 @@ dependencies = [
"bitflags 1.3.2",
"cfg-if",
"libc",
"memoffset",
"memoffset 0.6.5",
]
[[package]]
@@ -1321,6 +1465,15 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f89dff0959d98c9758c88826cc002e2c3d0b9dfac4139711d1f30de442f1139b"
[[package]]
name = "qoi"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001"
dependencies = [
"bytemuck",
]
[[package]]
name = "quote"
version = "1.0.33"
@@ -1387,6 +1540,26 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
[[package]]
name = "rayon"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]
[[package]]
name = "redox_syscall"
version = "0.4.1"
@@ -1472,6 +1645,7 @@ dependencies = [
"cfg-if",
"env_logger",
"error-iter",
"image",
"imgui",
"imgui-wgpu",
"imgui-winit-support",
@@ -1658,6 +1832,15 @@ dependencies = [
"wayland-protocols",
]
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
dependencies = [
"lock_api",
]
[[package]]
name = "spirv"
version = "0.2.0+1.5.4"
@@ -1731,6 +1914,17 @@ dependencies = [
"syn 2.0.39",
]
[[package]]
name = "tiff"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211"
dependencies = [
"flate2",
"jpeg-decoder",
"weezl",
]
[[package]]
name = "tiny-keccak"
version = "2.0.2"
@@ -1982,6 +2176,12 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "weezl"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
[[package]]
name = "wgpu"
version = "0.16.3"
@@ -2409,3 +2609,12 @@ dependencies = [
"quote",
"syn 2.0.39",
]
[[package]]
name = "zune-inflate"
version = "0.2.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02"
dependencies = [
"simd-adler32",
]

View File

@@ -22,3 +22,4 @@ pixels = "0.13"
error-iter = "0.4.1"
rhai = {version = "1.16.3"}
rand = "0.8.5"
image = "0.24.7"

View File

@@ -1,19 +1,32 @@
let scene = Scene();
let material = Material(V(0.5,0.5,0.5), V(0.8, 0.8, 0.8), 25.0);
let material = Material(V(0.2,0.2,0.2), V(0.2, 0.8, 0.8), 10.0);
//let ambient = Light(P(10.0,0.0,0.0), V(1.0,1.0,1.0), V(0.0, 0.0, 0.0));
//scene.addLight(ambient);
let light = Light(P(3.0,3.0,1.0), V(0.0,1.0,1.0), V(0.1, 0.01, 0.001));
let light = Light(P(0.0,7.0,0.0), V(0.0,0.0,1.0), V(0.1, 0.01, 0.001));
scene.addLight(light);
let light = Light(P(2.0,7.0,0.0), V(0.0,1.0,0.0), V(0.1, 0.01, 0.001));
scene.addLight(light);
let light = Light(P(-2.0,7.0,0.0), V(1.0,0.0,0.0), V(0.1, 0.01, 0.001));
scene.addLight(light);
let light = Ambient(V(0.1,0.1,0.1));
scene.addLight(light);
let sphere = Sphere(P(0.0,0.0,0.0), 1.0, material);
let sphere_node = Node(sphere);
scene.addNode(sphere_node);
for i in 0..6 {
let sphere = Sphere(P(0.0,0.0,0.0), 2.0, material);
let sphere_node = Node(sphere);
sphere_node.translate(V(2.0*cos(i.to_float()), -4.0, 2.0*sin(i.to_float())));
scene.addNode(sphere_node);
}
// let child = sphere_node.child(sphere);
// child.translate(V(1.0,1.0,1.0));
// scene.addNode(sphere_node);
//scene.addNode(child);
// let cube = CubeUnit(material);
@@ -24,10 +37,10 @@ let sphere_node = Node(sphere);
// let gnonom_node = Node(gnonom);
// scene.addNode(gnonom_node);
let cylinder = Cylinder(1.0,1.0, material);
let cylinder_node = Node(cylinder);
cylinder_node.scale(V(4.0,0.3,0.3));
cylinder_node.translate(V(0.0,-4.0,1.0));
scene.addNode(cylinder_node);
// let cylinder = Cylinder(10.0,1.0, material);
// let cylinder_node = Node(cylinder);
// //cylinder_node.scale(V(4.0,0.3,0.3));
// cylinder_node.translate(V(0.0,-4.0,0.0));
// scene.addNode(cylinder_node);
scene

View File

@@ -3,7 +3,7 @@ use crate::{
light::Light,
primitive::*,
scene::{Node, Scene},
state::INIT_FILE,
state::{INIT_FILE, SAVE_FILE},
UP_VECTOR_F32, ZERO_VECTOR_F32,
};
use imgui::*;
@@ -12,13 +12,13 @@ use pixels::{wgpu, PixelsContext};
use rhai::Engine;
use std::time::Instant;
const BUFFER_PROPORTION_INIT: f32 = 1.0;
const BUFFER_PROPORTION_MIN: f32 = 0.5;
const BUFFER_PROPORTION_INIT: f32 = 0.2;
const BUFFER_PROPORTION_MIN: f32 = 0.1;
const BUFFER_PROPORTION_MAX: f32 = 1.0;
const RAYS_INIT: i32 = 1000;
const RAYS_MIN: i32 = 100;
const RAYS_MAX: i32 = 100000;
const RAYS_MAX: i32 = 30000;
const CAMERA_MIN_FOV: f32 = 10.0;
const CAMERA_MAX_FOV: f32 = 160.0;
@@ -29,6 +29,7 @@ pub enum GuiEvent {
BufferResize(f32, f32),
CameraUpdate(Camera),
SceneLoad(Scene),
SaveImage(String),
}
pub struct Gui {
@@ -53,6 +54,8 @@ pub struct Gui {
camera_target: [f32; 3],
camera_up: [f32; 3],
camera_fov: f32,
image_filename: String,
}
impl Gui {
@@ -115,6 +118,8 @@ impl Gui {
camera_target: ZERO_VECTOR_F32.into(),
camera_up: UP_VECTOR_F32.into(),
camera_fov: 110.0,
image_filename: String::from(SAVE_FILE),
}
}
@@ -216,11 +221,25 @@ impl Gui {
Err(e) => println!("{e}"),
}
}
if ui.button("Save script") {
match std::fs::write(&self.script_filename, &self.script) {
Ok(_) => println!("Script saved successfully"),
Err(e) => println!("{}", e),
}
}
//Script block
ui.input_text_multiline("script", &mut self.script, [600., 1500.])
.build();
}
if CollapsingHeader::new("Image").build(ui) {
ui.input_text("Image file", &mut self.image_filename)
.build();
if ui.button("Save Image") {
self.event = Some(GuiEvent::SaveImage(self.image_filename.clone()));
}
}
// Render Dear ImGui with WGPU
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("imgui"),
@@ -270,7 +289,9 @@ pub fn init_engine() -> Engine {
.register_type::<Scene>()
.register_fn("Scene", Scene::empty)
.register_fn("addNode", Scene::add_node)
.register_fn("addLight", Scene::add_light);
.register_fn("addLight", Scene::add_light)
.register_fn("addCamera", Scene::add_camera)
.register_fn("addMaterial", Scene::add_material);
engine
.register_type::<Node>()
@@ -281,7 +302,8 @@ pub fn init_engine() -> Engine {
.register_fn("child", Node::child);
engine
.register_type::<Light>()
.register_fn("Light", Light::new);
.register_fn("Light", Light::new)
.register_fn("Ambient", Light::ambient);
engine
.register_type::<Material>()
.register_fn("Material", Material::new)
@@ -319,6 +341,9 @@ pub fn init_engine() -> Engine {
engine
.register_type::<Torus>()
.register_fn("Torus", Torus::new);
engine
.register_type::<Mesh>()
.register_fn("Mesh", Mesh::from_file);
engine
.register_type::<Gnonom>()
.register_fn("Gnonom", Gnonom::new);

View File

@@ -5,6 +5,7 @@ pub struct Light {
pub position: Point3<f64>,
pub colour: Vector3<f64>,
pub falloff: Vector3<f64>,
pub ambient: bool,
}
impl Light {
@@ -13,11 +14,15 @@ impl Light {
position,
colour,
falloff,
ambient: false,
}
}
pub fn white(position: Point3<f64>) -> Self {
let colour = Vector3::new(1.0, 1.0, 1.0);
let falloff = Vector3::new(1.0, 0.0, 0.0);
Light::new(position, colour, falloff)
pub fn ambient(colour: Vector3<f64>) -> Self {
Light {
position: Point3::new(0.0, 0.0, 0.0),
colour,
falloff: Vector3::new(0.0, 0.0, 0.0),
ambient: true,
}
}
}

View File

@@ -5,7 +5,6 @@ const EPSILON: f64 = 1e-6;
const INFINITY: f64 = f64::MAX;
const EPSILON_VECTOR: Vector3<f64> = Vector3::new(EPSILON, EPSILON, EPSILON);
static ZERO_VECTOR: Vector3<f64> = Vector3::new(0.0, 0.0, 0.0);
static UP_VECTOR: Vector3<f64> = Vector3::new(0.0, 1.0, 0.0);
static ZERO_VECTOR_F32: Vector3<f32> = Vector3::new(0.0, 0.0, 0.0);
static UP_VECTOR_F32: Vector3<f32> = Vector3::new(0.0, 1.0, 0.0);

View File

@@ -73,6 +73,7 @@ impl Intersection {
// BOUNDING BOX -----------------------------------------------------------------
#[derive(Clone)]
struct BoundingBox {
bln: Point3<f64>,
trf: Point3<f64>,
@@ -97,6 +98,7 @@ impl BoundingBox {
None
}
}
#[allow(dead_code)]
fn get_centroid(&self) -> Point3<f64> {
self.bln + (self.trf - self.bln) / 2.0
}
@@ -689,7 +691,8 @@ impl Primitive for Cube {
// TRIANGLE -----------------------------------------------------------------
#[derive(Clone)]
struct Triangle {
#[allow(dead_code)]
pub struct Triangle {
u: Point3<f64>,
v: Point3<f64>,
w: Point3<f64>,
@@ -699,7 +702,7 @@ struct Triangle {
}
impl Triangle {
fn new(
pub fn new(
u: Point3<f64>,
v: Point3<f64>,
w: Point3<f64>,
@@ -720,6 +723,7 @@ impl Triangle {
bounding_box,
})
}
#[allow(dead_code)]
pub fn unit(material: Arc<Material>) -> Arc<dyn Primitive> {
let u = Point3::new(-1.0, 0.0, -1.0);
let v = Point3::new(0.0, 0.0, 1.0);
@@ -780,14 +784,15 @@ impl Primitive for Triangle {
// MESH -----------------------------------------------------------------
#[derive(Clone)]
struct Mesh {
pub struct Mesh {
triangles: Vec<Arc<Triangle>>,
material: Arc<Material>,
bounding_box: BoundingBox,
}
impl Mesh {
fn new(triangles: Vec<Arc<Triangle>>, material: Arc<Material>) -> Arc<dyn Primitive> {
#[allow(dead_code)]
pub fn new(triangles: Vec<Arc<Triangle>>, material: Arc<Material>) -> Arc<dyn Primitive> {
// Calculate the bounding box for the entire mesh based on the bounding boxes of individual triangles
let bounding_box = Mesh::compute_bounding_box(&triangles);
@@ -798,6 +803,7 @@ impl Mesh {
})
}
#[allow(dead_code)]
fn compute_bounding_box(triangles: &Vec<Arc<Triangle>>) -> BoundingBox {
let mut bln = Point3::new(INFINITY, INFINITY, INFINITY);
let mut trf = -bln;
@@ -813,7 +819,7 @@ impl Mesh {
BoundingBox { bln, trf }
}
fn from_file(filename: &str, material: Arc<Material>) -> Arc<dyn Primitive> {
pub fn from_file(filename: &str, material: Arc<Material>) -> Arc<dyn Primitive> {
let mut triangles: Vec<Arc<dyn Primitive>> = Vec::new();
let mut vertices: Vec<Point3<f64>> = Vec::new();

View File

@@ -1,8 +1,8 @@
use crate::{
primitive::{self, Intersection},
primitive::Intersection,
raytracer::phong_shade_point,
scene::{Node, Scene},
EPSILON, INFINITY,
INFINITY,
};
use nalgebra::{Matrix4, Point3, Vector3};
@@ -12,6 +12,7 @@ pub struct Ray {
pub b: Vector3<f64>,
}
#[allow(dead_code)]
impl Ray {
pub fn new(a: Point3<f64>, b: Vector3<f64>) -> Ray {
Ray {
@@ -45,7 +46,7 @@ impl Ray {
for node in nodes {
let primitive = node.primitive.clone();
//Transform ray to view coords
//Transform ray from view coords
let ray = self.transform(&node.inv_viewmodel);
if primitive.intersect_bounding_box(&ray).is_some() {
@@ -54,6 +55,7 @@ impl Ray {
closest_distance = intersect.distance;
//Convert back to world coords
let intersect = intersect.transform(&node.model, &node.inv_model);
closest_intersect = Some(intersect);
}
}

View File

@@ -24,8 +24,14 @@ pub fn phong_shade_point(scene: &Scene, intersect: &Intersection) -> Vector3<u8>
position: light_position,
colour: light_colour,
falloff: light_falloff,
ambient: light_ambient,
} = light;
if *light_ambient {
colour += light_colour;
continue;
}
// Point to light
let to_light = light_position - point;
let light_distance = to_light.norm();

View File

@@ -4,6 +4,7 @@ use crate::camera::Camera;
use crate::ray::Ray;
use crate::{gui::Gui, scene::Scene};
use crate::{gui::GuiEvent, log_error};
use std::path::Path;
use rand::seq::SliceRandom;
use rand::thread_rng;
@@ -19,11 +20,12 @@ use winit::event::{Event, KeyboardInput, MouseButton, VirtualKeyCode, WindowEven
use winit::event_loop::{ControlFlow, EventLoop};
use winit::window::{Window, WindowBuilder};
const START_WIDTH: i32 = 1400;
const START_HEIGHT: i32 = 1000;
const START_WIDTH: i32 = 1200;
const START_HEIGHT: i32 = 1200;
const COLOUR_CLEAR: [u8; 4] = [0x22, 0x00, 0x11, 0xff];
pub const INIT_FILE: &str = "scene.rhai";
pub const SAVE_FILE: &str = "img.png";
pub struct State {
scene: Scene,
@@ -75,6 +77,17 @@ impl State {
self.scene = scene;
self.reset_queue();
}
GuiEvent::SaveImage(filename) => {
let pixels = self.pixels.lock().unwrap();
let frame = pixels.frame();
image::save_buffer(
Path::new(&filename),
frame,
self.buffer_width,
self.buffer_height,
image::ColorType::Rgba8,
)?
}
}
};
Ok(())
@@ -93,13 +106,11 @@ impl State {
let mut pixels = self.pixels.lock().unwrap();
pixels.resize_buffer(self.buffer_width, self.buffer_height)?;
pixels.resize_surface(size.width, size.height)?;
Ok(())
}
fn resize(&mut self, size: &PhysicalSize<u32>) -> Result<(), Box<dyn Error>> {
self.buffer_width = (size.width) as u32;
self.buffer_height = (size.height) as u32;
self.reset_queue();
let mut pixels = self.pixels.lock().unwrap();
pixels.resize_surface(size.width, size.height)?;
Ok(())

22
test.rhai Normal file
View File

@@ -0,0 +1,22 @@
let scene = Scene();
let material = Material(V(0.2,0.2,0.2), V(0.2, 0.8, 0.8), 10.0);
//let ambient = Light(P(10.0,0.0,0.0), V(1.0,1.0,1.0), V(0.0, 0.0, 0.0));
//scene.addLight(ambient);
let light = Light(P(0.0,7.0,0.0), V(0.0,0.0,1.0), V(0.1, 0.01, 0.001));
scene.addLight(light);
let light = Light(P(2.0,7.0,0.0), V(0.0,1.0,0.0), V(0.1, 0.01, 0.001));
scene.addLight(light);
let light = Light(P(-2.0,7.0,0.0), V(1.0,0.0,0.0), V(0.1, 0.01, 0.001));
scene.addLight(light);
let light = Ambient(V(0.1,0.1,0.1));
scene.addLight(light);
let sphere = Stein(material);
let sphere_node = Node(sphere);
scene.addNode(sphere_node);
scene