source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.h @ 2861

Revision 2861, 1.9 KB checked in by mattausch, 16 years ago (diff)

cleaned up code

Line 
1#ifndef _SsaoShader_H__
2#define _SsaoShader_H__
3
4#include "common.h"
5#include "glInterface.h"
6#include <Cg/cg.h>
7#include <Cg/cgGL.h>
8
9
10namespace CHCDemoEngine
11{
12
13class FrameBufferObject;
14class Vector3;
15class Camera;
16class Matrix4x4;
17
18/** This class implements a deferred shading algorithm that takes
19        a frame buffer object as input and outputs an image in the given size
20*/
21class SsaoShader
22{
23public:
24        /** constructor for a deferred shader taking the requested output image size,
25                the current camera,     and a scaling factor.
26                       
27                The parameter scaleFactor must be reciprocal value of the
28                scale factor used for creating the positions texture. It is used recover the
29                exact scene size that was scaled in order to improve floating point precision.
30        */
31        SsaoShader(int w, int h, Camera *cam, float scaleFactor);
32        /**
33       
34                The algorithm renders the scene given an fbo consists of 1 color buffer,
35                1 position buffer, and 1 normal buffer.
36                We also need the  projection view matrix of the last frame for reprojection, and
37                a smoothing factor for temporal coherence
38        */
39        void Render(FrameBufferObject *fbo, const Matrix4x4 &oldProjViewMatrix, float expFactor);
40
41        /** Initialises the deferred shader and loads the required shaders:
42                This function has to be called only once.
43        */
44        static void Init(CGcontext context);
45
46        ~SsaoShader();
47
48protected:
49
50        void FirstPass(FrameBufferObject *fbo, float expFactor);
51
52        void SecondPass(FrameBufferObject *fbo);
53
54        void CreateNoiseTex2D();
55        void ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br);
56
57
58        ////////////
59
60        int mWidth;
61        int mHeight;
62
63        /// this is just a scale factor for the scene depth in order to get better float precision in the shader
64        float mScaleFactor;
65
66        Camera *mCamera;
67
68        FrameBufferObject *mOldFbo;
69        FrameBufferObject *mNewFbo;
70};
71
72} // namespace
73#endif // _SsaoShader_H__
Note: See TracBrowser for help on using the repository browser.