floor.material.color = Color(1, 0.9, 0.9) # floor.material.pattern = pattern backdrop = Plane() backdrop.transform = \ rotation_y(pi / 3) * translation(0, 0, 5) * rotation_x(pi / 2) backdrop2 = Plane() backdrop2.transform = \ rotation_y(-pi / 3) * translation(0, 0, 5) * rotation_x(pi / 2) middle = Sphere() # middle = glass_sphere() middle.transform = translation(-0.5, 1, 0.5) # middle.reflective = 1.0 middle.material = Material() middle.material.color = Color(0.1, 1, 0.5) # middle.material.pattern = pattern middle.material.diffuse = 0.7 middle.material.specular = 0.3 # middle.material.reflective = 1.0 # right = Sphere() right = glass_sphere() right.transform = translation(1.5, 0.5, -0.5) * scaling(0.5, 0.5, 0.5) right.material.reflective = 0.9 right.material.transparency = 0.9 right.material.refractive_index = 1.5 # right.material = Material() # right.material.color = Color(0.5, 1, 0.1) # right.material.pattern = pattern
from raytracerchallenge_python.intersection import Intersections from raytracerchallenge_python.canvas import Canvas from raytracerchallenge_python.material import Material from raytracerchallenge_python.point_light import PointLight if __name__ == "__main__": ray_origin = Point(0, 0, -5) wall_z = 10 wall_size = 7.0 canvas_pixcels = 100 pixel_size = wall_size / canvas_pixcels half = wall_size / 2 canvas = Canvas(canvas_pixcels, canvas_pixcels) shape = Sphere() shape.material = Material() shape.material.color = Color(1, 0.2, 1) light_position = Point(-10, 10, -10) light_color = Color(1, 1, 1) light = PointLight(light_position, light_color) # for each row of pixels in the canvas for y in range(canvas_pixcels): # compute the world y coordinate (top = +half, bottom = -half) world_y = half - pixel_size * y for x in range(canvas_pixcels): # compute the world x coordinate (left = -half, right = half) world_x = -half + pixel_size * x