2015-09-30 élasticité, vapory and reflections

L'installation Elasticité dynamique agit comme un filtre et génère de nouveaux espaces démultipliés, comme un empilement quasi infini d'horizons. Par principe de réflexion, la pièce absorbe l'image de l'environnement et accumule les points de vue ; le mouvement permanent requalifie continuellement ce qui est regardé et entendu.

Ce post simule un rendu de reflection utilisant povray.

A scene with mirrors rendered with vapory (see http://blog.invibe.net/posts/2015-01-16-rendering-3d-scenes-in-python.html )

In [1]:
%load_ext autoreload
%autoreload 2
from vapory import *
import numpy as np

W, H = 1024, 500

lx, ly, lz = .2, 3.0, 5.0 # épaisseur, hauteur, largeur
location = [0, 1.75, -8]
head_size = .4
look_at = [0, 1.5, 0]
head_location = np.array(location) - np.array([0, 0, head_size])
antialiasing = 0.001 # The nearer from zero, the more precise the image.
quality = 120
light_intensity = 1.

light = LightSource([15, 15, -10], 'color', [light_intensity]*3)
wall = Plane([0, 0, 1], 0, Texture(Pigment('color', [1, 1, 1])), 'translate', (0, 0, 25))
ground = Plane( [0, 1, 0], 0,
                Texture( Pigment( 'color', [1, .8, 1, 0.2]),
                         Finish( 'phong', 0.1,
                                 'reflection',0.1,
                                 'metallic', 0.1)))

# for transformations, see http://www.povray.org/documentation/view/3.6.1/49/
reflection = 1.

plane1 = Box([-lx/2, 0, -lz/2], [lx/2, ly, lz/2], Pigment('color', [0, 0, 1]),
                                  Finish('phong', 0.8, 'reflection', reflection), 
                     'rotate', (0, -18, 0),
                     'translate', (2, 0, 0))
plane2 = Box([-lx/2, 0, -lz/2], [lx/2, ly, lz/2], Pigment('color', [1, 0, 0]),
                                  Finish('phong', 0.8, 'reflection', reflection),
                     'rotate', (0, 61, 0),
                     'translate', (-2, 0, 3))

me = vapory.Sphere( head_location, head_size, vapory.Texture( vapory.Pigment( 'color', [1, 0, 1] )))

scene = Scene( Camera("location", location, "look_at", look_at),
               objects = [ ground, wall, light, plane1, plane2, me],
               included=["glass.inc"])
scene.render('ipython', width=W, height=H,
             antialiasing = antialiasing, # The nearer from zero, the more precise the image.
              quality=quality)
Out[1]:
In [2]:
light_intensity = 10.

light = LightSource([15, 15, -10], 'color', [light_intensity]*3)

def vapory_box(lhw, xyz, R, tex='T_Ruby_Glass'):
    """ 
    Draws a box on the floor rotates it and then moves it at the given position
    
    """
    return Box([-lhw[0]/2, 0, -lhw[2]/2], [lhw[0]/2, lhw[1],lhw[2]/2],
                Texture(tex), Interior('ior', 10),
                'rotate', R,
                'translate', xyz)

scene = Scene( Camera("location", location, "look_at", look_at),
               objects = [ light, # ground, wall,
                         vapory_box((10, 5., 1), (-2, 0, 3), (0, 0, 0), tex='T_Ruby_Glass'),
                         vapory_box((10, 5., 1), (2, 0, 3), (0, 60, 0), tex='T_Yellow_Glass'),
                         vapory_box((10, 5., 1), (-2, 0, 3), (0, 45, 90), tex='T_Green_Glass')],
               included=["glass.inc", "textures.inc", "glass.inc"])
scene.render('ipython', width=W, height=H,
             antialiasing = antialiasing, # The nearer from zero, the more precise the image.
              quality=quality)
Out[2]:
In [3]:
scene = Scene( Camera("location", location, "look_at", look_at),
               objects = [ light, # ground, wall,
                         vapory_box((10, 1., 1), (0, 0, 3), (45, 0, 0), tex='T_Ruby_Glass'),
                         vapory_box((10, 1., 1), (0, 0, 3), (0, 45, 0), tex='T_Yellow_Glass'),
                         vapory_box((10, 1., 1), (0, 0, 3), (0, 0, 45), tex='T_Green_Glass'),
                         vapory_box((10, 1., 1), (0, 0, 3), (90, 0, 0), tex='T_Ruby_Glass'),
                         vapory_box((10, 1., 1), (0, 0, 3), (0, 90, 0), tex='T_Yellow_Glass'),
                         vapory_box((10, 1., 1), (0, 0, 3), (0, 0, 90), tex='T_Green_Glass')],
               included=["glass.inc", "textures.inc", "glass.inc"])
scene.render('ipython', width=W, height=H, antialiasing = antialiasing, quality=quality)
Out[3]:
In [4]:
scene = Scene( Camera("location", location, "look_at", look_at),
               objects = [ light, # ground, wall,
                         vapory_box((10, 3., .1), (0, 0, 3), (0, 0, 0), tex='T_Ruby_Glass'),
                         vapory_box((10, 3., .1), (0, 0, 3), (0, 60, 0), tex='T_Yellow_Glass'),
                         vapory_box((10, 3., .1), (0, 0, 3), (0, 90, 0), tex='T_Green_Glass')],
               included=["glass.inc", "textures.inc", "glass.inc"])
scene.render('ipython', width=W, height=H, antialiasing = antialiasing, quality=quality)
Out[4]:
In [5]:
location = [0, 1.75, -2]
scene = Scene( Camera("location", location, "look_at", look_at),
               objects = [ light, # ground, wall,
                         vapory_box((.2, 3., .01), (-1, 0, 3), (0, 0, 0), tex='T_Ruby_Glass'),
                         vapory_box((.2, 3., .01), (0, 0, 3), (0, 60, 0), tex='T_Yellow_Glass'),
                         vapory_box((.2, 3., .01), (1, 0, 3), (0, 90, 0), tex='T_Green_Glass')],
               included=["glass.inc", "textures.inc", "glass.inc"])
scene.render('ipython', width=W, height=H, antialiasing = antialiasing, quality=quality)
Out[5]:

including a background:

In [6]:
background_depth = 100
foreground = Box([0, 0, 0], [1, 1, 1], 
                 Texture(Pigment(ImageMap('png', '"../files/VISUEL_104.png"', 'once')),
                         Finish('ambient', 1.2) ),
                 'scale', [background_depth, background_depth, 0],
                 'translate', [-background_depth/2, -.45*background_depth, background_depth/2])

scene = Scene( Camera("location", location, "look_at", look_at),
               objects = [foreground],# ground
               included=["glass.inc"] )
scene.render('ipython', width=W, height=H,
             antialiasing = antialiasing, # The nearer from zero, the more precise the image.
              quality=quality)
Out[6]: