[463] | 1 | #ifndef _SamplingPreprocessor_H__
|
---|
| 2 | #define _SamplingPreprocessor_H__
|
---|
| 3 |
|
---|
| 4 | #include <fstream>
|
---|
| 5 | using namespace std;
|
---|
| 6 |
|
---|
| 7 | #include "Preprocessor.h"
|
---|
| 8 | #include "VssRay.h"
|
---|
| 9 |
|
---|
| 10 | class Exporter;
|
---|
| 11 |
|
---|
| 12 | /** Sampling based visibility preprocessing. The implementation is based on heuristical
|
---|
| 13 | sampling of view space */
|
---|
| 14 | class SamplingPreprocessor : public Preprocessor {
|
---|
| 15 | public:
|
---|
| 16 |
|
---|
| 17 | SamplingPreprocessor();
|
---|
| 18 | ~SamplingPreprocessor();
|
---|
| 19 |
|
---|
| 20 | virtual bool ComputeVisibility();
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | protected:
|
---|
| 24 | /** Sets up ray for sampling.
|
---|
| 25 | */
|
---|
| 26 | void
|
---|
| 27 | SetupRay(Ray &ray,
|
---|
| 28 | const Vector3 &point,
|
---|
| 29 | const Vector3 &direction,
|
---|
[466] | 30 | const int type,
|
---|
| 31 | const Ray::Intersection &source);
|
---|
| 32 |
|
---|
| 33 | /** Refined sampling for finding "holes", i.e., difficult visibility.
|
---|
| 34 | */
|
---|
[463] | 35 | void
|
---|
| 36 | HoleSamplingPass();
|
---|
[466] | 37 |
|
---|
| 38 | /** Casts a bundle of sample rays into the scene.
|
---|
[463] | 39 | @param sampleContributions the number of sample contributions
|
---|
| 40 | @param contributingSamples the number of samples contributing
|
---|
| 41 | */
|
---|
| 42 | void
|
---|
[466] | 43 | CastRays(const RayContainer &rays);
|
---|
[463] | 44 |
|
---|
| 45 | /** Casts a single ray into the scene.
|
---|
| 46 | @returns sample contributions
|
---|
| 47 | */
|
---|
| 48 | int CastRay(Ray &ray);
|
---|
| 49 |
|
---|
| 50 | /** Verify if the exact visibility for this object was established.
|
---|
| 51 | */
|
---|
| 52 | void
|
---|
| 53 | VerifyVisibility(Intersectable *object);
|
---|
| 54 |
|
---|
| 55 | /** Sample the shiluette of objects in order to find visibility changes
|
---|
| 56 | along the visibility skeleton.
|
---|
| 57 | */
|
---|
| 58 | int
|
---|
| 59 | CastEdgeSamples(
|
---|
| 60 | Intersectable *object,
|
---|
| 61 | const Vector3 &point,
|
---|
| 62 | MeshInstance *mi,
|
---|
| 63 | const int samples
|
---|
| 64 | );
|
---|
| 65 |
|
---|
| 66 | /** Processes the view cells during a pass.
|
---|
| 67 | @param newRays the newly cast rays
|
---|
| 68 | @param sampleContributions returns the accumulated contribution of the samples
|
---|
| 69 | @param contributingSamples returns the samples contributing to pvs
|
---|
| 70 | */
|
---|
| 71 |
|
---|
| 72 | void ProcessViewCells(const RayContainer &newRays,
|
---|
| 73 | const ObjectContainer &objects,
|
---|
| 74 | int &sampleContributions,
|
---|
| 75 | int &contributingSamples);
|
---|
| 76 |
|
---|
| 77 | /**
|
---|
| 78 | Returns random node as target for the current sample ray.
|
---|
| 79 | */
|
---|
| 80 | KdNode *GetNodeToSample(Intersectable *object);
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | protected:
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | int mPass;
|
---|
| 87 | int mSamplesPerPass;
|
---|
| 88 | int mTotalSamples;
|
---|
| 89 |
|
---|
| 90 | ofstream mStats;
|
---|
| 91 | ObjectContainer mObjects;
|
---|
| 92 |
|
---|
| 93 | RayContainer mSampleRays;
|
---|
| 94 | VssRayContainer mVssSampleRays;
|
---|
| 95 | };
|
---|
| 96 |
|
---|
| 97 | #endif
|
---|