diff --git a/enonce01.pdf b/enonce01.pdf deleted file mode 100644 index 9bb7f798574c344d3aaf82e0260c7290fa5b45fa..0000000000000000000000000000000000000000 Binary files a/enonce01.pdf and /dev/null differ diff --git a/scenes/multiprocessing.py b/scenes/multiprocessing.py index 2e7fb230bc98cb80cf895f8a1ac51e9014dfd5ac..0afca63e46d7ecd74000453465d942bff023eeac 100644 --- a/scenes/multiprocessing.py +++ b/scenes/multiprocessing.py @@ -18,19 +18,13 @@ def trace_ray_mutliprocess(t): (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)) diff --git a/script.py b/scripts/script.py similarity index 82% rename from script.py rename to scripts/script.py index a15d386ef67930661098fcba0107b7e4b37e2e51..032a962ad357c08aa0242232f5aa4f20057c7833 100644 --- a/script.py +++ b/scripts/script.py @@ -1,4 +1,7 @@ -from scene import * +# Show to python where to find the modules +import sys + +sys.path.append('..')from scene import * from light import Spotlight from camera import Camera from raytracer import raytracer_render diff --git a/scripts/script_multiprocessing.py b/scripts/script_multiprocessing.py new file mode 100644 index 0000000000000000000000000000000000000000..2e7fb230bc98cb80cf895f8a1ac51e9014dfd5ac --- /dev/null +++ b/scripts/script_multiprocessing.py @@ -0,0 +1,46 @@ +# 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) diff --git a/script_one_sphere.py b/scripts/script_one_sphere.py similarity index 93% rename from script_one_sphere.py rename to scripts/script_one_sphere.py index f92e8dc7c1c9092daa2ad7d2d527b612178ae327..80402df3840c94ab7ac4e18fc2f58bd14041e461 100644 --- a/script_one_sphere.py +++ b/scripts/script_one_sphere.py @@ -1,3 +1,6 @@ +# Show to python where to find the modules +import sys + from scene import * from light import Spotlight from camera import Camera diff --git a/reflection.py b/scripts/script_reflection.py similarity index 98% rename from reflection.py rename to scripts/script_reflection.py index bdb61f998c1218aff88110a3a10b5cc2990f44f3..67cbff512c19b34433760c8f99d80e8c1308ff94 100644 --- a/reflection.py +++ b/scripts/script_reflection.py @@ -1,4 +1,6 @@ # Show to python where to find the modules +import sys + from scene import * from light import Spotlight from camera import Camera diff --git a/script_shadow.py b/scripts/script_shadow.py similarity index 93% rename from script_shadow.py rename to scripts/script_shadow.py index fd8ded3035a408ee54491b6058a1c08df877a80b..a25a314f33a3145ece8aa92cc11cabf71b955101 100644 --- a/script_shadow.py +++ b/scripts/script_shadow.py @@ -1,3 +1,6 @@ +# Show to python where to find the modules +import sys + from scene import * from light import Spotlight from camera import Camera