Skip to content
Snippets Groups Projects
Commit 632b11c8 authored by Benjamin Koltes's avatar Benjamin Koltes
Browse files

rangements

parent 9882bd61
No related branches found
No related tags found
No related merge requests found
File deleted
...@@ -18,19 +18,13 @@ def trace_ray_mutliprocess(t): ...@@ -18,19 +18,13 @@ def trace_ray_mutliprocess(t):
(nx, ny, nb_reflexion) = (1000, 1000, 20) (nx, ny, nb_reflexion) = (1000, 1000, 20)
camera = Camera(nx, ny, 1) camera = Camera(nx, ny, 1)
materiau_sphere_bleue = Material(Vector([0,0,1.]), .5, .5, .5, 1000,.1) materiau_sphere_bleue = Material(Vector([0,0,1.]), .5, .5, .5, 1000,.1)
materiau_sphere_verte = Material(Vector([0,1,0]), .5, .5, .5, 1000, .6)
materiau_sphere_rouge = Material(Vector([1,0,0]), .5, .5, .5, 1000, .3) materiau_sphere_rouge = Material(Vector([1,0,0]), .5, .5, .5, 1000, .3)
materiau_sphere_blanche = Material(Vector([1,0,0]), .5, .5, .5, 1000, .7)
sphere_verte = Sphere(Vector([3,-3,4]), 2.5, materiau_sphere_verte)
sphere_bleue = Sphere(Vector([0,0,3]), .8, materiau_sphere_bleue) sphere_bleue = Sphere(Vector([0,0,3]), .8, materiau_sphere_bleue)
sphere_rouge = Sphere(Vector([.5,.5,2]), .5, materiau_sphere_rouge) sphere_rouge = Sphere(Vector([.5,.5,2]), .5, materiau_sphere_rouge)
sphere_blanche = Sphere(Vector([0,0,0]), 25, materiau_sphere_blanche)
scene = Scene() scene = Scene()
lumiere = Spotlight(Vector([1,1,0]), Vector([1,1,1])) lumiere = Spotlight(Vector([1,1,0]), Vector([1,1,1]))
scene.add_object(sphere_bleue) scene.add_object(sphere_bleue)
scene.add_object(sphere_rouge) scene.add_object(sphere_rouge)
scene.add_object(sphere_verte)
scene.add_object(sphere_blanche)
scene.add_light(lumiere) scene.add_light(lumiere)
affiche = np.zeros((nx, ny, 3)) affiche = np.zeros((nx, ny, 3))
rows = list(range(nx)) rows = list(range(nx))
......
from scene import * # Show to python where to find the modules
import sys
sys.path.append('..')from scene import *
from light import Spotlight from light import Spotlight
from camera import Camera from camera import Camera
from raytracer import raytracer_render from raytracer import raytracer_render
......
# Show to python where to find the modules
import sys
sys.path.append('..')
from camera import Camera
from scene import *
from light import *
from raytracer import *
import numpy as np
from matplotlib.image import imsave
import itertools
import multiprocessing
def trace_ray_mutliprocess(t):
(i, j, camera, scene, nb_reflexion) = t
return np.array(trace_ray(camera.ray_at(i, j), scene, camera, nb_reflexion).coord())
(nx, ny, nb_reflexion) = (1000, 1000, 20)
camera = Camera(nx, ny, 1)
materiau_sphere_bleue = Material(Vector([0,0,1.]), .5, .5, .5, 1000,.1)
materiau_sphere_verte = Material(Vector([0,1,0]), .5, .5, .5, 1000, .6)
materiau_sphere_rouge = Material(Vector([1,0,0]), .5, .5, .5, 1000, .3)
materiau_sphere_blanche = Material(Vector([1,0,0]), .5, .5, .5, 1000, .7)
sphere_verte = Sphere(Vector([3,-3,4]), 2.5, materiau_sphere_verte)
sphere_bleue = Sphere(Vector([0,0,3]), .8, materiau_sphere_bleue)
sphere_rouge = Sphere(Vector([.5,.5,2]), .5, materiau_sphere_rouge)
sphere_blanche = Sphere(Vector([0,0,0]), 25, materiau_sphere_blanche)
scene = Scene()
lumiere = Spotlight(Vector([1,1,0]), Vector([1,1,1]))
scene.add_object(sphere_bleue)
scene.add_object(sphere_rouge)
scene.add_object(sphere_verte)
scene.add_object(sphere_blanche)
scene.add_light(lumiere)
affiche = np.zeros((nx, ny, 3))
rows = list(range(nx))
columns = list(range(ny))
carte = list(itertools.product(rows, columns, [camera], [scene], [nb_reflexion]))
if __name__ == '__main__':
pool = multiprocessing.Pool(8)
affiche_map = pool.map(trace_ray_mutliprocess, carte)
pool.close()
pool.join()
affiche = np.array(affiche_map).reshape(nx, ny, 3)
imsave('test.png', affiche)
# Show to python where to find the modules
import sys
from scene import * from scene import *
from light import Spotlight from light import Spotlight
from camera import Camera from camera import Camera
......
# Show to python where to find the modules # Show to python where to find the modules
import sys
from scene import * from scene import *
from light import Spotlight from light import Spotlight
from camera import Camera from camera import Camera
......
# Show to python where to find the modules
import sys
from scene import * from scene import *
from light import Spotlight from light import Spotlight
from camera import Camera from camera import Camera
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment