Пример #1
0
def render_moon(scene):

    light = Light(Color(1.0, 1.0, 1.0, 1.0), 1.0)
    light.transform.position = Vector3(0.0, 2.0, -2.0)
    scene.set_light(light)

    lambertianTintMaterial = Material()
    lambertianTintMaterial.albedo = Color(1.0, 1.0, 1.0, 1.0)
    lambertianTintMaterial.shader = LambertianTintShader()

    s1_earth = Sphere(0.6)
    s1_earth.transform.position = Vector3(0, 0, 1.5)
    s1_earth.material = lambertianTintMaterial.clone()
    scene.add_objects(s1_earth)

    s2_moon = Sphere(0.4)
    s2_moon.transform.position = Vector3(-0.2, -0.5, 1.2)
    s2_moon.material = lambertianTintMaterial.clone()
    s2_moon.material.set_texture(Texture("images/moon.jpg"))
    scene.add_objects(s2_moon)

    v1 = Vector3(0.0, 1.5, 0.5)
    v2 = Vector3(0.5, -1.0, 0.0)
    animation_velocity = 0.4

    def update_method(t):
        p = Vector3(-0.2, -0.5, 1.2)
        p = p.add(v1.multiply(np.cos(animation_velocity * t * np.pi)))
        p = p.add(v2.multiply(np.sin(animation_velocity * t * np.pi)))

        s2_moon.transform.position = p
        s2_moon.transform.rotation = Vector3(
            0.0, np.mod(0.5 * animation_velocity * t, 360), 0.0)

    return update_method
Пример #2
0
# s2 = Sphere(1.2)
# s2.transform.position = Vector3(-0.2, -2.4, 4)
# s2.material = lambertianTintMaterial.clone()
# s2.material.set_texture(Texture("images/moon.jpg"))
# scene_test.add_objects(s2)

zelda_texture = Texture("images/zelda.jpg")

position = Vector3(-2.0, 0.0, 3.0)
v1 = Vector3(2.0, 0.0, 0.0).multiply(zelda_texture.aspect_ratio)
v2 = Vector3(0.0, 2.0, 0.0)

mesh = Mesh()
quadmesh.create(mesh, v1, v2, position)
mesh.material = lambertianTintMaterial.clone()
mesh.material.albedo = Color(1.0, 0.5, 0.5, 1.0)
mesh.material.texture = zelda_texture
scene_test.add_objects(mesh)

c = Camera()
c.fov = 90

scene_test.set_ssaa(1)
scene_test.set_camera(c)

# blur_kernel = np.matrix([[0.0625, 0.125, 0.0625],
#                          [0.125,  0.25,   0.125],
#                          [0.0625, 0.125, 0.0625]])
# sharpen_kernel = np.matrix([[ 0, -1,  0],
#                             [-1,  5, -1],