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

Revision 2859, 1.6 KB checked in by mattausch, 16 years ago (diff)
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;
14
15
16/** This class implements a deferred shading algorithm that takes
17        a frame buffer object as input and outputs an image in the given size
18*/
19class SsaoShader
20{
21public:
22        /** constructor for a deferred shader taking the requested output image size,
23                the exponential smoothing factor for temporal reprojection.
24               
25                The last parameter is a just a scale factor
26                for the scene depth in order to get better floating point precision in the shader
27                This must be reciprocal value of the scale factor used in the mrt shader.
28        */
29        SsaoShader(int w, int h, float expFactor, float scaleFactor);
30        /** The algorithm renders the scene given an fbo.
31                The fbo must have color buffer, position buffer, normal buffer.
32        */
33        void Render(FrameBufferObject *fbo, FrameBufferObject *fbo2);
34
35        /** Initialises the deferred shader and loads the required shaders:
36                This function has to be called only once.
37        */
38        static void Init(CGcontext context);
39
40
41protected:
42
43        void FirstPass(FrameBufferObject *fbo, FrameBufferObject *fbo2);
44
45        void SecondPass(FrameBufferObject *fbo, FrameBufferObject *fbo2);
46
47
48        ////////////
49
50        int mWidth;
51        int mHeight;
52
53        /// the temporal smoothing factor
54        float mExpFactor;
55        /// this is just a scale factor for the scene depth in order to get better float precision in the shader
56        float mScaleFactor;
57};
58
59} // namespace
60#endif // _SsaoShader_H__
Note: See TracBrowser for help on using the repository browser.