Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dev_log
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Koltes
dev_log
Commits
9882bd61
Commit
9882bd61
authored
9 years ago
by
Benjamin Koltes
Browse files
Options
Downloads
Patches
Plain Diff
multiprocess
parent
a9ca3b78
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
scenes/__pycache__/test.cpython-33.pyc
+0
-0
0 additions, 0 deletions
scenes/__pycache__/test.cpython-33.pyc
scenes/multiprocessing.py
+17
-14
17 additions, 14 deletions
scenes/multiprocessing.py
scenes/test.png
+0
-0
0 additions, 0 deletions
scenes/test.png
with
17 additions
and
14 deletions
scenes/__pycache__/test.cpython-33.pyc
0 → 100644
+
0
−
0
View file @
9882bd61
File added
This diff is collapsed.
Click to expand it.
scenes/
test
.py
→
scenes/
multiprocessing
.py
+
17
−
14
View file @
9882bd61
...
@@ -5,39 +5,42 @@ sys.path.append('..')
...
@@ -5,39 +5,42 @@ sys.path.append('..')
from
camera
import
Camera
from
camera
import
Camera
from
scene
import
*
from
scene
import
*
from
light
import
*
from
light
import
*
from
raytracer
import
imsave
from
raytracer
import
*
import
numpy
as
np
import
numpy
as
np
import
matplotlib.image
from
matplotlib.image
import
imsave
import
itertools
import
itertools
import
multiprocessing
import
multiprocessing
def
trace_ray_mutliprocess
(
t
):
def
trace_ray_mutliprocess
(
t
):
(
i
,
j
,
camera
,
scene
,
nb_reflexion
)
=
t
(
i
,
j
,
camera
,
scene
,
nb_reflexion
)
=
t
return
trace_ray
(
camera
.
ray_at
(
i
,
j
),
scene
,
camera
,
nb_reflexion
)
return
np
.
array
(
trace_ray
(
camera
.
ray_at
(
i
,
j
),
scene
,
camera
,
nb_reflexion
)
.
coord
())
(
nx
,
ny
,
nb_reflexion
)
=
(
1000
,
1000
,
1
0
)
(
nx
,
ny
,
nb_reflexion
)
=
(
1000
,
1000
,
2
0
)
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_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_verte
=
Sphere
(
Vector
([
3
,
-
3
,
4
]),
2.5
,
materiau_sphere_verte
)
sphere_bleue
=
Sphere
(
Vector
([
0
,
0
,
3
]),
0.8
,
materiau_sphere_bleue
)
sphere_bleue
=
Sphere
(
Vector
([
0
,
0
,
3
]),
.
8
,
materiau_sphere_bleue
)
sphere_rouge
=
Sphere
(
Vector
([
0.5
,
0.5
,
2
]),
0.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_verte
)
scene
.
add_object
(
sphere_blanche
)
scene
.
add_light
(
lumiere
)
scene
.
add_light
(
lumiere
)
img
=
np
.
zeros
((
nx
,
ny
,
3
))
affiche
=
np
.
zeros
((
nx
,
ny
,
3
))
R
ows
=
list
(
range
(
nx
))
r
ows
=
list
(
range
(
nx
))
C
ol
o
ns
=
list
(
range
(
ny
))
c
ol
um
ns
=
list
(
range
(
ny
))
carte
=
list
(
itertools
.
product
(
R
ows
,
C
ol
o
ns
,
[
camera
],
[
scene
],
[
nb_reflexion
]))
carte
=
list
(
itertools
.
product
(
r
ows
,
c
ol
um
ns
,
[
camera
],
[
scene
],
[
nb_reflexion
]))
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
pool
=
multiprocessing
.
Pool
(
8
)
pool
=
multiprocessing
.
Pool
(
8
)
affiche
=
pool
.
map
(
trace_ray_mutliprocess
,
carte
)
affiche
_map
=
pool
.
map
(
trace_ray_mutliprocess
,
carte
)
p
.
close
()
p
ool
.
close
()
p
.
join
()
p
ool
.
join
()
img
=
np
.
array
(
img
).
reshape
(
nx
,
ny
,
3
)
affiche
=
np
.
array
(
affiche_map
).
reshape
(
nx
,
ny
,
3
)
imsave
(
'
test.png
'
,
affiche
)
imsave
(
'
test.png
'
,
affiche
)
This diff is collapsed.
Click to expand it.
scenes/test.png
0 → 100644
+
0
−
0
View file @
9882bd61
51.1 KiB
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment