Ejemplo n.º 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)
}
Ejemplo n.º 2
0
func main() {
	scene := pt.Scene{}
	r := 0.4
	var material pt.Material

	material = pt.DiffuseMaterial(pt.HexColor(0x334D5C))
	scene.Add(pt.NewSphere(pt.Vector{-2, r, 0}, r, material))

	material = pt.SpecularMaterial(pt.HexColor(0x334D5C), 2)
	scene.Add(pt.NewSphere(pt.Vector{-1, r, 0}, r, material))

	material = pt.GlossyMaterial(pt.HexColor(0x334D5C), 2, pt.Radians(50))
	scene.Add(pt.NewSphere(pt.Vector{0, r, 0}, r, material))

	material = pt.TransparentMaterial(pt.HexColor(0x334D5C), 2, pt.Radians(20), 1)
	scene.Add(pt.NewSphere(pt.Vector{1, r, 0}, r, material))

	material = pt.ClearMaterial(2, 0)
	scene.Add(pt.NewSphere(pt.Vector{2, r, 0}, r, material))

	material = pt.SpecularMaterial(pt.HexColor(0xFFFFFF), 1000)
	scene.Add(pt.NewSphere(pt.Vector{0, 1.5, -4}, 1.5, material))

	scene.Add(pt.NewCube(pt.Vector{-1000, -1, -1000}, pt.Vector{1000, 0, 1000}, pt.GlossyMaterial(pt.HexColor(0xFFFFFF), 1.4, pt.Radians(20))))
	scene.Add(pt.NewSphere(pt.Vector{0, 5, 0}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 3, pt.LinearAttenuation(0.4))))
	camera := pt.LookAt(pt.Vector{0, 3, 6}, pt.Vector{0, 1, 0}, pt.Vector{0, 1, 0}, 30)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560/2, 1440/2, -1, 16, 16)
}
Ejemplo n.º 3
0
func main() {
	scene := pt.Scene{}
	floor := pt.GlossyMaterial(pt.HexColor(0xFCFFF5), 1.2, pt.Radians(30))
	cube := pt.GlossyMaterial(pt.HexColor(0xFF8C00), 1.3, pt.Radians(20))
	ball := pt.GlossyMaterial(pt.HexColor(0xD90000), 1.4, pt.Radians(10))
	n := 7
	fn := float64(n)
	for z := 0; z < n; z++ {
		for x := 0; x < n-z; x++ {
			for y := 0; y < n-z-x; y++ {
				fx, fy, fz := float64(x), float64(y), float64(z)
				scene.Add(pt.NewCube(pt.Vector{fx, fy, fz}, pt.Vector{fx + 1, fy + 1, fz + 1}, cube))
				if x+y == n-z-1 {
					if rand.Float64() > 0.75 {
						scene.Add(pt.NewSphere(pt.Vector{fx + 0.5, fy + 0.5, fz + 1.5}, 0.35, ball))
					}
				}
			}
		}
	}
	scene.Add(pt.NewCube(pt.Vector{-1000, -1000, -1}, pt.Vector{1000, 1000, 0}, floor))
	scene.Add(pt.NewSphere(pt.Vector{fn, fn / 3, fn * 2}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{fn * 2, fn * 2, fn * 2}, pt.Vector{0, 0, fn / 4}, pt.Vector{0, 0, 1}, 35)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2880, 1800, -1, 16, 4)
}
Ejemplo n.º 4
0
func (s *Renderer) Render(ctx context.Context, req *pb.RenderRequest) (*pb.RenderResponse, error) {
	scene := pt.Scene{}
	wall := pt.SpecularMaterial(pt.HexColor(0x2FC92C), 8)
	//texture, err := pt.LoadTexture("valentyn.jpg")
	img, _, err := image.Decode(bytes.NewReader(req.Texture))
	texture := pt.NewTexture(img)
	if err != nil {
		return nil, err
	}
	wall.Texture = texture
	scene.Add(pt.NewSphere(pt.Vector{1.5, 1, 0}, 1, pt.SpecularMaterial(pt.HexColor(0x334D5C), 8)))
	scene.Add(pt.NewSphere(pt.Vector{-1, 1, 2}, 1, wall))
	scene.Add(pt.NewSphere(pt.Vector{-3, 1, 0.5}, 1, wall))
	scene.Add(pt.NewSphere(pt.Vector{-0.5, 0.5, -1.4}, 0.7, wall))
	scene.Add(pt.NewCube(pt.Vector{-100, -1, -100}, pt.Vector{100, 0, 100}, pt.DiffuseMaterial(pt.Color{1, 1, 1})))
	scene.Add(pt.NewSphere(pt.Vector{-1, 4, -1}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 3, pt.LinearAttenuation(1))))
	camera := pt.LookAt(pt.Vector{-1.5 + rand.Float64()*2, 2 + rand.Float64()*2, -5}, pt.Vector{0, 0, 3}, pt.Vector{0, 1, 0}, 45)
	im := pt.Render(&scene, &camera, 320, 240, 4, 16, 18)
	buf := new(bytes.Buffer)
	err = jpeg.Encode(buf, im, nil)
	if err != nil {
		return nil, err
	}
	return &pb.RenderResponse{Image: buf.Bytes()}, nil
}
Ejemplo n.º 5
0
func main() {
	scene := pt.Scene{}
	texture, err := pt.LoadTexture("examples/texture.png")
	if err != nil {
		panic(err)
	}
	material := pt.GlossyMaterial(pt.HexColor(0xFCFAE1), 1.1, pt.Radians(20))
	material.Texture = texture
	var triangles []*pt.Triangle
	for x := -10; x <= 10; x++ {
		for z := -10; z <= 10; z++ {
			h := rand.Intn(4)
			for y := 0; y <= h; y++ {
				p := pt.Vector{float64(x), float64(y), float64(z)}
				tiles := Dirt
				if y == h {
					tiles = Grass
				}
				cube := Cube(p, material, tiles)
				triangles = append(triangles, cube...)
			}
		}
	}
	mesh := pt.NewMesh(triangles)
	scene.Add(mesh)
	camera := pt.LookAt(pt.Vector{-13, 11, -7}, pt.Vector{0, 0, 0}, pt.Vector{0, 1, 0}, 45)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560/2, 1440/2, -1, 4, 4)
}
Ejemplo n.º 6
0
func main() {
	scene := pt.Scene{}
	scene.Add(pt.NewSphere(pt.Vector{1.5, 1, 0}, 1, pt.SpecularMaterial(pt.HexColor(0x334D5C), 2)))
	scene.Add(pt.NewSphere(pt.Vector{-1, 1, 2}, 1, pt.SpecularMaterial(pt.HexColor(0xEFC94C), 2)))
	scene.Add(pt.NewCube(pt.Vector{-100, -1, -100}, pt.Vector{100, 0, 100}, pt.DiffuseMaterial(pt.Color{1, 1, 1})))
	scene.Add(pt.NewSphere(pt.Vector{-1, 4, -1}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 3, pt.LinearAttenuation(1))))
	camera := pt.LookAt(pt.Vector{0, 2, -5}, pt.Vector{0, 0, 3}, pt.Vector{0, 1, 0}, 45)
	pt.IterativeRender("out%03d.png", 10, &scene, &camera, 2560/4, 1440/4, 4, 64, 8)
}
Ejemplo n.º 7
0
func main() {
	scene := pt.Scene{}
	material := pt.GlossyMaterial(pt.HexColor(0xFCFAE1), 1.5, pt.Radians(20))
	mesh, err := pt.LoadOBJ("examples/dragon.obj", material)
	if err != nil {
		log.Fatalln("LoadOBJ error:", err)
	}
	mesh.FitInside(pt.Box{pt.Vector{-1, -1, -1}, pt.Vector{1, 1, 1}}, pt.Vector{0.5, 0.5, 0.5})
	scene.Add(mesh)
	scene.Add(pt.NewSphere(pt.Vector{0, 10, 0}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{-3, 1, 0}, pt.Vector{0, 0, 0}, pt.Vector{0, 1, 0}, 45)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 512, 512, -1, 16, 4)
}
Ejemplo n.º 8
0
func main() {
	scene := pt.Scene{}
	material := pt.GlossyMaterial(pt.HexColor(0xFCFAE1), 1.5, pt.Radians(20))
	mesh, err := pt.LoadOBJ("examples/dabrovic-sponza/sponza.obj", material)
	if err != nil {
		log.Fatalln("LoadOBJ error:", err)
	}
	mesh.MoveTo(pt.Vector{}, pt.Vector{0.5, 0, 0.5})
	scene.Add(mesh)
	scene.Add(pt.NewSphere(pt.Vector{0, 20, 0}, 3, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{-10, 2, 0}, pt.Vector{0, 4, 0}, pt.Vector{0, 1, 0}, 45)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560/2, 1440/2, -1, 16, 3)
}
Ejemplo n.º 9
0
func main() {
	rand.Seed(6)
	floor := pt.GlossyMaterial(pt.HexColor(0xFCFFF5), 1.5, pt.Radians(20))
	light := pt.LightMaterial(pt.HexColor(0xFFFFFF), 1, pt.QuadraticAttenuation(0.002))
	triangles := LoadTriangles("examples/counties.csv")
	mesh := pt.NewMesh(triangles)
	mesh.FitInside(pt.Box{pt.Vector{-1, -1, 0}, pt.Vector{1, 1, 1}}, pt.Vector{0.5, 0.5, 0})
	scene := pt.Scene{}
	scene.Add(mesh)
	scene.Add(pt.NewCube(pt.Vector{-100, -100, -1}, pt.Vector{100, 100, 0.03}, floor))
	scene.Add(pt.NewSphere(pt.Vector{0, 4, 10}, 4, light))
	camera := pt.LookAt(pt.Vector{0, -0.25, 2}, pt.Vector{0, 0, 0}, pt.Vector{0, 0, 1}, 35)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560/2, 1440/2, -1, 4, 4)
}
Ejemplo n.º 10
0
func main() {
	scene := pt.Scene{}
	wall := pt.SpecularMaterial(pt.HexColor(0xFCFAE1), 2)
	scene.Add(pt.NewSphere(pt.Vector{4, 7, 3}, 2, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewCube(pt.Vector{-30, -1, -30}, pt.Vector{-8, 10, 30}, wall))
	scene.Add(pt.NewCube(pt.Vector{-30, -1, -30}, pt.Vector{30, 0.376662, 30}, wall))
	material := pt.GlossyMaterial(pt.Color{}, 1.5, pt.Radians(30))
	mesh, err := pt.LoadOBJ("examples/gopher.obj", material)
	if err != nil {
		log.Fatalln("LoadOBJ error:", err)
	}
	mesh.SmoothNormals()
	scene.Add(mesh)
	camera := pt.LookAt(pt.Vector{8, 3, 0.5}, pt.Vector{-1, 2.5, 0.5}, pt.Vector{0, 1, 0}, 45)
	pt.IterativeRender("out%03d.png", 10, &scene, &camera, 2560/4, 1440/4, -1, 16, 4)
}
Ejemplo n.º 11
0
func main() {
	scene := pt.Scene{}
	scene.Add(pt.NewSphere(pt.Vector{-2, 5, -3}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewSphere(pt.Vector{5, 5, -3}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewCube(pt.Vector{-30, -1, -30}, pt.Vector{30, 0, 30}, pt.SpecularMaterial(pt.HexColor(0xFCFAE1), 2)))
	mesh, err := pt.LoadOBJ("examples/teapot.obj", pt.SpecularMaterial(pt.HexColor(0xB9121B), 2))
	if err != nil {
		log.Fatalln("LoadOBJ error:", err)
	}
	scene.Add(mesh)
	camera := pt.LookAt(pt.Vector{2, 5, -6}, pt.Vector{0.5, 1, 0}, pt.Vector{0, 1, 0}, 45)
	im := pt.Render(&scene, &camera, 2560/4, 1440/4, 4, 16, 4)
	if err := pt.SavePNG("out.png", im); err != nil {
		log.Fatalln("SavePNG error:", err)
	}
}
Ejemplo n.º 12
0
func main() {
	scene := pt.Scene{}
	material := pt.GlossyMaterial(pt.HexColor(0xF2EBC7), 1.5, pt.Radians(0))
	mesh, err := pt.LoadOBJ("examples/bunny.obj", material)
	if err != nil {
		panic(err)
	}
	mesh.SmoothNormalsThreshold(pt.Radians(20))
	mesh.FitInside(pt.Box{pt.Vector{-1, 0, -1}, pt.Vector{1, 2, 1}}, pt.Vector{0.5, 0, 0.5})
	scene.Add(mesh)
	floor := pt.GlossyMaterial(pt.HexColor(0x33332D), 1.2, pt.Radians(20))
	scene.Add(pt.NewCube(pt.Vector{-10000, -10000, -10000}, pt.Vector{10000, 0, 10000}, floor))
	scene.Add(pt.NewSphere(pt.Vector{0, 5, 0}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewSphere(pt.Vector{4, 5, 4}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{-1, 2, 3}, pt.Vector{0, 0.75, 0}, pt.Vector{0, 1, 0}, 50)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560, 1440, -1, 4, 4)
}
Ejemplo n.º 13
0
func main() {
	scene := pt.Scene{}
	scene.SetColor(pt.HexColor(0xFEE7E0))
	// material := pt.GlossyMaterial(pt.HexColor(0x5C832F), 1.5, pt.Radians(20))
	material := pt.TransparentMaterial(pt.HexColor(0xFFFFFF), 2, pt.Radians(20), 0)
	mesh, err := pt.LoadOBJ("examples/dragon.obj", material)
	if err != nil {
		panic(err)
	}
	mesh.FitInside(pt.Box{pt.Vector{-1, 0, -1}, pt.Vector{1, 2, 1}}, pt.Vector{0.5, 0, 0.5})
	scene.Add(mesh)
	floor := pt.GlossyMaterial(pt.HexColor(0xD8CAA8), 1.2, pt.Radians(20))
	scene.Add(pt.NewCube(pt.Vector{-1000, -1000, -1000}, pt.Vector{1000, 0, 1000}, floor))
	scene.Add(pt.NewSphere(pt.Vector{0, 10, 0}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{-3, 2, -1}, pt.Vector{0, 0.5, 0}, pt.Vector{0, 1, 0}, 35)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560/4, 1440/4, -1, 4, 4)
}
Ejemplo n.º 14
0
func main() {
	scene := pt.Scene{}
	material := pt.GlossyMaterial(pt.HexColor(0xF2F2F2), 1.5, pt.Radians(20))
	scene.Add(pt.NewCube(pt.Vector{-100, -1, -100}, pt.Vector{100, 0, 100}, material))
	heart := pt.GlossyMaterial(pt.HexColor(0xF60A20), 1.5, pt.Radians(20))
	mesh, err := pt.LoadBinarySTL("examples/love.stl", heart)
	if err != nil {
		log.Fatalln("LoadBinarySTL error:", err)
	}
	mesh.FitInside(pt.Box{pt.Vector{-0.5, 0, -0.5}, pt.Vector{0.5, 1, 0.5}}, pt.Vector{0.5, 0, 0.5})
	scene.Add(mesh)
	scene.Add(pt.NewSphere(pt.Vector{-2, 10, -2}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewSphere(pt.Vector{0, 10, -2}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewSphere(pt.Vector{2, 10, -2}, 1, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{0, 1.5, -2}, pt.Vector{0, 0.5, 0}, pt.Vector{0, 1, 0}, 35)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 1440, 900, -1, 16, 4)
}
Ejemplo n.º 15
0
func main() {
	scene := pt.Scene{}
	material := pt.DiffuseMaterial(pt.HexColor(0x334D5C))
	scene.Add(pt.NewSphere(pt.Vector{0.5, 1, 3}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewSphere(pt.Vector{1.5, 1, 3}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	scene.Add(pt.NewCube(pt.Vector{-5, -5, -2}, pt.Vector{5, 5, -1}, material))
	mesh, err := pt.LoadOBJ("examples/suzanne.obj", pt.SpecularMaterial(pt.HexColor(0xEFC94C), 2))
	if err != nil {
		log.Fatalln("LoadOBJ error:", err)
	}
	scene.Add(mesh)
	camera := pt.LookAt(pt.Vector{1, -0.45, 4}, pt.Vector{1, -0.6, 0.4}, pt.Vector{0, 1, 0}, 45)
	im := pt.Render(&scene, &camera, 2560/4, 1440/4, 4, 16, 4)
	if err := pt.SavePNG("out.png", im); err != nil {
		log.Fatalln("SavePNG error:", err)
	}
}
Ejemplo n.º 16
0
func main() {
	scene := pt.Scene{}
	material := pt.GlossyMaterial(pt.HexColor(0xEFC94C), 3, pt.Radians(30))
	whiteMat := pt.GlossyMaterial(pt.Color{1, 1, 1}, 3, pt.Radians(30))
	for x := 0; x < 10; x++ {
		for z := 0; z < 10; z++ {
			center := pt.Vector{float64(x) - 4.5, 0, float64(z) - 4.5}
			scene.Add(pt.NewSphere(center, 0.4, material))
		}
	}
	scene.Add(pt.NewCube(pt.Vector{-100, -1, -100}, pt.Vector{100, 0, 100}, whiteMat))
	scene.Add(pt.NewSphere(pt.Vector{-1, 3, -1}, 0.5, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))
	camera := pt.LookAt(pt.Vector{0, 4, -8}, pt.Vector{0, 0, -2}, pt.Vector{0, 1, 0}, 45)
	im := pt.Render(&scene, &camera, 2560/4, 1440/4, 4, 16, 8)
	if err := pt.SavePNG("out.png", im); err != nil {
		log.Fatalln("SavePNG error:", err)
	}
}
Ejemplo n.º 17
0
func main() {
	scene := pt.Scene{}
	material := pt.DiffuseMaterial(pt.HexColor(0xFCFAE1))
	scene.Add(pt.NewCube(pt.Vector{-1000, -1, -1000}, pt.Vector{1000, 0, 1000}, material))
	for x := -20; x <= 20; x++ {
		for z := -20; z <= 20; z++ {
			if (x+z)%2 == 0 {
				continue
			}
			s := 0.1
			min := pt.Vector{float64(x) - s, 0, float64(z) - s}
			max := pt.Vector{float64(x) + s, 2, float64(z) + s}
			scene.Add(pt.NewCube(min, max, material))
		}
	}
	scene.Add(pt.NewCube(pt.Vector{-5, 10, -5}, pt.Vector{5, 11, 5}, pt.LightMaterial(pt.Color{1, 1, 1}, 5, pt.QuadraticAttenuation(0.05))))
	camera := pt.LookAt(pt.Vector{20, 10, 0}, pt.Vector{8, 0, 0}, pt.Vector{0, 1, 0}, 45)
	pt.IterativeRender("out%03d.png", 1000, &scene, &camera, 2560/2, 1440/2, -1, 4, 2)
}
Ejemplo n.º 18
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)
}
Ejemplo n.º 19
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)
}
Ejemplo n.º 20
0
Archivo: green.go Proyecto: davsk/ply
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)
}