include/sampler.h
author Radek Brich <radek.brich@devl.cz>
Sat, 10 May 2008 14:29:37 +0200
branchpyrit
changeset 95 ca7d4c665531
parent 94 4c8abb8977dc
permissions -rw-r--r--
build script fixes, add ldflags build option update and enhance demos fix bug in 4x grid oversampling warn if writePNG called while compiled without libpng make shapes in ShapeList const and add many other const needed due to snowball effect slightly optimize Camera::makeRayPacket using _mm_shuffle_ps make Vector SIMD vectorization disabled by default (causes problems) fix bug in implicit reflection of transmissive surfaces, when surface's reflection parameter is set to zero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
     1
/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
     2
 * @file  sampler.h
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
     3
 * @brief Screen sample generation and image reconstruction
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
 *
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
 * This file is part of Pyrit Ray Tracer.
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
 *
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
 * Copyright 2008  Radek Brich
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
 *
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
 * of this software and associated documentation files (the "Software"), to deal
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
 * in the Software without restriction, including without limitation the rights
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
 * copies of the Software, and to permit persons to whom the Software is
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
 * furnished to do so, subject to the following conditions:
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
 *
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
 * The above copyright notice and this permission notice shall be included in
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
 * all copies or substantial portions of the Software.
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
 *
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
 * THE SOFTWARE.
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
 */
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
#ifndef SAMPLER_H
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
#define SAMPLER_H
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31
#include "common.h"
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
#include "vector.h"
88
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
    33
