#ifndef _SamplingPreprocessor_H__ #define _SamplingPreprocessor_H__ #include using namespace std; #include "Preprocessor.h" /** Sampling based visibility preprocessing. The implementation is based on heuristical sampling of view space */ class SamplingPreprocessor : public Preprocessor { public: int mPass; int mSamplesPerPass; int mTotalSamples; int mKdPvsDepth; ofstream mStats; ObjectContainer mObjects; RayContainer mSampleRays; int mBspConstructionSamples; int mPostProcessSamples; SamplingPreprocessor(); ~SamplingPreprocessor(); virtual bool ComputeVisibility(); void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction, const int type); KdNode * GetNodeForPvs(KdLeaf *leaf); int AddNodeSamples(const Ray &ray, Intersectable *sObject, Intersectable *tObject ); void HoleSamplingPass(); int CastRay(Intersectable *object, Ray &ray); KdNode * GetNodeToSample(Intersectable *object); void VerifyVisibility(Intersectable *object); int CastEdgeSamples( Intersectable *object, const Vector3 &point, MeshInstance *mi, const int samples ); /** Processes the BSP based view cells during a pass. @param ray the current ray @param object the currently processed object @param faceIndex the sampled face of the object @param contributingSamples samples contributing to pvs @param sampleContributions contribution of the samples @returns true if BSP tree has been constructed, false if not yet */ bool ProcessBspViewCells(Ray &ray, Intersectable *object, int faceIndex, int &contributingSamples, int &sampleContributions); /** Adds objects samples to bsp view cells. */ int AddObjectSamples(Intersectable *obj, const Ray &ray); bool BuildBspTree(); void ExportSplits(const ObjectContainer &objects); void ExportBspPvs(const ObjectContainer &objects); /** Post processes view cells (i.e., merges or subdivides view cells based on the PVS and the ray sets. @returns number of merged view cells. */ int PostprocessViewCells(const RayContainer &rays); /** Simulated rendering using a simple render heuristics. Used to evaluate the quality of the view cell partition. */ Real EvaluateRenderHeuristics(); }; #endif