Changeset 2896


Ignore:
Timestamp:
09/02/08 15:48:44 (16 years ago)
Author:
mattausch
Message:
 
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  
    531531                                </File> 
    532532                                <File 
    533                                         RelativePath=".\src\DeferredRenderer.cpp" 
     533                                        RelativePath=".\src\DeferredRenderer.h" 
    534534                                        > 
    535535                                </File> 
     
    638638                                <File 
    639639                                        RelativePath=".\src\chcdemo.cpp" 
     640                                        > 
     641                                </File> 
     642                                <File 
     643                                        RelativePath=".\src\DeferredRenderer.cpp" 
    640644                                        > 
    641645                                </File> 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r2895 r2896  
    1 #include "SsaoShader.h" 
     1#include "DeferredRenderer.h" 
    22#include "FrameBufferObject.h" 
    33#include "RenderState.h" 
     
    123123        switch (sampling) 
    124124        { 
    125         case SsaoShader::POISSON: 
     125        case DeferredRenderer::POISSON: 
    126126                { 
    127127                        static PoissonDiscSampleGenerator poisson(NUM_SAMPLES, 1.0f); 
     
    129129                } 
    130130                break; 
    131         case SsaoShader::GAUSS: 
     131        case DeferredRenderer::GAUSS: 
    132132                { 
    133133                        const float radius = 1.0f; 
     
    202202 
    203203 
    204 SsaoShader::SsaoShader(int w, int h, Camera *cam, float scaleFactor): 
     204DeferredRenderer::DeferredRenderer(int w, int h, Camera *cam, float scaleFactor): 
    205205mWidth(w), mHeight(h),  
    206206mCamera(cam), 
     
    240240 
    241241 
    242 SsaoShader::~SsaoShader()  
     242DeferredRenderer::~DeferredRenderer()  
    243243{ 
    244244        if (sCgSsaoProgram)     cgDestroyProgram(sCgSsaoProgram); 
     
    256256 
    257257 
    258 void SsaoShader::SetUseTemporalCoherence(bool temporal) 
     258void DeferredRenderer::SetUseTemporalCoherence(bool temporal) 
    259259{ 
    260260        mUseTemporalCoherence = temporal; 
     
    262262 
    263263 
    264 void SsaoShader::Init(CGcontext context) 
     264void DeferredRenderer::Init(CGcontext context) 
    265265{        
    266266        sCgDeferredProgram =  
     
    436436 
    437437 
    438 void SsaoShader::Render(FrameBufferObject *fbo,  
     438void DeferredRenderer::Render(FrameBufferObject *fbo,  
    439439                                                const Matrix4x4 &oldProjViewMatrix, 
    440440                                                float expFactor, 
     
    507507 
    508508 
    509 void SsaoShader::ComputeSsao(FrameBufferObject *fbo,  
     509void DeferredRenderer::ComputeSsao(FrameBufferObject *fbo,  
    510510                                                         float expFactor, 
    511511                                                         const Matrix4x4 &oldProjViewMatrix 
     
    601601 
    602602 
    603 void SsaoShader::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br) 
     603void DeferredRenderer::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br) 
    604604{ 
    605605        Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; 
     
    630630 
    631631 
    632 void SsaoShader::AntiAliasing(FrameBufferObject *fbo) 
     632void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo) 
    633633{ 
    634634        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     
    670670 
    671671 
    672 void SsaoShader::FirstPass(FrameBufferObject *fbo) 
     672void DeferredRenderer::FirstPass(FrameBufferObject *fbo) 
    673673{ 
    674674        GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); 
     
    721721 
    722722 
    723 void SsaoShader::ComputeGlobIllum(FrameBufferObject *fbo,  
     723void DeferredRenderer::ComputeGlobIllum(FrameBufferObject *fbo,  
    724724                                                                  float expFactor, 
    725725                                                                  const Matrix4x4 &oldProjViewMatrix 
     
    827827 
    828828 
    829 void SsaoShader::CombineIllum(FrameBufferObject *fbo) 
     829void DeferredRenderer::CombineIllum(FrameBufferObject *fbo) 
    830830{ 
    831831        GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 
     
    884884 
    885885 
    886 void SsaoShader::CombineSsao(FrameBufferObject *fbo) 
     886void DeferredRenderer::CombineSsao(FrameBufferObject *fbo) 
    887887{ 
    888888        GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 
     
    933933 
    934934 
    935 void SsaoShader::FirstPassShadow(FrameBufferObject *fbo, ShadowMap *shadowMap) 
     935void DeferredRenderer::FirstPassShadow(FrameBufferObject *fbo, ShadowMap *shadowMap) 
    936936{ 
    937937        GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); 
     
    995995 
    996996 
    997 void SsaoShader::SetSamplingMethod(SAMPLING_METHOD s)  
     997void DeferredRenderer::SetSamplingMethod(SAMPLING_METHOD s)  
    998998{  
    999999        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__ 
    33 
    44#include "common.h" 
    55#include "glInterface.h" 
     6 
    67#include <Cg/cg.h> 
    78#include <Cg/cgGL.h> 
     
    1516class Camera; 
    1617class Matrix4x4; 
     18class ShadowMap; 
     19 
    1720 
    1821/** This class implements a deferred shading algorithm that takes 
    1922        a frame buffer object as input and outputs an image in the given size 
    2023*/ 
    21 class SsaoShader 
     24class DeferredRenderer 
    2225{ 
    2326public: 
     
    2932                exact scene size that was scaled in order to improve floating point precision. 
    3033        */ 
    31         SsaoShader(int w, int h, Camera *cam, float scaleFactor); 
     34        DeferredRenderer(int w, int h, Camera *cam, float scaleFactor); 
    3235        /** The algorithm renders the scene given an fbo consists of 1 color buffer,  
    3336                1 position buffer, and 1 normal buffer. 
     
    3538                a smoothing factor for temporal coherence 
    3639        */ 
    37         void Render(FrameBufferObject *fbo, const Matrix4x4 &oldProjViewMatrix, float expFactor); 
     40        void Render(FrameBufferObject *fbo, const Matrix4x4 &oldProjViewMatrix, float expFactor, ShadowMap *shadowMap = NULL); 
    3841 
    3942        /** Initialises the deferred shader and loads the required shaders: 
     
    4245        static void Init(CGcontext context); 
    4346 
    44         ~SsaoShader(); 
     47        ~DeferredRenderer(); 
    4548 
    46         void SetUseGlobIllum(bool useGlobIllum); 
    4749        void SetUseTemporalCoherence(bool temporal); 
    4850 
    4951        enum SAMPLING_METHOD {POISSON, GAUSS}; 
     52        enum SHADING_METHOD {DEFAULT, SSAO, GI}; 
    5053 
    51         void SetSamplingMethod(int s) { mSampling = s;} 
     54        void SetSamplingMethod(SAMPLING_METHOD s); 
    5255 
     56        void SetShadingMethod(SHADING_METHOD s) { mShadingMethod = s; } 
    5357 
    5458protected: 
     
    5963 
    6064        void FirstPass(FrameBufferObject *fbo); 
     65 
     66        void FirstPassShadow(FrameBufferObject *fbo, ShadowMap *shadowMap); 
    6167 
    6268        void CombineSsao(FrameBufferObject *fbo); 
     
    8490        FrameBufferObject *mFbo; 
    8591 
    86         bool mUseGlobIllum; 
    8792        bool mUseTemporalCoherence; 
    8893 
    89         int mSampling; 
     94        int mSamplingMethod; 
    9095        int mFboIndex; 
     96 
     97        int mShadingMethod; 
     98 
     99        bool mRegenerateSamples; 
    91100}; 
    92101 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2895 r2896  
    3333#include "SampleGenerator.h" 
    3434#include "FrameBufferObject.h" 
    35 #include "SsaoShader.h" 
     35#include "DeferredRenderer.h" 
    3636#include "ShadowMapping.h" 
    3737#include "Light.h" 
     
    168168bool useLODs = true; 
    169169 
    170 SsaoShader::SAMPLING_METHOD samplingMethod = SsaoShader::POISSON; 
    171 SsaoShader::SHADING_METHOD shadingMethod = SsaoShader::DEFAULT; 
     170DeferredRenderer::SAMPLING_METHOD samplingMethod = DeferredRenderer::POISSON; 
     171DeferredRenderer::SHADING_METHOD shadingMethod = DeferredRenderer::DEFAULT; 
    172172 
    173173bool showShadowMap = false; 
     
    225225void InitFBO(); 
    226226 
    227 SsaoShader *ssaoShader = NULL; 
     227DeferredRenderer *ssaoShader = NULL; 
    228228 
    229229static GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT}; 
     
    431431        InitCg(); 
    432432 
    433         SsaoShader::Init(sCgContext); 
     433        DeferredRenderer::Init(sCgContext); 
    434434 
    435435 
     
    10141014                cgGLDisableProfile(RenderState::sCgFragmentProfile); 
    10151015 
    1016                 if (!ssaoShader) ssaoShader = new SsaoShader(texWidth, texHeight, camera, myfar / 10.0f); 
     1016                if (!ssaoShader) ssaoShader = new DeferredRenderer(texWidth, texHeight, camera, myfar / 10.0f); 
    10171017                 
    10181018                ssaoShader->SetShadingMethod(shadingMethod); 
     
    11341134        case 'P': 
    11351135        case 'p': 
    1136                 if (samplingMethod == SsaoShader::GAUSS) 
    1137                         samplingMethod = SsaoShader::POISSON; 
     1136                if (samplingMethod == DeferredRenderer::GAUSS) 
     1137                        samplingMethod = DeferredRenderer::POISSON; 
    11381138                else 
    1139                         samplingMethod = SsaoShader::GAUSS; 
     1139                        samplingMethod = DeferredRenderer::GAUSS; 
    11401140 
    11411141                break; 
     
    12801280                break; 
    12811281        case GLUT_KEY_F8: 
    1282                 shadingMethod = (SsaoShader::SHADING_METHOD)((shadingMethod + 1) % 3); 
     1282                shadingMethod = (DeferredRenderer::SHADING_METHOD)((shadingMethod + 1) % 3); 
    12831283                 
    12841284                break; 
Note: See TracChangeset for help on using the changeset viewer.