#include "pixmap.h"
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    35
using namespace std;
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    36
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    37
/**
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    38
 * A structure containing sample's coordinates.
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    39
 */
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    40
class Sample
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    41
{
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    42
public:
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    43
	//@{
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    44
	/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    45
	 * Generated coordinates.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    46
	 *
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    47
	 * These are coordinates for use by Camera.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    48
	 * Middle of the screen plane has [0,0],
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    49
	 * top of the screen has y=-0.5, left pixels has x<0
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    50
	 * and the rest of samples are aligned to regular grid,
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    51
	 * so the vertical size is always one and horizontal size
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    52
	 * can be wider depending on aspect ratio.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    53
	 */
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    54
	Float x,y;
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    55
	//@}
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    56
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    57
	//@{
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    58
	/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    59
	 * Auxiliary coordinates used internally by sampler.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    60
	 *
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    61
	 * Screen coordinates sx, sy are integer coordinates of screen pixels,
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    62
	 * osa_samp is used by oversampling to remember current sample.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    63
	 */
53
228cb8bfdd54 slighly optimized raytrace_worker
Radek Brich <radek.brich@devl.cz>
parents: 50
diff changeset
    64
	int sx,sy,osa_samp;
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    65
	//@}
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    66
};
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    67
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    68
/**
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    69
 * A abstract sampler.
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    70
 *
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    71
 * It generates screen samples in coordinates between [-0.5..0.5] for height
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    72
 * and [-w/h/2..w/h/2] for width. It works in phases: initSampleSet returns
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    73
 * number of samples for each phase, then samples can be generated using
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    74
 * nextSample method. The resulting colour of each sample should be returned
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    75
 * via saveSample method. The sampler should save the results to given buffer
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    76
 * and decide if another phase is needed. When the picture is complete,
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    77
 * initSampleSet returns zero and picture can be read from buffer.
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    78
 */
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    79
class Sampler
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    80
{
82
930a2d3ecaed prepare structures for packet tracing
Radek Brich <radek.brich@devl.cz>
parents: 78
diff changeset
    81
protected:
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    82
	Pixmap pixmap;    ///< A pixmap for resulting image.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    83
	bool packetable;  ///< True if the generated samples are usable with ray packets.
82
930a2d3ecaed prepare structures for packet tracing
Radek Brich <radek.brich@devl.cz>
parents: 78
diff changeset
    84
public:
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    85
	/** Constructor with user provided image buffer. */
88
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
    86
	Sampler(Float *buffer, const int &w, const int &h):
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
    87
		pixmap(buffer, w, h), packetable(false) {};
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    88
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    89
	/** With this constructor, image buffer is allocated as specified by w,h. */
88
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
    90
	Sampler(const int &w, const int &h):
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
    91
		pixmap(w, h), packetable(false) {};
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    92
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    93
	virtual ~Sampler() {};
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    95
	/** Switch to new user provided buffer. */
88
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
    96
	void resetBuffer(Float *buffer, int &w, int &h)
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
    97
		{ pixmap.setData(buffer, w, h); };
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    98
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
    99
	/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   100
	 * Initialize the sampler.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   101
	 *
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   102
	 * This must be called first when starting new image.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   103
	 */
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   104
	virtual void init() = 0;
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   105
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   106
	/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   107
	 * Prepare for next phase.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   108
	 *
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   109
	 * Must be called before reading samples.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   110
	 * @retval N approximate number of samples to be generated in the phase
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   111
	 * @retval 0 last phase, image is complete
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   112
	 */
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   113
	virtual int initSampleSet() = 0;
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   114
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   115
	/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   116
	 * Generate next sample.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   117
	 *
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   118
	 * @param[out] s  The sample.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   119
	 * @retval false  No more samples in this phase.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   120
	 */
53
228cb8bfdd54 slighly optimized raytrace_worker
Radek Brich <radek.brich@devl.cz>
parents: 50
diff changeset
   121
	virtual bool nextSample(Sample *s) = 0;
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   122
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   123
	/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   124
	 * Save the color of the sample.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   125
	 *
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   126
	 * @param[in] samp  A sample.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   127
	 * @param[in] col   Color resulted from ray tracing the sample.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   128
	 */
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   129
	virtual void saveSample(const Sample &samp, const Colour &col) = 0;
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   130
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   131
	/** True if generated samples are usable with ray packets. */
82
930a2d3ecaed prepare structures for packet tracing
Radek Brich <radek.brich@devl.cz>
parents: 78
diff changeset
   132
	bool packetableSamples() { return packetable; };
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   133
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   134
	/** Get the pixmap. */
90
f6a72eb99631 rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents: 88
diff changeset
   135
	const Pixmap &getPixmap() const { return pixmap; };
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   136
};
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   137
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   138
/**
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   139
 * Default sampler.
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   140
 *
48
a4913301c626 begin moving subsampling and oversampling to Sampler
Radek Brich <radek.brich@devl.cz>
parents: 47
diff changeset
   141
 * Implements basic adaptive subsampling and oversampling.
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   142
 */
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   143
class DefaultSampler: public Sampler
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   144
{
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   145
	int phase;      ///< Current phase
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   146
	int subsample;  ///< Subsampling mode
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   147
	int oversample; ///< Oversampling mode
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   148
	//@{
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   149
	/** Properties of last generated sample. */
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   150
	int sx,sy,osa_samp;
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   151
	//@}
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   152
public:
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   153
	/** Constructor with user provided image buffer. */
88
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
   154
	DefaultSampler(Float *buffer, const int &w, const int &h):
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
   155
		Sampler(buffer, w, h), phase(-1), subsample(0), oversample(0) {};
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   156
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   157
	/** With this constructor, image buffer is allocated as specified by w,h. */
88
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
   158
	DefaultSampler(const int &w, const int &h):
f7edb3b90816 merge pixmap handling from sampler, material.h and ccdemos's image module to new Pixmap class
Radek Brich <radek.brich@devl.cz>
parents: 87
diff changeset
   159
		Sampler(w, h), phase(-1), subsample(0), oversample(0) {};
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   160
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   161
	/* Implement virtuals from Sampler. */
48
a4913301c626 begin moving subsampling and oversampling to Sampler
Radek Brich <radek.brich@devl.cz>
parents: 47
diff changeset
   162
	void init();
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   163
	int initSampleSet();
53
228cb8bfdd54 slighly optimized raytrace_worker
Radek Brich <radek.brich@devl.cz>
parents: 50
diff changeset
   164
	bool nextSample(Sample *s);
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   165
	void saveSample(const Sample &samp, const Colour &col);
48
a4913301c626 begin moving subsampling and oversampling to Sampler
Radek Brich <radek.brich@devl.cz>
parents: 47
diff changeset
   166
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   167
	/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   168
	  * Set subsampling mode.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   169
	  *
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   170
	  * @param[in] sub  0,1 = no, 1+ = size of sampling grid
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   171
	  */
48
a4913301c626 begin moving subsampling and oversampling to Sampler
Radek Brich <radek.brich@devl.cz>
parents: 47
diff changeset
   172
	void setSubsample(int sub) { subsample = sub; };
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   173
	/** Get subsampling mode. @see setSubsample */
48
a4913301c626 begin moving subsampling and oversampling to Sampler
Radek Brich <radek.brich@devl.cz>
parents: 47
diff changeset
   174
	int getSubsample() { return subsample; };
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   175
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   176
	/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   177
	  * Set oversampling mode.
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   178
	  *
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   179
	  * @param[in] osa  0 = no, 1 = 4x, 2 = 9x, 3 = 16x
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   180
	  */
48
a4913301c626 begin moving subsampling and oversampling to Sampler
Radek Brich <radek.brich@devl.cz>
parents: 47
diff changeset
   181
	void setOversample(int osa) { oversample = osa; };
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
   182
	/** Get oversampling mode. @see setOversample */
48
a4913301c626 begin moving subsampling and oversampling to Sampler
Radek Brich <radek.brich@devl.cz>
parents: 47
diff changeset
   183
	int getOversample() { return oversample; };
47
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   184
};
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   185
320d5d466864 move Sampler classes to sampler.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   186
#endif