- Timestamp:
- 09/02/08 15:48:44 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r2895 r2896 531 531 </File> 532 532 <File 533 RelativePath=".\src\DeferredRenderer. cpp"533 RelativePath=".\src\DeferredRenderer.h" 534 534 > 535 535 </File> … … 638 638 <File 639 639 RelativePath=".\src\chcdemo.cpp" 640 > 641 </File> 642 <File 643 RelativePath=".\src\DeferredRenderer.cpp" 640 644 > 641 645 </File> -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r2895 r2896 1 #include " SsaoShader.h"1 #include "DeferredRenderer.h" 2 2 #include "FrameBufferObject.h" 3 3 #include "RenderState.h" … … 123 123 switch (sampling) 124 124 { 125 case SsaoShader::POISSON:125 case DeferredRenderer::POISSON: 126 126 { 127 127 static PoissonDiscSampleGenerator poisson(NUM_SAMPLES, 1.0f); … … 129 129 } 130 130 break; 131 case SsaoShader::GAUSS:131 case DeferredRenderer::GAUSS: 132 132 { 133 133 const float radius = 1.0f; … … 202 202 203 203 204 SsaoShader::SsaoShader(int w, int h, Camera *cam, float scaleFactor):204 DeferredRenderer::DeferredRenderer(int w, int h, Camera *cam, float scaleFactor): 205 205 mWidth(w), mHeight(h), 206 206 mCamera(cam), … … 240 240 241 241 242 SsaoShader::~SsaoShader()242 DeferredRenderer::~DeferredRenderer() 243 243 { 244 244 if (sCgSsaoProgram) cgDestroyProgram(sCgSsaoProgram); … … 256 256 257 257 258 void SsaoShader::SetUseTemporalCoherence(bool temporal)258 void DeferredRenderer::SetUseTemporalCoherence(bool temporal) 259 259 { 260 260 mUseTemporalCoherence = temporal; … … 262 262 263 263 264 void SsaoShader::Init(CGcontext context)264 void DeferredRenderer::Init(CGcontext context) 265 265 { 266 266 sCgDeferredProgram = … … 436 436 437 437 438 void SsaoShader::Render(FrameBufferObject *fbo,438 void DeferredRenderer::Render(FrameBufferObject *fbo, 439 439 const Matrix4x4 &oldProjViewMatrix, 440 440 float expFactor, … … 507 507 508 508 509 void SsaoShader::ComputeSsao(FrameBufferObject *fbo,509 void DeferredRenderer::ComputeSsao(FrameBufferObject *fbo, 510 510 float expFactor, 511 511 const Matrix4x4 &oldProjViewMatrix … … 601 601 602 602 603 void SsaoShader::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br)603 void DeferredRenderer::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br) 604 604 { 605 605 Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; … … 630 630 631 631 632 void SsaoShader::AntiAliasing(FrameBufferObject *fbo)632 void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo) 633 633 { 634 634 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); … … 670 670 671 671 672 void SsaoShader::FirstPass(FrameBufferObject *fbo)672 void DeferredRenderer::FirstPass(FrameBufferObject *fbo) 673 673 { 674 674 GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); … … 721 721 722 722 723 void SsaoShader::ComputeGlobIllum(FrameBufferObject *fbo,723 void DeferredRenderer::ComputeGlobIllum(FrameBufferObject *fbo, 724 724 float expFactor, 725 725 const Matrix4x4 &oldProjViewMatrix … … 827 827 828 828 829 void SsaoShader::CombineIllum(FrameBufferObject *fbo)829 void DeferredRenderer::CombineIllum(FrameBufferObject *fbo) 830 830 { 831 831 GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); … … 884 884 885 885 886 void SsaoShader::CombineSsao(FrameBufferObject *fbo)886 void DeferredRenderer::CombineSsao(FrameBufferObject *fbo) 887 887 { 888 888 GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); … … 933 933 934 934 935 void SsaoShader::FirstPassShadow(FrameBufferObject *fbo, ShadowMap *shadowMap)935 void DeferredRenderer::FirstPassShadow(FrameBufferObject *fbo, ShadowMap *shadowMap) 936 936 { 937 937 GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); … … 995 995 996 996 997 void SsaoShader::SetSamplingMethod(SAMPLING_METHOD s)997 void DeferredRenderer::SetSamplingMethod(SAMPLING_METHOD s) 998 998 { 999 999 if (s != mSamplingMethod) -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
r2891 r2896 1 #ifndef _ SsaoShader_H__2 #define _ SsaoShader_H__1 #ifndef _DeferredRenderer_H__ 2 #define _DeferredRenderer_H__ 3 3 4 4 #include "common.h" 5 5 #include "glInterface.h" 6 6 7 #include <Cg/cg.h> 7 8 #include <Cg/cgGL.h> … … 15 16 class Camera; 16 17 class Matrix4x4; 18 class ShadowMap; 19 17 20 18 21 /** This class implements a deferred shading algorithm that takes 19 22 a frame buffer object as input and outputs an image in the given size 20 23 */ 21 class SsaoShader24 class DeferredRenderer 22 25 { 23 26 public: … … 29 32 exact scene size that was scaled in order to improve floating point precision. 30 33 */ 31 SsaoShader(int w, int h, Camera *cam, float scaleFactor);34 DeferredRenderer(int w, int h, Camera *cam, float scaleFactor); 32 35 /** The algorithm renders the scene given an fbo consists of 1 color buffer, 33 36 1 position buffer, and 1 normal buffer. … … 35 38 a smoothing factor for temporal coherence 36 39 */ 37 void Render(FrameBufferObject *fbo, const Matrix4x4 &oldProjViewMatrix, float expFactor );40 void Render(FrameBufferObject *fbo, const Matrix4x4 &oldProjViewMatrix, float expFactor, ShadowMap *shadowMap = NULL); 38 41 39 42 /** Initialises the deferred shader and loads the required shaders: … … 42 45 static void Init(CGcontext context); 43 46 44 ~ SsaoShader();47 ~DeferredRenderer(); 45 48 46 void SetUseGlobIllum(bool useGlobIllum);47 49 void SetUseTemporalCoherence(bool temporal); 48 50 49 51 enum SAMPLING_METHOD {POISSON, GAUSS}; 52 enum SHADING_METHOD {DEFAULT, SSAO, GI}; 50 53 51 void SetSamplingMethod( int s) { mSampling = s;}54 void SetSamplingMethod(SAMPLING_METHOD s); 52 55 56 void SetShadingMethod(SHADING_METHOD s) { mShadingMethod = s; } 53 57 54 58 protected: … … 59 63 60 64 void FirstPass(FrameBufferObject *fbo); 65 66 void FirstPassShadow(FrameBufferObject *fbo, ShadowMap *shadowMap); 61 67 62 68 void CombineSsao(FrameBufferObject *fbo); … … 84 90 FrameBufferObject *mFbo; 85 91 86 bool mUseGlobIllum;87 92 bool mUseTemporalCoherence; 88 93 89 int mSampling ;94 int mSamplingMethod; 90 95 int mFboIndex; 96 97 int mShadingMethod; 98 99 bool mRegenerateSamples; 91 100 }; 92 101 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2895 r2896 33 33 #include "SampleGenerator.h" 34 34 #include "FrameBufferObject.h" 35 #include " SsaoShader.h"35 #include "DeferredRenderer.h" 36 36 #include "ShadowMapping.h" 37 37 #include "Light.h" … … 168 168 bool useLODs = true; 169 169 170 SsaoShader::SAMPLING_METHOD samplingMethod = SsaoShader::POISSON;171 SsaoShader::SHADING_METHOD shadingMethod = SsaoShader::DEFAULT;170 DeferredRenderer::SAMPLING_METHOD samplingMethod = DeferredRenderer::POISSON; 171 DeferredRenderer::SHADING_METHOD shadingMethod = DeferredRenderer::DEFAULT; 172 172 173 173 bool showShadowMap = false; … … 225 225 void InitFBO(); 226 226 227 SsaoShader *ssaoShader = NULL;227 DeferredRenderer *ssaoShader = NULL; 228 228 229 229 static GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT}; … … 431 431 InitCg(); 432 432 433 SsaoShader::Init(sCgContext);433 DeferredRenderer::Init(sCgContext); 434 434 435 435 … … 1014 1014 cgGLDisableProfile(RenderState::sCgFragmentProfile); 1015 1015 1016 if (!ssaoShader) ssaoShader = new SsaoShader(texWidth, texHeight, camera, myfar / 10.0f);1016 if (!ssaoShader) ssaoShader = new DeferredRenderer(texWidth, texHeight, camera, myfar / 10.0f); 1017 1017 1018 1018 ssaoShader->SetShadingMethod(shadingMethod); … … 1134 1134 case 'P': 1135 1135 case 'p': 1136 if (samplingMethod == SsaoShader::GAUSS)1137 samplingMethod = SsaoShader::POISSON;1136 if (samplingMethod == DeferredRenderer::GAUSS) 1137 samplingMethod = DeferredRenderer::POISSON; 1138 1138 else 1139 samplingMethod = SsaoShader::GAUSS;1139 samplingMethod = DeferredRenderer::GAUSS; 1140 1140 1141 1141 break; … … 1280 1280 break; 1281 1281 case GLUT_KEY_F8: 1282 shadingMethod = ( SsaoShader::SHADING_METHOD)((shadingMethod + 1) % 3);1282 shadingMethod = (DeferredRenderer::SHADING_METHOD)((shadingMethod + 1) % 3); 1283 1283 1284 1284 break;
Note: See TracChangeset
for help on using the changeset viewer.