Subversion Repositories gelsvn

Rev

Rev 353 | Rev 357 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 353 Rev 355
Line 1... Line 1...
1
#include "pathtracer.h"
1
#include "pathtracer.h"
2
 
2
 
3
using namespace CGLA;
3
using namespace CGLA;
4
 
4
 
5
path_tracer::path_tracer(int w, int h, bool explicit_direct, int subsamples)
5
pathtracer::pathtracer(int w, int h, bool explicit_direct, int subsamples)
6
: tracer(w, h)
6
: width_(w), height_(h), scene_(0)
7
{
7
{
8
    explicit_direct_ = explicit_direct;
8
    explicit_direct_ = explicit_direct;
9
    subsamples_ = subsamples;
9
    subsamples_ = subsamples;
10
}
10
}
11
 
11
 
-
 
12
void pathtracer::set_scene(scene* s)
-
 
13
{
-
 
14
    scene_ = s;
-
 
15
}
-
 
16
 
12
CGLA::Vec3f path_tracer::trace(const ray& r, bool include_emitted)
17
CGLA::Vec3f pathtracer::trace(const ray& r, bool include_emitted)
13
{
18
{
14
    //intersect ray with
19
    //intersect ray with
15
    hit_info hi;
20
    hit_info hi;
16
    bool hit = scene_->intersect(r, hi);
21
    bool hit = scene_->intersect(r, hi);
17
 
22
 
Line 135... Line 140...
135
 
140
 
136
    //returm sum of emitted + direct + indirect
141
    //returm sum of emitted + direct + indirect
137
    return Le + Ld + Li;
142
    return Le + Ld + Li;
138
}
143
}
139
 
144
 
140
Vec3f path_tracer::compute_pixel(int w, int h)
145
Vec3f pathtracer::compute_pixel(int w, int h)
141
{
146
{
142
    assert(scene_);
147
    assert(scene_);
143
 
148
 
144
    //supersample
149
    //supersample
145
    Vec3f L(0.f);
150
    Vec3f L(0.f);
Line 182... Line 187...
182
#include "matte.h"
187
#include "matte.h"
183
#include "plastic.h"
188
#include "plastic.h"
184
#include "metal.h"
189
#include "metal.h"
185
#include "glass.h"
190
#include "glass.h"
186
 
191
 
187
#include "path_tracer.h"
192
#include "pathtracer.h"
188
 
193
 
189
using namespace CGLA;
194
using namespace CGLA;
190
 
195
 
191
//global pointer to the active scene
196
//global pointer to the active scene
192
scene* current;
197
scene* current;
193
 
198
 
194
static path_tracer* renderer;
199
static pathtracer* renderer;
195
 
200
 
196
const int width = 64*8;
201
const int width = 64*8;
197
const int height = 64*8;
202
const int height = 64*8;
198
 
203
 
199
static Vec3f* film;
204
static Vec3f* film;
Line 433... Line 438...
433
 
438
 
434
    //build acceleration structure
439
    //build acceleration structure
435
    current->initialize(8, 25);
440
    current->initialize(8, 25);
436
 
441
 
437
    //create the renderer
442
    //create the renderer
438
    renderer = new path_tracer(width, height, true, 1);
443
    renderer = new pathtracer(width, height, true, 1);
439
    renderer->set_scene(current);
444
    renderer->set_scene(current);
440
 
445
 
441
    //create the film
446
    //create the film
442
    film = new Vec3f[width * height];
447
    film = new Vec3f[width * height];
443
    std::fill(film, film+width*height, Vec3f(0.3f));
448
    std::fill(film, film+width*height, Vec3f(0.3f));