Skip to content

Commit

Permalink
multi sample per pixel
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Finer committed Jan 2, 2011
1 parent c339c2f commit 1eb5005
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
1 change: 0 additions & 1 deletion rtfgu.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
<Unit filename="src/GlossySpecular.cpp" />
<Unit filename="src/Grid.cpp" />
<Unit filename="src/Hammersley.cpp" />
<Unit filename="src/IBuilder.cpp" />
<Unit filename="src/Instance.cpp" />
<Unit filename="src/Jittered.cpp" />
<Unit filename="src/Lambertian.cpp" />
Expand Down
38 changes: 26 additions & 12 deletions src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@

#include "IRenderer.h"

#include <stdexcept>
#include <stdexcept>

namespace {

const float ZW = 100.0f;

}


// -------------------------------------------------------------------- default constructor

Expand Down Expand Up @@ -93,19 +100,26 @@ void World::render_scene() const {

RGBColor pixel_color;
Ray ray;
int hres = vp.hres;
int vres = vp.vres;
float s = vp.s;
float zw = 100.0; // hardwired in

ray.d = Vector3D(0, 0, -1);
ray.d = Vector3D(0, 0, -1);
const int N = static_cast<int>(sqrt(static_cast<float>(vp.num_samples)));

for (int r = 0; r < vres; r++) // up
for (int c = 0; c <= hres; c++) { // across
ray.o = Point3D(s * (c - hres / 2.0 + 0.5), s * (r - vres / 2.0 + 0.5), zw);
pixel_color = tracer->trace_ray(ray);
for (int r = 0; r < vp.vres; r++) {
for (int c = 0; c <= vp.hres; c++) {
pixel_color = background_color;

// Samples
for ( int p = 0; p < N; p++ ) {
for ( int q = 0; q < N; q++ ) {
float nx = vp.s * (c - 0.5f * vp.hres + (q + 0.5f) / N);
float ny = vp.s * (r - 0.5f * vp.vres + (p + 0.5f) / N);
ray.o = Point3D(nx, ny, ZW);
pixel_color += tracer->trace_ray(ray);
}
}
pixel_color /= vp.num_samples;
display_pixel(r, c, pixel_color);
}
}
}
}


Expand Down

0 comments on commit 1eb5005

Please sign in to comment.