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

scripts

parent a39f5f6f
No related branches found
No related tags found
No related merge requests found
File added
File added
scripts/img.png

50.3 KiB

# Show to python where to find the modules
import sys
sys.path.append('..')
sys.path.append('..')from scene import *
from scene import *
from light import Spotlight
from camera import Camera
from raytracer import raytracer_render
......
......@@ -15,12 +15,12 @@ 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)
(nx, ny, nb_reflexion) = (400, 400, 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)
materiau_sphere_blanche = Material(Vector([1,1,1]), .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)
......@@ -38,9 +38,9 @@ columns = list(range(ny))
carte = list(itertools.product(rows, columns, [camera], [scene], [nb_reflexion]))
if __name__ == '__main__':
pool = multiprocessing.Pool(8)
pool = multiprocessing.Pool(4)
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)
imsave('img.png', affiche)
# Show to python where to find the modules
import sys
sys.path.append('..')
from scene import *
from light import Spotlight
......
# Show to python where to find the modules
import sys
sys.path.append('..')
from scene import *
from light import Spotlight
......
# Show to python where to find the modules
import sys
sys.path.append('..')
from scene import *
from light import Spotlight
......
# 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
from matplotlib.image import imsave
camera = Camera(100,100,1)
materiau_sphere_bleue = Material(Vector((0,0,1)), .5, .3, .3, 100, .5)
materiau_sphere_rouge = Material(Vector((1,0,0)), .5, .3, .3, 100, .3)
materiau_sphere_blanche = Material(Vector((1,1,1)), .5, .3, .3, 100, 0)
materiau_sphere_verte= Material(Vector((0,1,0)), .5, .3, .3, 100, .3)
c = (8+2*(3**.5))**.5
l = 0+0*((c**2 - 4)**.5)
v0 = Vector([0,0,2+l])
v1 = Vector([0,2,2+l])
v2 = Vector([2,0,2+l])
v3 = Vector([0,0,2])
#triangle_rouge = Triangle(v0,v1,v3,materiau_sphere_rouge)
#triangle_vert = Triangle(v1,v2,v3,materiau_sphere_verte)
#triangle_bleu = Triangle(v0,v2,v3,materiau_sphere_bleue)
triangle_blanc = Triangle(v0,v1,v2,materiau_sphere_blanche)
lumiere = Spotlight(Vector((1,1,0)), Vector((1,1,1)))
scene = Scene()
#scene.add_object(sphere_blanche)
#scene.add_object(triangle_bleu)
#scene.add_object(triangle_rouge)
scene.add_object(triangle_blanc)
scene.add_light(lumiere)
affiche = raytracer_render(camera, scene)
imsave('try.png',affiche)
print('Done')
# 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) = (200, 200, 20)
camera = Camera(nx, ny, 1)
materiau_sphere_bleue = Material(Vector([0,0,1]), .5, .5, .5, 1000,0)
materiau_sphere_verte = Material(Vector([0,1,0]), .5, .5, .5, 1000, 0)
materiau_sphere_rouge = Material(Vector([1,0,0]), .5, .5, .5, 1000, 0)
materiau_sphere_blanche = Material(Vector([1,1,1]), 1, 1, 1, 20, 0)
c = (8+2*(3**.5))**.5
l = (c**2 - 4)**.5
v0 = Vector([0,2,2+l])
v1 = Vector([3**.5,-1,2+l])
v2 = Vector([3**.5,-1,2+l])
v3 = Vector([0,0,2])
#triangle_rouge = Triangle(v0,v1,v3,materiau_sphere_rouge)
#triangle_vert = Triangle(v1,v2,v3,materiau_sphere_verte)
#triangle_bleu = Triangle(v0,v2,v3,materiau_sphere_bleue)
triangle_blanc = Triangle(v0,v2,v3,materiau_sphere_blanche)
scene = Scene()
lumiere = Spotlight(Vector([0,0,0]), Vector([1,1,1]))
#scene.add_object(sphere_blanche)
#scene.add_object(triangle_bleu)
#scene.add_object(triangle_rouge)
scene.add_object(triangle_blanc)
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(4)
affiche_map = pool.map(trace_ray_mutliprocess, carte)
pool.close()
pool.join()
affiche = np.array(affiche_map).reshape(nx, ny, 3)
imsave('triangle.png', affiche)
scripts/test.png

43.7 KiB

scripts/try.png

1.57 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment