@@ -45,75 +45,42 @@ begin
45
45
s1 = tmesh (LowSphere (0.5f0 ), material_white)
46
46
s2 = tmesh (LowSphere (0.3f0 , Point3f (0.5 , 0.5 , 0 )), material_blue)
47
47
s3 = tmesh (LowSphere (0.3f0 , Point3f (- 0.5 , 0.5 , 0 )), mirror)
48
- s4 = tmesh (LowSphere (0.4f0 , Point3f (0.0 , 1.0 , 0 )), material_white)
49
- ground = tmesh (Rect3f (Vec3f (- 5 , - 5 , 0 ), Vec3f (10 , 10 , - 0.1 )), mirror)
50
- left = tmesh (Rect3f (Vec3f (- 3 , 0 , 0 ), Vec3f (- 0.1 , 10 , - 0.1 )), mirror)
48
+ s4 = tmesh (LowSphere (0.4f0 , Point3f (0 , 1.0 , 0 )), glass)
51
49
52
- bvh = Trace. BVHAccel ([s1... , s2... , s3... , s4... , ground... ], 1 );
50
+ ground = tmesh (Rect3f (Vec3f (- 5 , - 5 , 0 ), Vec3f (10 , 10 , 0.01 )), mirror)
51
+ back = tmesh (Rect3f (Vec3f (- 5 , - 3 , 0 ), Vec3f (10 , 0.01 , 10 )), material_white)
52
+ l = tmesh (Rect3f (Vec3f (- 2 , - 5 , 0 ), Vec3f (0.01 , 10 , 10 )), material_red)
53
+ r = tmesh (Rect3f (Vec3f (2 , - 5 , 0 ), Vec3f (0.01 , 10 , 10 )), material_blue)
54
+
55
+ bvh = Trace. BVHAccel ([s1... , s2... , s3... , s4... , ground... , back... , l... , r... ], 1 );
53
56
54
57
lights = [
55
- Trace. PointLight (Vec3f (0 , 2.5 , 4 ), Trace. RGBSpectrum (60.0f0 )),
56
- Trace. PointLight (Vec3f (- 5 , 2 , 0 ), Trace. RGBSpectrum (60.0f0 )),
58
+ # Trace.PointLight(Vec3f(0, -1, 2), Trace.RGBSpectrum(22.0f0)),
59
+ Trace. PointLight (Vec3f (0 , 0 , 2 ), Trace. RGBSpectrum (10.0f0 )),
60
+ Trace. PointLight (Vec3f (0 , 3 , 3 ), Trace. RGBSpectrum (15.0f0 )),
57
61
]
58
62
scene = Trace. Scene (lights, bvh);
59
- resolution = Point2f (1024 )
63
+ resolution = Point2f (10 )
60
64
f = Trace. LanczosSincFilter (Point2f (1.0f0 ), 3.0f0 )
61
65
film = Trace. Film (resolution,
62
66
Trace. Bounds2 (Point2f (0.0f0 ), Point2f (1.0f0 )),
63
67
f, 1.0f0 , 1.0f0 ,
64
68
" shadows_sppm_res.png" ,
65
69
)
66
70
screen_window = Trace. Bounds2 (Point2f (- 1 ), Point2f (1 ))
67
- camera = Trace. PerspectiveCamera (
68
- Trace. look_at (Point3f (0 , 3 , 3 ), Point3f (0 , 0 , 0 ), Vec3f (0 , 0 , 1 )),
71
+ cam = Trace. PerspectiveCamera (
72
+ Trace. look_at (Point3f (0 , 4 , 2 ), Point3f (0 , - 4 , - 1 ), Vec3f (0 , 0 , 1 )),
69
73
screen_window, 0.0f0 , 1.0f0 , 0.0f0 , 1.0f6 , 45.0f0 , film,
70
74
)
71
- integrator = Trace. WhittedIntegrator (camera, Trace. UniformSampler (8 ), 1 )
72
- integrator (scene)
75
+
76
+ end
77
+ begin
78
+ integrator = Trace. WhittedIntegrator (cam, Trace. UniformSampler (8 ), 1 )
79
+ @time integrator (scene)
73
80
img = reverse (film. framebuffer, dims= 1 )
74
81
end
75
- x = Trace. scale (2 , 2 , 2 )
76
- x. inv_m == inv (x. m)
77
- GLMakie. activate! (inline= true )
78
- # Computer projective camera transformations.
79
- resolution = Point2f (1024 )
80
- resolution = Trace. scale (resolution[1 ], resolution[2 ], 1 )
81
-
82
- window_width = screen_window. p_max .- screen_window. p_min
83
- inv_bounds = Trace. scale ((1.0f0 ./ window_width). .. , 1 )
84
-
85
- offset = Trace. translate (Vec3f (
86
- - screen_window. p_min... , 0.0f0 ,
87
- ))
88
-
89
- ray = camera. core. raster_to_camera (Point3f (1024 / 2 , 1024 / 2 , 0 ))
90
- camera. core. screen_to_raster (camera. core. camera_to_screen (ray))
91
-
92
- camera. core. screen_to_raster (Point3f (- 1 , - 1 , 0 ))
93
- camera. core. screen_to_raster (Point3f (1 , 1 , 0 ))
94
-
95
- camera. core. raster_to_screen (Point3f (1024 , 1024 , 0 ))
96
-
97
- camera. core. screen_to_raster (Point3f (- 1 , - 1 , 0 ))# == (0, 0, 0)
98
- camera. core. screen_to_raster (Point3f (1 , 1 , 0 ))# == (1024, 1024, 0)
99
-
100
- camera. core. raster_to_screen (Point3f (0 , 0 , 0 )) # == (0, 0, 0)
101
- camera. core. screen_to_raster (Point3f (1 , 1 , 0 )) # == (1024, 1024, 0)
102
-
103
-
104
- res_t = Trace. scale (resolution... , 1 )
105
- window_width = screen_window. p_max .- screen_window. p_min
106
- inv_bounds = Trace. scale ((1f0 ./ window_width). .. , 1 )
107
-
108
- offset = Trace. translate (Vec3f (
109
- (- screen_window. p_min). .. , 0f0 ,
110
- ))
111
-
112
- inv (res_t. m)
113
- screen_to_raster = res_t * inv_bounds * offset
114
-
115
- screen_to_raster (Point3f (1 , 1 , 0 ))
116
-
117
- raster_to_screen = inv (offset) * inv (inv_bounds) * inv (res_t)
118
-
119
- raster_to_screen (Point3f (1024 , 1024 , 0 ))
82
+ # begin
83
+ # integrator = Trace.SPPMIntegrator(cam, 0.075f0, 5, 100)
84
+ # integrator(scene)
85
+ # img = reverse(film.framebuffer, dims=1)
86
+ # end
0 commit comments