equal
deleted
inserted
replaced
1 #include "raytracer.h" |
1 #include "raytracer.h" |
2 #include "octree.h" |
2 #include "octree.h" |
3 |
3 |
4 #include "image.h" |
|
5 #include "common_sdl.h" |
4 #include "common_sdl.h" |
6 |
5 |
7 Camera cam; |
6 Camera cam; |
8 Light light(Vector3(-2.0, 10.0, -2.0), Colour(0.9, 0.9, 0.9)); |
7 Light light(Vector3(-2.0, 10.0, -2.0), Colour(0.9, 0.9, 0.9)); |
9 |
8 |
106 |
105 |
107 /* render image */ |
106 /* render image */ |
108 if (argc == 2 && !strcmp(argv[1], "-r")) |
107 if (argc == 2 && !strcmp(argv[1], "-r")) |
109 { |
108 { |
110 pyrit_verbosity = 2; |
109 pyrit_verbosity = 2; |
111 Float *fdata = (Float *) malloc(w*h*3*sizeof(Float)); |
110 DefaultSampler sampler(w, h); |
112 DefaultSampler sampler(fdata, w, h); |
|
113 sampler.setOversample(2); |
111 sampler.setOversample(2); |
114 rt.setSampler(&sampler); |
112 rt.setSampler(&sampler); |
115 rt.render(); |
113 rt.render(); |
116 |
114 sampler.getPixmap().writePNG("spheres_shadow.png"); |
117 struct image *img; |
|
118 new_image(&img, w, h, 3); |
|
119 |
|
120 Float *fd = fdata; |
|
121 for (unsigned char *cd = img->data; cd != img->data + w*h*3; cd++, fd++) { |
|
122 if (*fd > 1.0) |
|
123 *cd = 255; |
|
124 else |
|
125 *cd = (unsigned char)(*fd * 255.0); |
|
126 } |
|
127 free(fdata); |
|
128 save_png("spheres_shadow.png", img); |
|
129 destroy_image(&img); |
|
130 } |
115 } |
131 } |
116 } |