Beispiel #1
0
func main() {
	scene := pt.Scene{}
	scene.SetColor(pt.Color{1, 1, 1})
	meshes := []*pt.Mesh{
		CreateBrick(1),  // white
		CreateBrick(21), // bright red
		CreateBrick(23), // bright blue
		CreateBrick(24), // bright yellow
		CreateBrick(26), // black
		CreateBrick(28), // dark green
	}
	for x := -30; x <= 50; x += 2 {
		for y := -50; y <= 20; y += 4 {
			h := rand.Intn(5) + 1
			for i := 0; i < h; i++ {
				dy := 0
				if (x/2+i)%2 == 0 {
					dy = 2
				}
				z := float64(i) * H
				mesh := meshes[rand.Intn(len(meshes))]
				m := pt.Translate(pt.Vector{float64(x), float64(y + dy), z})
				scene.Add(pt.NewTransformedShape(mesh, m))
			}
		}
	}
	// light := pt.LightMaterial(pt.Color{0.2, 0.2, 0.2}, 10, pt.QuadraticAttenuation(0.01))
	// scene.Add(pt.NewSphere(pt.Vector{0, 0, 25}, 1, light))
	camera := pt.LookAt(pt.Vector{-23, 13, 20}, pt.Vector{0, 0, 0}, pt.Vector{0, 0, 1}, 45)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560, 1440, -1, 4, 4)
}
Beispiel #2
0
func main() {
	scene := pt.Scene{}
	meshes := []pt.Shape{
		createMesh(pt.GlossyMaterial(pt.HexColor(0x3B596A), 1.5, pt.Radians(20))),
		createMesh(pt.GlossyMaterial(pt.HexColor(0x427676), 1.5, pt.Radians(20))),
		createMesh(pt.GlossyMaterial(pt.HexColor(0x3F9A82), 1.5, pt.Radians(20))),
		createMesh(pt.GlossyMaterial(pt.HexColor(0xA1CD73), 1.5, pt.Radians(20))),
		createMesh(pt.GlossyMaterial(pt.HexColor(0xECDB60), 1.5, pt.Radians(20))),
	}
	for x := -8; x <= 8; x++ {
		for z := -12; z <= 12; z++ {
			fx := float64(x)
			fy := rand.Float64() * 2
			fz := float64(z)
			scene.Add(pt.NewTransformedShape(meshes[rand.Intn(len(meshes))], pt.Translate(pt.Vector{fx, fy, fz})))
			scene.Add(pt.NewTransformedShape(meshes[rand.Intn(len(meshes))], pt.Translate(pt.Vector{fx, fy - 1, fz})))
		}
	}
	scene.Add(pt.NewSphere(pt.Vector{8, 10, 0}, 3, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{-10, 10, 0}, pt.Vector{-2, 0, 0}, pt.Vector{0, 1, 0}, 45)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 5475, 3675, -1, 16, 3)
}
Beispiel #3
0
func main() {
	white := pt.DiffuseMaterial(pt.Color{0.740, 0.742, 0.734})
	red := pt.DiffuseMaterial(pt.Color{0.366, 0.037, 0.042})
	green := pt.DiffuseMaterial(pt.Color{0.163, 0.409, 0.083})
	light := pt.LightMaterial(pt.Color{0.780, 0.780, 0.776}, 10, pt.QuadraticAttenuation(0.1))
	scene := pt.Scene{}
	n := 10.0
	scene.Add(pt.NewCube(pt.Vector{-n, -11, -n}, pt.Vector{n, -10, n}, white))
	scene.Add(pt.NewCube(pt.Vector{-n, 10, -n}, pt.Vector{n, 11, n}, white))
	scene.Add(pt.NewCube(pt.Vector{-n, -n, 10}, pt.Vector{n, n, 11}, white))
	scene.Add(pt.NewCube(pt.Vector{-11, -n, -n}, pt.Vector{-10, n, n}, red))
	scene.Add(pt.NewCube(pt.Vector{10, -n, -n}, pt.Vector{11, n, n}, green))
	scene.Add(pt.NewSphere(pt.Vector{3, -7, -3}, 3, white))
	cube := pt.NewCube(pt.Vector{-3, -4, -3}, pt.Vector{3, 4, 3}, white)
	transform := pt.Rotate(pt.Vector{0, 1, 0}, pt.Radians(30)).Translate(pt.Vector{-3, -6, 4})
	scene.Add(pt.NewTransformedShape(cube, transform))
	scene.Add(pt.NewCube(pt.Vector{-2, 9.8, -2}, pt.Vector{2, 10, 2}, light))
	camera := pt.LookAt(pt.Vector{0, 0, -20}, pt.Vector{0, 0, 1}, pt.Vector{0, 1, 0}, 65)
	pt.IterativeRender("out%03d.png", 10, &scene, &camera, 512, 512, -1, 16, 4)
}
Beispiel #4
0
func main() {
	scene := pt.Scene{}
	meshes := []pt.Shape{
		createMesh(pt.GlossyMaterial(pt.HexColor(0x730046), 1.6, pt.Radians(45))),
		createMesh(pt.GlossyMaterial(pt.HexColor(0xBFBB11), 1.6, pt.Radians(45))),
		createMesh(pt.GlossyMaterial(pt.HexColor(0xFFC200), 1.6, pt.Radians(45))),
		createMesh(pt.GlossyMaterial(pt.HexColor(0xE88801), 1.6, pt.Radians(45))),
		createMesh(pt.GlossyMaterial(pt.HexColor(0xC93C00), 1.6, pt.Radians(45))),
	}
	for x := -6; x <= 3; x++ {
		mesh := meshes[(x+6)%len(meshes)]
		for y := -5; y <= 4; y++ {
			fx := float64(x) / 2
			fy := float64(y)
			fz := float64(x) / 2
			scene.Add(pt.NewTransformedShape(mesh, pt.Translate(pt.Vector{fx, fy, fz})))
		}
	}
	scene.Add(pt.NewSphere(pt.Vector{1, 0, 10}, 3, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{-5, 0, 5}, pt.Vector{1, 0, 0}, pt.Vector{0, 0, 1}, 45)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 5475, 3675, -1, 16, 3)
}