src/sampler.cc
branchpyrit
changeset 95 ca7d4c665531
parent 94 4c8abb8977dc
equal deleted inserted replaced
94:4c8abb8977dc 95:ca7d4c665531
    27 #include <math.h>
    27 #include <math.h>
    28 
    28 
    29 #include "common.h"
    29 #include "common.h"
    30 #include "scene.h"
    30 #include "scene.h"
    31 
    31 
       
    32 /* grid oversampling look up tables */
       
    33 static const int gridsamples[] = {1,4,9,16};
       
    34 static const Float osa4x[] = { -0.25f, +0.25f, +0.25f, -0.25f };
       
    35 static const Float osa4y[] = { -0.25f, -0.25f, +0.25f, +0.25f };
       
    36 static const Float osa9x[] =
       
    37 {
       
    38 	-0.34f,  0.00f, +0.34f,
       
    39 	-0.34f,  0.00f, +0.34f,
       
    40 	-0.34f,  0.00f, +0.34f
       
    41 };
       
    42 static const Float osa9y[] =
       
    43 {
       
    44 	-0.34f, -0.34f, -0.34f,
       
    45 	 0.00f,  0.00f,  0.00f,
       
    46 	+0.34f, +0.34f, +0.34f
       
    47 };
       
    48 static const Float osa16x[] =
       
    49 {
       
    50 	-0.375f, -0.125f, +0.125f, +0.375f,
       
    51 	-0.375f, -0.125f, +0.125f, +0.375f,
       
    52 	-0.375f, -0.125f, +0.125f, +0.375f,
       
    53 	-0.375f, -0.125f, +0.125f, +0.375f
       
    54 };
       
    55 static const Float osa16y[] =
       
    56 {
       
    57 	-0.375f, -0.375f, -0.375f, -0.375f,
       
    58 	-0.125f, -0.125f, -0.125f, -0.125f,
       
    59 	+0.125f, +0.125f, +0.125f, +0.125f,
       
    60 	+0.375f, +0.375f, +0.375f, +0.375f
       
    61 };
       
    62 static const Float *osaSx[] = {NULL, osa4x, osa9x, osa16x};
       
    63 static const Float *osaSy[] = {NULL, osa4y, osa9y, osa16y};
       
    64 
       
    65 
    32 void DefaultSampler::init()
    66 void DefaultSampler::init()
    33 {
    67 {
    34 	phase = 0;
    68 	phase = 0;
    35 	packetable = (subsample <= 1);
    69 	packetable = (subsample <= 1);
    36 }
    70 }
    37 
    71 
    38 int DefaultSampler::initSampleSet()
    72 int DefaultSampler::initSampleSet()
    39 {
    73 {
    40 	static const int gridsamples[] = {1,5,9,16};
       
    41 	const int samples = gridsamples[oversample];
    74 	const int samples = gridsamples[oversample];
    42 	const int &w = pixmap.getWidth(), &h = pixmap.getHeight();
    75 	const int &w = pixmap.getWidth(), &h = pixmap.getHeight();
    43 	Float *&buffer = pixmap.getFloatData();
    76 	Float *&buffer = pixmap.getFloatData();
    44 
    77 
    45 	if ( phase == 0 )
    78 	if ( phase == 0 )
   182 		}
   215 		}
   183 	}
   216 	}
   184 	else if (phase == 2)
   217 	else if (phase == 2)
   185 	{
   218 	{
   186 		/* grid oversampling */
   219 		/* grid oversampling */
   187 		static const int gridsamples[] = {1,4,9,16};
       
   188 		static const Float osa4x[] = {-0.25f, +0.25f, +0.25f, -0.25f};
       
   189 		static const Float osa4y[] = {-0.25f, -0.25f, +0.25f, +0.25f};
       
   190 		static const Float osa9x[] = {-0.34f,  0.00f, +0.34f,
       
   191 			-0.34f,  0.00f, +0.34f, -0.34f,  0.00f, +0.34f};
       
   192 		static const Float osa9y[] = {-0.34f, -0.34f, -0.34f,
       
   193 				0.00f,  0.00f,  0.00f, +0.34f, +0.34f, +0.34f};
       
   194 		static const Float osa16x[] = {-0.375f, -0.125f, +0.125f, +0.375f,
       
   195 			-0.375f, -0.125f, +0.125f, +0.375f, -0.375f, -0.125f, +0.125f, +0.375f,
       
   196 			-0.375f, -0.125f, +0.125f, +0.375f};
       
   197 		static const Float osa16y[] = {-0.375f, -0.375f, -0.375f, -0.375f,
       
   198 			-0.125f, -0.125f, -0.125f, -0.125f, +0.125f, +0.125f, +0.125f, +0.125f,
       
   199 			+0.375f, +0.375f, +0.375f, +0.375f};
       
   200 		static const Float *osaSx[] = {NULL, osa4x, osa9x, osa16x};
       
   201 		static const Float *osaSy[] = {NULL, osa4y, osa9y, osa16y};
       
   202 		const int samples = gridsamples[oversample];
   220 		const int samples = gridsamples[oversample];
   203 		const Float *osax = osaSx[oversample];
   221 		const Float *osax = osaSx[oversample];
   204 		const Float *osay = osaSy[oversample];
   222 		const Float *osay = osaSy[oversample];
   205 
   223 
   206 		if (sx < 0)
   224 		if (sx < 0)