# HG changeset patch # User Radek Brich # Date 1206547418 -3600 # Node ID a4913301c6262531ccf566b115c81d6128dd92fa # Parent 320d5d4668646f86b26d4cca4b63a8f0ce065c24 begin moving subsampling and oversampling to Sampler diff -r 320d5d466864 -r a4913301c626 ccdemos/spheres_shadow.cc --- a/ccdemos/spheres_shadow.cc Wed Mar 26 14:29:21 2008 +0100 +++ b/ccdemos/spheres_shadow.cc Wed Mar 26 17:03:38 2008 +0100 @@ -56,8 +56,6 @@ int main(int argc, char **argv) { Raytracer rt; - rt.setOversample(0); - rt.setSubsample(8); Octree top; rt.setTop(&top); @@ -111,8 +109,8 @@ { pyrit_verbosity = 2; Float *fdata = (Float *) malloc(w*h*3*sizeof(Float)); - rt.setOversample(2); DefaultSampler sampler(fdata, w, h); + sampler.setOversample(2); rt.setSampler(&sampler); rt.render(); diff -r 320d5d466864 -r a4913301c626 ccdemos/textures.cc --- a/ccdemos/textures.cc Wed Mar 26 14:29:21 2008 +0100 +++ b/ccdemos/textures.cc Wed Mar 26 17:03:38 2008 +0100 @@ -187,8 +187,6 @@ int main(int argc, char **argv) { Raytracer rt; - rt.setOversample(0); - rt.setSubsample(8); Octree top; rt.setTop(&top); @@ -276,10 +274,10 @@ { pyrit_verbosity = 2; Float *fdata = (Float *) malloc(w*h*3*sizeof(Float)); - rt.setOversample(2); - rt.setSubsample(1); rt.ambientocclusion(300, 5.0, 0.5); DefaultSampler sampler(fdata, w, h); + sampler.setOversample(2); + sampler.setSubsample(1); rt.setSampler(&sampler); rt.render(); diff -r 320d5d466864 -r a4913301c626 include/common.h --- a/include/common.h Wed Mar 26 14:29:21 2008 +0100 +++ b/include/common.h Wed Mar 26 17:03:38 2008 +0100 @@ -3,7 +3,7 @@ * * This file is part of Pyrit Ray Tracer. * - * Copyright 2006, 2007 Radek Brich + * Copyright 2006, 2007, 2008 Radek Brich * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff -r 320d5d466864 -r a4913301c626 include/raytracer.h --- a/include/raytracer.h Wed Mar 26 14:29:21 2008 +0100 +++ b/include/raytracer.h Wed Mar 26 17:03:38 2008 +0100 @@ -57,14 +57,12 @@ int ao_samples; Float ao_distance, ao_angle; int num_threads; - int subsample; - int oversample; // 0 = no, 1 = 5x, 2 = 9x, 3 = 16x int max_depth; Vector3 SphereDistribute(int i, int n, Float extent, Vector3 &normal); public: Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0), - ao_samples(0), num_threads(2), subsample(8), oversample(0), max_depth(3) {}; + ao_samples(0), num_threads(2), max_depth(3) {}; void render(); Colour raytrace(Ray &ray, int depth, Shape *origin_shape); void addshape(Shape *shape) { top->addShape(shape); }; @@ -73,10 +71,7 @@ void setCamera(Camera *cam) { camera = cam; }; void setTop(Container *atop) { top = atop; }; Container *getTop() { return top; }; - void setSubsample(int sub) { subsample = sub; }; - int getSubsample() { return subsample; }; - void setOversample(int osa) { oversample = osa; }; - int getOversample() { return oversample; }; + void setMaxDepth(int newdepth) { max_depth = newdepth; }; void ambientocclusion(int samples, Float distance, Float angle); diff -r 320d5d466864 -r a4913301c626 include/sampler.h --- a/include/sampler.h Wed Mar 26 14:29:21 2008 +0100 +++ b/include/sampler.h Wed Mar 26 17:03:38 2008 +0100 @@ -77,16 +77,25 @@ /** * Default sampler. + * Implements basic adaptive subsampling and oversampling. */ class DefaultSampler: public Sampler { int phase; + int subsample; + int oversample; // 0 = no, 1 = 5x, 2 = 9x, 3 = 16x public: - DefaultSampler(Float *abuffer, int &aw, int &ah): Sampler(abuffer, aw, ah), phase(-1) {}; - void init() { phase = 0; }; + DefaultSampler(Float *abuffer, int &aw, int &ah): + Sampler(abuffer, aw, ah), phase(-1), subsample(8), oversample(0) {}; + void init(); int initSampleSet(); Sample *nextSample(Sample *prev); void saveSample(Sample *samp, Colour &col); + + void setSubsample(int sub) { subsample = sub; }; + int getSubsample() { return subsample; }; + void setOversample(int osa) { oversample = osa; }; + int getOversample() { return oversample; }; }; #endif diff -r 320d5d466864 -r a4913301c626 src/raytracer.cc --- a/src/raytracer.cc Wed Mar 26 14:29:21 2008 +0100 +++ b/src/raytracer.cc Wed Mar 26 17:03:38 2008 +0100 @@ -286,6 +286,7 @@ } } +#if 0 static void *renderrow(void *data) { RenderrowData *d = (RenderrowData*) data; @@ -441,6 +442,7 @@ #endif return (void *)d; } +#endif void Raytracer::render() { diff -r 320d5d466864 -r a4913301c626 src/raytracermodule.cc --- a/src/raytracermodule.cc Wed Mar 26 14:29:21 2008 +0100 +++ b/src/raytracermodule.cc Wed Mar 26 17:03:38 2008 +0100 @@ -3,7 +3,7 @@ * * This file is part of Pyrit Ray Tracer. * - * Copyright 2006, 2007 Radek Brich + * Copyright 2006, 2007, 2008 Radek Brich * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff -r 320d5d466864 -r a4913301c626 src/sampler.cc --- a/src/sampler.cc Wed Mar 26 14:29:21 2008 +0100 +++ b/src/sampler.cc Wed Mar 26 17:03:38 2008 +0100 @@ -29,6 +29,11 @@ #include "common.h" #include "scene.h" +void DefaultSampler::init() +{ + phase = 0; +} + int DefaultSampler::initSampleSet() { if ( phase == 0 )