Changeset 2982


Ignore:
Timestamp:
10/01/08 00:40:59 (16 years ago)
Author:
mattausch
Message:

problematic: merging

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

Legend:

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

    r2959 r2982  
    2323 
    2424# ssao temporal coherence factor 
    25 tempCohFactor=100.0f 
     25tempCohFactor=50.0f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r2981 r2982  
    164164        str.read(reinterpret_cast<char *>(&texId), sizeof(int)); 
    165165 
    166         if (0)//texId >= 0) 
     166        if (texId >= 0) 
    167167                mat->SetTexture(mTextureTable[texId]); 
    168168         
     
    182182                str.read(reinterpret_cast<char *>(&mat->mEmmisiveColor), sizeof(Vector3)); 
    183183                str.read(reinterpret_cast<char *>(&mat->mSpecularColor), sizeof(Vector3)); 
    184  
    185                 mat->mAmbientColor = RandomColor(); 
    186                 mat->mDiffuseColor = RgbaColor(0,0,0,1); 
    187184        } 
    188185 
     
    228225        } 
    229226 
    230         // return new Geometry(vertices, normals, texcoords, vertexCount, true); 
    231         return new Geometry(vertices, normals, texcoords, vertexCount, false); 
     227        return new Geometry(vertices, normals, texcoords, vertexCount, true); 
     228        //return new Geometry(vertices, normals, texcoords, vertexCount, false); 
    232229} 
    233230 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp

    r2981 r2982  
    2424static CGparameter sDColorParam; 
    2525static CGparameter sEColorParam; 
     26static CGparameter sMultiplierParam; 
     27 
    2628 
    2729 
     
    6062                sDColorParam = cgGetNamedParameter(sCgSkyProgram, "dColor"); 
    6163                sEColorParam = cgGetNamedParameter(sCgSkyProgram, "eColor"); 
     64 
     65                sMultiplierParam = cgGetNamedParameter(sCgSkyProgram, "multiplier"); 
    6266        } 
    6367        else 
     
    7579        { 
    7680                cgGLLoadProgram(sCgMrtFragmentSkyDomeProgram); 
    77  
    78                 /* 
    79                 cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / farDist); 
    80                 */ 
     81                //cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / farDist); 
    8182        } 
    8283        else 
     
    129130        cgGLSetParameter3f(sEColorParam, ABCDE[4].x, ABCDE[4].y, ABCDE[4].z); 
    130131 
    131         cgGLEnableProfile(RenderState::sCgVertexProfile); 
    132         cgGLBindProgram(sCgSkyProgram); 
    133  
    134          
    135132        if (state->GetRenderPassType() == RenderState::DEFERRED) 
    136133        { 
    137134                cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    138135                cgGLBindProgram(sCgMrtFragmentSkyDomeProgram); 
     136                 
     137                // can use tone mapping 
     138                cgGLSetParameter1f(sMultiplierParam, 1.0f); 
    139139        }        
     140        else  
     141        { 
     142                // no tone mapping => scale 
     143                cgGLSetParameter1f(sMultiplierParam, 8e-5f); 
     144        } 
     145 
     146        cgGLEnableProfile(RenderState::sCgVertexProfile); 
     147        cgGLBindProgram(sCgSkyProgram); 
    140148 
    141149        // Render sky dome. 
     
    258266 
    259267 
    260 void SkyPreetham::ComputeSunColor(const Vector3 &sunDir, Vector3 &ambient, Vector3 &diffuse) const 
     268void SkyPreetham::ComputeSunColor(const Vector3 &sunDir, Vector3 &ambient, Vector3 &diffuse, bool scaleToRange) const 
    261269{ 
    262270        // sunDir is sun direction 
     
    280288 
    281289        // downscale ambient color 
    282         if (1) 
    283                 ambient *= 5e-5f; 
     290        if (scaleToRange) 
     291                ambient *= 2e-5f; 
    284292        else 
    285293                ambient *= 1e-1f; 
     
    320328 
    321329        // Calculate final sun diffuse color. 
    322         if (1) 
    323                 diffuse = color * 1.7e-4f; 
     330        if (scaleToRange) 
     331                diffuse = color * 5e-2f; 
    324332        else 
    325333                diffuse = color * 3e-1f; 
    326334 
    327335        diffuse *= (2.0f - 1.0f * DotProd(sunDir, Vector3::UNIT_Z())); 
    328          
    329336 
    330337        //cout << "diffuse: " << Magnitude(diffuse) << " ambient: " << Magnitude(ambient) << endl; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.h

    r2960 r2982  
    3131                                                std::pair<float, float> &sunThetha) const; 
    3232 
    33         void ComputeSunColor(const CHCDemoEngine::Vector3 &sunDir, CHCDemoEngine::Vector3 &ambient, CHCDemoEngine::Vector3 &diffuse) const; 
     33        void ComputeSunColor(const CHCDemoEngine::Vector3 &sunDir,  
     34                                 CHCDemoEngine::Vector3 &ambient,  
     35                                                 CHCDemoEngine::Vector3 &diffuse, 
     36                                                 bool scaleToRange) const; 
    3437 
    3538 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2981 r2982  
    455455         
    456456        SceneEntity *oldEnt = NULL; 
    457  
     457#if 0 
    458458        cout << "merging entities .. " << endl; 
    459459 
     
    489489 
    490490        cout << "merged " << merged << " of " << (int)sceneEntities.size() << " entities " << endl; 
    491  
     491#endif 
    492492        // set far plane based on scene extent 
    493493        farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 
     
    502502 
    503503        Vector3 cubeCenter(470.398f, 240.364f, 182.5f); 
    504         /*AxisAlignedBox3 box(cubeCenter - Vector3(2.0f), cubeCenter + Vector3(2.0f)); 
    505  
    506         Material *mat = new Material(RgbaColor(1, 0.4, 0.4, 0)); 
    507         Transform3 *tf = new Transform3(); 
    508         cube = SceneEntityConverter().ConvertBox(box, mat, tf); 
    509 */ 
    510  
     504         
    511505        Matrix4x4 transl = TranslationMatrix(cubeCenter); 
    512506         
    513         //const string aeroplaneStr = model_path + "toyplane.dem"; 
    514         //const string aeroplaneStr = model_path + "city_full.dem"; 
    515507 
    516508        SceneEntityContainer dummy; 
    517  
    518509         
    519510        string skyDomeStr(model_path + "sky.dem"); 
     
    532523 
    533524 
    534         /*if (loader->Load(aeroplaneStr, dummy)) 
    535                 cout << "successfully loaded " << dummy.size() << " scene entities" << endl; 
    536         else 
    537         { 
    538                 cerr << "loading file " << aeroplaneStr << " failed" << endl; 
    539  
    540                 CleanUp(); 
    541                 exit(0); 
    542         } 
    543  
    544         aeroplane = dummy[1]; 
    545  
    546         aeroplane->GetTransform()->MultMatrix(transl); 
    547 */ 
    548         const float turbitiy = 3.0f; 
     525        const float turbitiy = 9.0f; 
    549526        preetham = new SkyPreetham(turbitiy, skyDome); 
    550527 
     
    859836        GLfloat diffuse[] = {1.0f, 0.95f, 0.85f, 1.0f}; 
    860837        GLfloat specular[] = {1.0f, 1.0f, 1.0f, 1.0f}; 
    861         //GLfloat specular[] = {0.0f, 0.0f, 0.0f, 1.0f}; 
     838         
     839 
     840        const bool useToneMapping =  
     841                (renderMethod == RENDER_DEPTH_PASS_DEFERRED) || 
     842                (renderMethod == RENDER_DEFERRED); 
    862843 
    863844        Vector3 sunAmbient; 
    864845        Vector3 sunDiffuse; 
    865846 
    866         preetham->ComputeSunColor(lightDir, sunAmbient, sunDiffuse); 
    867  
    868         const float maxComponent = sunDiffuse.MaxComponent(); 
    869         //cout<< "sunambient: " << sunAmbient << " mag " << Magnitude(sunDiffuse) << " max: " << maxComponent << endl; 
     847        preetham->ComputeSunColor(lightDir, sunAmbient, sunDiffuse, !useToneMapping); 
    870848 
    871849        ambient[0] = sunAmbient.x; 
     
    873851        ambient[2] = sunAmbient.z; 
    874852 
    875         //sunDiffuse /= maxComponent; 
     853 
     854        // no tone mapping => scale 
     855        if (!useToneMapping) 
     856        { 
     857                const float maxComponent = sunDiffuse.MaxComponent(); 
     858                //cout<< "sunambient: " << sunAmbient << " mag " << Magnitude(sunDiffuse) << " max: " << maxComponent << endl; 
     859                sunDiffuse /= maxComponent; 
     860        } 
    876861 
    877862        diffuse[0] = sunDiffuse.x; 
    878863        diffuse[1] = sunDiffuse.y; 
    879864        diffuse[2] = sunDiffuse.z; 
    880          
    881         //cout<< "sunambient: " << sunAmbient << endl; 
    882         //cout<< "sundiffuse: " << sunDiffuse << endl; 
    883865 
    884866        glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); 
     
    11031085                 
    11041086                glEnableClientState(GL_NORMAL_ARRAY); 
    1105  
    11061087                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    11071088 
     
    11331114        { 
    11341115                // actually render the scene geometry using the specified algorithm 
    1135                 //traverser->RenderScene(); 
    1136  
     1116                traverser->RenderScene(); 
     1117/* 
    11371118#if 0 
    11381119                SceneEntityContainer::const_iterator sit, sit_end = sceneEntities.end(); 
     
    11471128                        renderQueue->Enqueue(*sit); 
    11481129#endif 
    1149                          
     1130*/                       
    11501131                renderQueue->Apply(); 
    11511132        } 
     
    20632044 
    20642045                InitDeferredRendering(); 
    2065  
    2066                 glClear(GL_COLOR_BUFFER_BIT); 
    20672046        } 
    20682047        else 
     
    20782057        glDepthFunc(GL_LEQUAL); 
    20792058        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     2059 
     2060        glClear(GL_COLOR_BUFFER_BIT); 
    20802061 
    20812062        state.SetUseAlphaToCoverage(true); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r2978 r2982  
    2828//#define ILLUM_INTENSITY 9e-1f; 
    2929 
    30 #define SSAO_MIPMAP_LEVEL 0//1 
     30#define SSAO_MIPMAP_LEVEL 1 
    3131#define GI_MIPMAP_LEVEL 0//2 
    3232 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2978 r2982  
    9898 
    9999        if (oldColor.w > 0) 
    100                 OUT.color.w = lerp(oldColor.w, logLumScaled, 0.2f); 
     100                OUT.color.w = lerp(oldColor.w, logLumScaled, 0.1f); 
    101101        else 
    102102                OUT.color.w = logLumScaled; 
     
    217217 
    218218        if (oldColor.w > 0) 
    219                 OUT.color.w = lerp(oldColor.w, logLumScaled, 0.2f); 
     219                OUT.color.w = lerp(oldColor.w, logLumScaled, 0.1f); 
    220220        else 
    221221                OUT.color.w = logLumScaled; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2974 r2982  
    9494        // hack: squeeze some information about ambient into the texture 
    9595        pix.col.w = glstate.material.emission.x; 
     96        //pix.col.w = length(currentPos - IN.worldPos) 
    9697 
    9798        return pix; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/sky_preetham.cg

    r2974 r2982  
    6363                                  uniform float3 dColor, 
    6464                                  uniform float3 eColor, 
    65                                   uniform float4x4 ModelView) 
     65                                  uniform float4x4 ModelView, 
     66                                  uniform float multiplier) 
    6667{ 
    6768        vtxout OUT; 
     
    9495        OUT.color = float4(hcol, 1.0); 
    9596 
    96         //OUT.color.rgb *= 2e-5f;  
     97        OUT.color.rgb *= multiplier; 
    9798 
    9899        OUT.color2 = OUT.color; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2979 r2982  
    157157        float newWeight; 
    158158 
     159        float newNumSamples = ao.y; 
     160 
    159161        if (//(temporalCoherence > 0) && 
    160162                (tex.x >= 0.0f) && (tex.x < 1.0f) &&  
    161163                (tex.y >= 0.0f) && (tex.y < 1.0f) &&  
    162                 (abs(depthDif) < 1e-3f)  
     164                (abs(depthDif) < 1e-4f)  
    163165                // check if visibility changed in the surrounding area: 
    164166                // then we have to recompute 
    165                 && (oldNumSamples > ao.y - 1.5f)  
     167                && ((newWeight < 10) || (oldNumSamples > 0.9f * newNumSamples)) 
     168                //&& (oldAvgDepth / newAvgDepth > 0.99) 
    166169                ) 
    167170        { 
     
    173176        } 
    174177        else 
    175         { 
     178        {        
    176179                OUT.illum_col.xy = ao.xy; 
    177180                newWeight = 0; 
Note: See TracChangeset for help on using the changeset viewer.