Changeset 2994


Ignore:
Timestamp:
10/02/08 18:34:07 (16 years ago)
Author:
mattausch
Message:

started to use a downsampling fbo

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r2986 r2994  
    2424# ssao temporal coherence factor 
    2525tempCohFactor=50.0f 
     26 
     27useHDR=1 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r2993 r2994  
    3838 
    3939 
    40 static CGprogram sCgInitialIntensityProgram; 
    4140static CGprogram sCgDownSampleProgram; 
    4241static CGprogram sCgToneProgram; 
     
    129128static CGparameter sColorsTexInitialParam; 
    130129static CGparameter sColorsTexToneParam; 
    131 static CGparameter sIntensityTexDownSampleParam; 
     130 
     131static CGparameter sColorsTexDownSampleParam; 
    132132 
    133133//#define USE_3D_SSAO 
     
    532532                cerr << "tone program failed to load" << endl; 
    533533 
    534 /* 
    535         sCgInitialIntensityProgram =  
     534        sCgDownSampleProgram =  
    536535                cgCreateProgramFromFile(context,  
    537536                                                                CG_SOURCE, 
     
    541540                                                                NULL); 
    542541 
    543         if (sCgInitialIntensityProgram != NULL) 
    544         { 
    545                 cgGLLoadProgram(sCgInitialIntensityProgram); 
     542        if (sCgDownSampleProgram != NULL) 
     543        { 
     544                cgGLLoadProgram(sCgDownSampleProgram); 
    546545 
    547546                // we need size of texture for scaling 
    548                 sColorsTexInitialParam = cgGetNamedParameter(sCgInitialIntensityProgram, "colors");   
     547                sColorsTexDownSampleParam = cgGetNamedParameter(sCgDownSampleProgram, "colors");   
    549548        } 
    550549        else 
    551550                cerr << "intensity program failed to load" << endl; 
    552  
    553 */ 
    554551 
    555552        PrintGLerror("init"); 
     
    12361233 
    12371234        cgGLDisableTextureParameter(sColorsTexLogLumParam); 
    1238  
    12391235        FrameBufferObject::Release(); 
    12401236 
     
    12531249void DeferredRenderer::DownSample(FrameBufferObject *fbo) 
    12541250{ 
    1255         GLuint intensityTex=0; 
     1251        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
     1252        GLuint colorsTex = colorBuffer->GetTexture(); 
    12561253         
    12571254        cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    12581255        cgGLBindProgram(sCgDownSampleProgram); 
    12591256         
    1260         cgGLSetTextureParameter(sIntensityTexDownSampleParam, intensityTex); 
    1261         cgGLEnableTextureParameter(sIntensityTexDownSampleParam); 
     1257        cgGLSetTextureParameter(sColorsTexDownSampleParam, colorsTex); 
     1258        cgGLEnableTextureParameter(sColorsTexDownSampleParam); 
     1259 
     1260        mDownSampleFbo->Bind(); 
     1261 
     1262        glDrawBuffers(1, mrt); 
     1263         
     1264        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     1265 
     1266        cgGLEnableProfile(RenderState::sCgFragmentProfile); 
     1267        cgGLBindProgram(sCgDownSampleProgram); 
     1268 
     1269        const float offs = 0.5f; 
     1270 
     1271        glBegin(GL_QUADS); 
     1272 
     1273        glTexCoord2f(0, 0); glVertex3f(-offs, -offs, -0.5f); 
     1274        glTexCoord2f(1, 0); glVertex3f( offs, -offs, -0.5f); 
     1275        glTexCoord2f(1, 1); glVertex3f( offs,  offs, -0.5f); 
     1276        glTexCoord2f(0, 1); glVertex3f(-offs,  offs, -0.5f); 
     1277 
     1278        glEnd(); 
     1279 
     1280        cgGLDisableTextureParameter(sColorsTexDownSampleParam); 
     1281 
     1282        FrameBufferObject::Release(); 
     1283 
     1284        PrintGLerror("ToneMapParams"); 
    12621285} 
    12631286 
     
    12701293{ 
    12711294        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
     1295        GLuint colorsTex = colorBuffer->GetTexture(); 
    12721296 
    12731297        fbo->Bind(); 
     
    12751299        colorBufferIdx = 3 - colorBufferIdx; 
    12761300        glDrawBuffers(1, mrt + colorBufferIdx); 
    1277  
    1278  
    1279         GLuint colorsTex = colorBuffer->GetTexture(); 
    12801301         
    12811302        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r2991 r2994  
    105105        Camera *mCamera; 
    106106 
    107         FrameBufferObject *mFbo; 
    108  
    109107        bool mUseTemporalCoherence; 
    110108 
     
    116114        bool mRegenerateSamples; 
    117115 
     116        // the main fbo we are working with 
     117        FrameBufferObject *mFbo; 
     118 
     119        FrameBufferObject *mDownSampleFbo; 
    118120}; 
    119121 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2992 r2994  
    9797SkyPreetham *preetham = NULL; 
    9898 
     99/// the used render type for this render pass 
     100enum RenderMethod 
     101{ 
     102        RENDER_FIXED, 
     103        RENDER_DEPTH_PASS, 
     104        RENDER_DEFERRED, 
     105        RENDER_DEPTH_PASS_DEFERRED, 
     106        RENDER_NUM_RENDER_TYPES 
     107}; 
     108 
     109/// one of four possible render methods 
     110int renderMethod = RENDER_FIXED; 
     111 
    99112 
    100113/// these values get scaled with the frame rate 
     
    133146int numBatches = 0; 
    134147 
    135 bool showHelp = false; 
    136 bool showStatistics = false; 
    137 bool showOptions = true; 
    138 bool showBoundingVolumes = false; 
    139 bool visMode = false; 
    140148 
    141149// mouse navigation state 
     
    146154int horizontalMotionBegin = 0; 
    147155 
    148 bool useOptimization = false; 
    149 bool useTightBounds = true; 
    150 bool useRenderQueue = true; 
    151 bool useMultiQueries = true; 
    152 bool flyMode = true; 
    153156 
    154157bool leftKeyPressed = false; 
     
    159162bool ascendKeyPressed = false; 
    160163 
     164bool showHelp = false; 
     165bool showStatistics = false; 
     166bool showOptions = true; 
     167bool showBoundingVolumes = false; 
     168bool visMode = false; 
     169 
     170bool useOptimization = false; 
     171bool useTightBounds = true; 
     172bool useRenderQueue = true; 
     173bool useMultiQueries = true; 
     174bool flyMode = true; 
     175 
    161176bool useGlobIllum = false; 
    162177bool useTemporalCoherence = true; 
     178bool showAlgorithmTime = false; 
     179 
     180bool useFullScreen = false; 
     181bool useLODs = true; 
     182bool moveLight = false; 
     183 
     184bool useAdvancedShading = false; 
     185bool showShadowMap = false; 
     186bool renderLightView = false; 
     187 
     188bool altKeyPressed = false; 
     189 
     190bool useHDR = true; 
    163191 
    164192static float ssaoTempCohFactor = 255.0; 
    165193 
    166 bool showAlgorithmTime = false; 
    167  
    168 GLubyte *randomNormals = NULL; 
    169194 
    170195PerfTimer frameTimer, algTimer; 
     
    172197static int sCurrentMrtSet = 0; 
    173198 
    174 /// the used render type for this render pass 
    175 enum RenderMethod 
    176 { 
    177         RENDER_FIXED, 
    178         RENDER_DEPTH_PASS, 
    179         RENDER_DEFERRED, 
    180         RENDER_DEPTH_PASS_DEFERRED, 
    181         RENDER_NUM_RENDER_TYPES 
    182 }; 
    183  
    184 /// one of four possible render methods 
    185 int renderMethod = RENDER_FIXED; 
    186  
    187199PerformanceGraph *perfGraph = NULL; 
    188200 
    189 bool useFullScreen = false; 
    190  
    191 bool useLODs = true; 
    192  
    193 bool moveLight = false; 
    194201 
    195202//DeferredRenderer::SAMPLING_METHOD samplingMethod = DeferredRenderer::SAMPLING_POISSON; 
    196203DeferredRenderer::SAMPLING_METHOD samplingMethod = DeferredRenderer::SAMPLING_QUADRATIC; 
    197204 
    198 bool useAdvancedShading = false; 
    199  
    200 bool showShadowMap = false; 
    201 bool shadowChanged = true; 
    202205 
    203206static Matrix4x4 matProjectionView = IdentityMatrix(); 
    204207 
    205 bool renderLightView = false; 
    206208 
    207209ShadowMap *shadowMap = NULL; 
     
    213215SceneEntity *skyDome = NULL; 
    214216 
    215 bool altKeyPressed = false; 
    216  
    217 #define USE_TONE_MAPPING 0 
    218217 
    219218 
     
    345344                env.GetBoolParam(string("useLODs"), useLODs); 
    346345                env.GetIntParam(string("shadowSize"), shadowSize); 
     346 
     347                env.GetBoolParam(string("useHDR"), useHDR); 
    347348 
    348349                //env.GetStringParam(string("modelPath"), model_path); 
     
    845846         
    846847 
    847         const bool useToneMapping = ((renderMethod == RENDER_DEPTH_PASS_DEFERRED) || (renderMethod == RENDER_DEFERRED)) && USE_TONE_MAPPING; 
     848        const bool useToneMapping = ((renderMethod == RENDER_DEPTH_PASS_DEFERRED) || (renderMethod == RENDER_DEFERRED)) && useHDR; 
    848849 
    849850        Vector3 sunAmbient; 
     
    11901191 
    11911192                ShadowMap *sm = showShadowMap ? shadowMap : NULL; 
    1192                 ssaoShader->Render(fbo, oldViewProjMatrix, matProjectionView, ssaoTempCohFactor, light, USE_TONE_MAPPING, sm); 
     1193                ssaoShader->Render(fbo, oldViewProjMatrix, matProjectionView, ssaoTempCohFactor, light, useHDR, sm); 
    11931194        } 
    11941195 
     
    12551256 
    12561257                break; 
    1257         case 'h': 
    1258         case 'H': 
    1259                 showHelp = !showHelp; 
    1260                 break; 
    12611258        case '+': 
    12621259                if (maxBatchSize < 10) 
     
    13641361        case 'L': 
    13651362                renderLightView = !renderLightView; 
     1363                break; 
     1364        case 'h': 
     1365        case 'H': 
     1366                useHDR = !useHDR; 
    13661367                break; 
    13671368        default: 
     
    20272028                state.SetRenderPassType(RenderState::DEFERRED); 
    20282029 
    2029         const bool useToneMapping = ((renderMethod == RENDER_DEPTH_PASS_DEFERRED) || (renderMethod == RENDER_DEFERRED)) && USE_TONE_MAPPING; 
     2030        const bool useToneMapping = ((renderMethod == RENDER_DEPTH_PASS_DEFERRED) || (renderMethod == RENDER_DEFERRED)) && useHDR; 
    20302031 
    20312032        preetham->RenderSkyDome(-light->GetDirection(), camera, &state, !useToneMapping); 
Note: See TracChangeset for help on using the changeset viewer.