parent
eacc585127
commit
ed05131b84
After Width: | Height: | Size: 2.1 MiB |
@ -0,0 +1,157 @@ |
||||
-- Scene developed by TSM71 |
||||
-- Also this took 30 hours to render |
||||
|
||||
local COLOR_BLACK = colorvec.new(0, 0, 0, 0) |
||||
|
||||
local GRAY = material.newfromdiagonal( |
||||
COLOR_BLACK, |
||||
colorvec.new(0.5, 0.5, 0.5, 0.5), |
||||
surfacetype.DIFFUSE |
||||
) |
||||
local CYAN = material.newfromdiagonal( |
||||
COLOR_BLACK, |
||||
colorvec.new(0, 1, 1, 0), |
||||
surfacetype.DIFFUSE |
||||
) |
||||
local PINK = material.newfromdiagonal( |
||||
COLOR_BLACK, |
||||
colorvec.new(1, .5, .5, 0), |
||||
surfacetype.DIFFUSE |
||||
) |
||||
local RED = material.newfromdiagonal( |
||||
COLOR_BLACK, |
||||
colorvec.new(1, 0, 0, 0), |
||||
surfacetype.DIFFUSE |
||||
) |
||||
local MAGENTA = material.newfromdiagonal( |
||||
COLOR_BLACK, |
||||
colorvec.new(1, 0, 1, 0), |
||||
surfacetype.DIFFUSE |
||||
) |
||||
local MIRROR = material.newfromdiagonal( |
||||
COLOR_BLACK, |
||||
colorvec.new(1, 1, 1, 1), |
||||
surfacetype.REFLECTIVE |
||||
) |
||||
local FLUORESCENT = material.new( |
||||
COLOR_BLACK, |
||||
colormat.new( |
||||
.25, 0, 0, .25, |
||||
0, .25, 0, .75, |
||||
0, 0, .25, 0, |
||||
0, 0, 0, 0 |
||||
), |
||||
surfacetype.DIFFUSE |
||||
) |
||||
|
||||
--[[ |
||||
obj.transformaround = function(a, b, c) |
||||
return util.translate( |
||||
util.transform( |
||||
util.translate( |
||||
a, |
||||
-c |
||||
), |
||||
b |
||||
), |
||||
c |
||||
) |
||||
end |
||||
--]] |
||||
--obj.transformaround = function(a, _b, _c) return a end |
||||
--obj.affinetransform = function(a, _b, _c) return a end |
||||
--obj.smoothunion = function(a, b, _r) return obj.union(a, b) end |
||||
---[[ |
||||
util.stacktransforms = function(list) |
||||
--do return list[1] end |
||||
--do return list[#list] end |
||||
local n = #list |
||||
local a = mat3.I |
||||
--for i=n, 1, -1 do |
||||
for i=1, n do |
||||
a = list[i] * a |
||||
--a = a * list[i] |
||||
end |
||||
return a |
||||
end |
||||
--]] |
||||
|
||||
return obj.withlights( |
||||
obj.transformaround( |
||||
obj.withlights( |
||||
util.union({ |
||||
util.intersection({ |
||||
util.union({ |
||||
obj.withmaterial( |
||||
obj.negation( |
||||
util.union({ |
||||
obj.cuboid(vec3.new(0, 0, 0), vec3.new(.5, 1, 4)), |
||||
obj.cuboid(vec3.new(0, 0, 0), vec3.new(4, 1, .5)) |
||||
}) |
||||
), |
||||
GRAY |
||||
), |
||||
obj.withmaterial( |
||||
util.intersection({ |
||||
util.union({ |
||||
obj.cuboid(vec3.new(0, 1, 0), vec3.new(.4, .1, 3.9)), |
||||
obj.cuboid(vec3.new(0, 1, 0), vec3.new(3.9, .1, .4)) |
||||
}), |
||||
obj.negation( |
||||
util.union({ |
||||
obj.cuboid(vec3.new(0, 1, 0), vec3.new(.3, 1, 3.8)), |
||||
obj.cuboid(vec3.new(0, 1, 0), vec3.new(3.8, 1, .3)) |
||||
}) |
||||
) |
||||
}), |
||||
FLUORESCENT |
||||
), |
||||
obj.smoothunion( |
||||
obj.withmaterial( |
||||
obj.sphere(vec3.new(0, .75, 0), .25), |
||||
CYAN |
||||
), |
||||
obj.withmaterial( -- withdynamicmaterial |
||||
obj.sphere(vec3.new(-.5, .5, 0), .25), |
||||
MAGENTA --dynamicmaterial.missingtexture(vec3.new(-.5, .5, 0)) |
||||
), |
||||
.5 |
||||
) |
||||
}), |
||||
obj.withmaterial( |
||||
obj.negation( |
||||
obj.cuboid(vec3.new(0, 0, 0), vec3.new(2, .25, 2)) |
||||
), |
||||
PINK |
||||
) |
||||
}), |
||||
obj.withmaterial( |
||||
obj.cylinder(vec3.new(1, 0, 0), .375), |
||||
RED |
||||
), |
||||
util.transform( |
||||
obj.withmaterial( |
||||
obj.torus(vec3.new(0, 0, -1), .375, .125), |
||||
MIRROR |
||||
), |
||||
transform.SWAPYZ |
||||
) |
||||
}), |
||||
{ |
||||
light.new(vec3.new(.45, 1-.2, -.45), colorvec.new(0, 0, 0, .1)), |
||||
--light.new(vec3.new(.45, 1-.2, -.45), colorvec.new(0, 0, 0, 1)), |
||||
} |
||||
), |
||||
util.stacktransforms({ |
||||
transform.scalexyz(1, -1, 1), |
||||
transform.rotatez(10*math.pi/180), |
||||
}), |
||||
vec3.new(0, 0, -1.5) |
||||
), |
||||
{ |
||||
light.new(vec3.new(0, .9375, 0), colorvec.new(.5, .25, 0, 0)), |
||||
light.new(vec3.new(0, .9375, -.625), colorvec.new(0, 0, 1, 0)), |
||||
--light.new(vec3.new(0, .9375, 0), colorvec.new(5, 2.5, 0, 0)), |
||||
--light.new(vec3.new(0, .9375, -.625), colorvec.new(0, 0, 10, 0)), |
||||
} |
||||
) |
@ -0,0 +1,42 @@ |
||||
use crate::object::Obj; |
||||
use crate::light::Light; |
||||
use crate::structs::Vec3; |
||||
use std::vec; |
||||
use crate::material::Material; |
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)] |
||||
pub struct SmoothUnion<A: Obj, B: Obj> { |
||||
a: A, |
||||
b: B, |
||||
r: f64 |
||||
} |
||||
|
||||
impl<A: Obj, B: Obj> SmoothUnion<A, B> { |
||||
pub fn new(a: A, b: B, r: f64) -> SmoothUnion<A, B> { |
||||
SmoothUnion { a, b, r } |
||||
} |
||||
} |
||||
|
||||
impl<A: Obj, B: Obj> Obj for SmoothUnion<A, B> { |
||||
fn distance_to(&self, point: Vec3) -> f64 { |
||||
let d1 = self.a.distance_to(point); |
||||
let d2 = self.b.distance_to(point); |
||||
let h = f64::max(self.r - f64::abs(d1-d2),0.); |
||||
d1.min(d2) - h*h*0.25 / self.r |
||||
} |
||||
fn material_at(&self, point: Vec3) -> Material { |
||||
if self.a.distance_to(point) < self.b.distance_to(point) { |
||||
self.a.material_at(point) |
||||
} else { |
||||
self.b.material_at(point) |
||||
} |
||||
} |
||||
fn get_lights(&self) -> vec::Vec<Light> { |
||||
let mut l = self.a.get_lights(); |
||||
l.extend(self.b.get_lights()); |
||||
l |
||||
} |
||||
fn node_count(&self) -> u32 { |
||||
self.a.node_count() + self.b.node_count() + 1 |
||||
} |
||||
} |
Loading…
Reference in new issue