1 ////////////////////////////////////////////////////////////////////// 2 // 3 // Pixie 4 // 5 // Copyright � 1999 - 2003, Okan Arikan 6 // 7 // Contact: okan@cs.utexas.edu 8 // 9 // This library is free software; you can redistribute it and/or 10 // modify it under the terms of the GNU Lesser General Public 11 // License as published by the Free Software Foundation; either 12 // version 2.1 of the License, or (at your option) any later version. 13 // 14 // This library is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 // Lesser General Public License for more details. 18 // 19 // You should have received a copy of the GNU Lesser General Public 20 // License along with this library; if not, write to the Free Software 21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 // 23 /////////////////////////////////////////////////////////////////////// 24 /////////////////////////////////////////////////////////////////////// 25 // 26 // File : stochastic.h 27 // Classes : CStochastic 28 // Description : 29 // 30 //////////////////////////////////////////////////////////////////////// 31 #ifndef STOCHASTIC_H 32 #define STOCHASTIC_H 33 34 #include "common/global.h" 35 #include "reyes.h" 36 #include "occlusion.h" 37 #include "random.h" 38 39 /////////////////////////////////////////////////////////////////////// 40 // Class : CStochastic 41 // Description : This is the stochastic hider (a scanline renderer) 42 // Comments : 43 class CStochastic : public CReyes, public COcclusionCuller { 44 public: 45 CStochastic(int thread); 46 ~CStochastic(); 47 preDisplaySetup()48 static void preDisplaySetup() { } 49 50 // The functions inherited from the CReyes 51 void rasterBegin(int,int,int,int,int); 52 void rasterDrawPrimitives(CRasterGrid *); 53 void rasterEnd(float *,int); 54 55 protected: probeArea(int * xbound,int * ybound,int bw,int bh,int bl,int bt,float zmin)56 int probeArea(int *xbound,int *ybound, int bw, int bh, int bl, int bt, float zmin) { 57 return probeRect(xbound,ybound,bw,bh,bl,bt,zmin); 58 } 59 60 private: 61 62 /////////////////////////////////////////////////////////////////////// 63 // Class : CFragment 64 // Description : This class holds a sample 65 // Comments : 66 class CFragment { 67 public: 68 vector color; // Color of the sample 69 vector opacity; // Opacity of the sample 70 vector accumulatedOpacity; // The accumulated opacity at this sample 71 float z; // Depth of the sample 72 CFragment *next; // The next fragment wrt. depth 73 CFragment *prev; // The previous fragment wrt. depth 74 float *extraSamples; // Extra sample space 75 }; 76 77 /////////////////////////////////////////////////////////////////////// 78 // Class : CPixel 79 // Description : This class holds a pixel 80 // Comments : 81 class CPixel { 82 public: 83 float jx,jy; // The sampling jitter 84 float jt; // The time jitter 85 float jdx,jdy; // The aperture jitter (Gaussian) 86 float jimp; // The relative important // GSHHACK 87 float z; // The farthest opaque z value 88 float zold; // This is the old Z value (for depth filtering) 89 int numSplats; // The number of splats to this pixel (used by the avg. depth filter); 90 float xcent,ycent; // The center of the sampling window 91 CFragment first,last; // The first and last fragments always exist 92 CFragment *update; // The last fragment to be saved 93 COcclusionNode *node; // The occlusion sample 94 }; 95 96 void filterSamples(int,CFragment **,float *); 97 void deepShadowCompute(); 98 99 int totalWidth,totalHeight; 100 CPixel **fb; 101 102 CFragment *freeFragments; 103 int numFragments; 104 float *extraSampleMemory; 105 106 int width,height; 107 int top,left,right,bottom; 108 int sampleWidth,sampleHeight; 109 110 CSobol<2> apertureGenerator; 111 112 // Define prototypes for the rasterization functions 113 114 #define DEFINE_STOCHASTIC_FUNPROTOS 115 #include "stochasticPrimitives.h" 116 #undef DEFINE_STOCHASTIC_FUNPROTOS 117 }; 118 119 #endif 120 121