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