Changeset 2964


Ignore:
Timestamp:
09/22/08 18:33:55 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp

    r2963 r2964  
    118118        } 
    119119 
    120         cout << "... finished loading " << bvh->mNumNodes << " scene box: " << bvh->mBox << endl; 
    121120 
    122121        bvh->mBox = bvh->mRoot->GetBox(); 
     122 
     123        cout << "... finished loading " << bvh->mNumNodes << " nodes" << endl; 
     124        cout << "scene box: " << bvh->mBox << endl; 
    123125 
    124126         
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp

    r2960 r2964  
    2222 
    2323        mAmbientColor = RgbaColor(0.2f, 0.2f, 0.2f, 1.0f); 
    24         //mAmbientColor = RgbaColor(1.0f, 1.0f, 1.0f, 1.0f); 
    2524        mDiffuseColor = RgbaColor(1.0f, 1.0f, 1.0f, 1.0f); 
    2625        mSpecularColor = RgbaColor(.0f, .0f, .0f, 1.0f); 
     
    6059        state->SetState(mTexture != NULL, mAlphaTestEnabled, mCullFaceEnabled); 
    6160 
    62         if (mTexture) 
    63                 mTexture->Bind(); 
     61        if (state->GetRenderPassType() == RenderState::DEFERRED) 
     62        { 
     63                if (mTexture) 
     64                { 
     65                        cgGLSetTextureParameter(RenderState::sTexParam, mTexture->GetId()); 
     66                        cgGLEnableTextureParameter(RenderState::sTexParam); 
     67                        cgGLEnableTextureParameter(RenderState::sDirtTexParamTex); 
     68                } 
     69                else 
     70                { 
     71                        cgGLDisableTextureParameter(RenderState::sTexParam); 
     72                } 
     73        } 
    6474        else 
    65                 glBindTexture(GL_TEXTURE_2D, 0); 
     75        { 
     76                if (mTexture) 
     77                        mTexture->Bind(); 
     78                else 
     79                        glBindTexture(GL_TEXTURE_2D, 0); 
     80        } 
    6681 
    6782        glMaterialfv(GL_FRONT, GL_AMBIENT, (float *)&mAmbientColor.r); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp

    r2955 r2964  
    1313CGprogram RenderState::sCgMrtFragmentProgram = NULL; 
    1414CGprogram RenderState::sCgMrtFragmentTexProgram = NULL; 
     15CGparameter RenderState::sTexParam; 
     16CGparameter RenderState::sDirtTexParamTex; 
     17 
    1518 
    1619 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h

    r2955 r2964  
    8181        static CGprogram sCgMrtFragmentTexProgram; 
    8282 
     83        static CGparameter sTexParam; 
     84 
     85        static CGparameter sDirtTexParamTex; 
    8386 
    8487protected: 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Texture.h

    r2850 r2964  
    6262        */ 
    6363        void Create(); 
    64          
     64        /** Returns id of this texture. 
     65        */ 
     66        int GetId() const { return mTexId; } 
    6567 
    6668 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2963 r2964  
    3939#include "ObjConverter.h" 
    4040#include "SkyPreetham.h" 
     41#include "Texture.h" 
    4142 
    4243 
     
    167168PerfTimer frameTimer, algTimer; 
    168169 
     170Texture *dirtTexture = NULL; 
     171 
    169172 
    170173/// the used render type for this render pass 
     
    269272static CGparameter sMaxDepthParam; 
    270273static CGparameter sMaxDepthParamTex; 
     274 
    271275static Matrix4x4 oldViewProjMatrix; 
    272276 
     
    454458        camera->SetFar(Magnitude(bvh->GetBox().Diagonal())); 
    455459         
     460        dirtTexture = new Texture(model_path + "waterstain.jpg"); 
     461        //dirtTexture = new Texture(model_path + "dirt.jpg"); 
     462        dirtTexture->Create(); 
     463 
    456464        InitCg(); 
    457465 
     
    470478         
    471479        //const string aeroplaneStr = model_path + "toyplane.dem"; 
    472         const string aeroplaneStr = model_path + "city_full.dem"; 
     480        //const string aeroplaneStr = model_path + "city_full.dem"; 
    473481 
    474482        SceneEntityContainer dummy; 
    475483 
    476         if (loader->Load(aeroplaneStr, dummy)) 
    477                 cout << "successfully loaded " << dummy.size() << " scene entities" << endl; 
    478         else 
    479         { 
    480                 cerr << "loading file " << aeroplaneStr << " failed" << endl; 
    481  
    482                 CleanUp(); 
    483                 exit(0); 
    484         } 
    485  
     484         
    486485        string skyDomeStr(model_path + "sky.dem"); 
    487486 
     
    496495        } 
    497496 
    498         aeroplane = dummy[0]; 
    499         skyDome = dummy[1]; 
     497        skyDome = dummy[0]; 
     498 
     499 
     500        /*if (loader->Load(aeroplaneStr, dummy)) 
     501                cout << "successfully loaded " << dummy.size() << " scene entities" << endl; 
     502        else 
     503        { 
     504                cerr << "loading file " << aeroplaneStr << " failed" << endl; 
     505 
     506                CleanUp(); 
     507                exit(0); 
     508        } 
     509 
     510        aeroplane = dummy[1]; 
    500511 
    501512        aeroplane->GetTransform()->MultMatrix(transl); 
    502  
     513*/ 
    503514        const float turbitiy = 3.0f; 
    504515        preetham = new SkyPreetham(turbitiy, skyDome); 
     
    569580 
    570581                sMaxDepthParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "maxDepth"); 
     582                RenderState::sDirtTexParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "dirtTex"); 
     583                RenderState::sTexParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tex"); 
     584 
     585                cgGLEnableTextureParameter(RenderState::sDirtTexParamTex); 
     586                cgGLSetTextureParameter(RenderState::sDirtTexParamTex, dirtTexture->GetId()); 
    571587 
    572588                cgGLSetParameter1f(sMaxDepthParamTex, MAX_DEPTH_CONST / farDist); 
     
    10861102        { 
    10871103                // actually render the scene geometry using the specified algorithm 
    1088                 //traverser->RenderScene(); 
     1104                traverser->RenderScene(); 
     1105        /* 
    10891106                state.Reset(); 
    1090         /*      SceneEntityContainer::const_iterator sit, sit_end = sceneEntities.end(); 
     1107                aeroplane->Render(&state); 
     1108 
     1109        SceneEntityContainer::const_iterator sit, sit_end = sceneEntities.end(); 
    10911110 
    10921111                for (sit = sceneEntities.begin(); sit != sit_end; ++ sit) 
    10931112                { 
    10941113                        renderQueue->Enqueue(*sit); 
    1095                 }*/ 
    1096  
    1097                 aeroplane->Render(&state); 
     1114                } 
    10981115 
    10991116                renderQueue->Apply(); 
     1117                */ 
    11001118        } 
    11011119 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r2954 r2964  
    2929//#define ILLUM_INTENSITY 9e-1f; 
    3030 
     31#define SSAO_MIPMAP_LEVEL 1 
     32#define GI_MIPMAP_LEVEL 2 
    3133 
    3234#endif // __SHADERENV_H 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r2904 r2964  
    9292 
    9393                // use lower lod level to improve cache coherence 
    94                 float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz; 
    95                 float3 sample_color = tex2Dlod(colors, float4(texcoord, 0, 2)).xyz; 
     94                float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 
     95                float3 sample_color = tex2Dlod(colors, float4(texcoord, 0, GI_MIPMAP_LEVEL)).xyz; 
    9696 
    9797                float3 vector_to_sample = sample_position - centerPosition.xyz; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2960 r2964  
    6666 
    6767pixel fragtex(fragin IN,  
    68                           uniform sampler2D tex,  
    69                           uniform float maxDepth) 
     68                          uniform sampler2D dirtTex, 
     69                          uniform float maxDepth, 
     70                          uniform sampler2D tex) 
    7071{ 
    7172        pixel pix; 
    7273 
     74        //float4 dirtTexColor = tex2D(dirtTex, IN.texCoord.xy); 
     75        float4 texColor = tex2D(tex, IN.texCoord.xy); 
     76 
    7377        // save color in first render target 
    7478        // hack: use comination of emmisive + diffuse (emmisive used as constant ambient term) 
    75         pix.col = (glstate.material.emission + glstate.material.diffuse) * tex2D(tex, IN.texCoord.xy); 
     79        //pix.col = (glstate.material.emission + glstate.material.diffuse) * texColor * dirtTexColor;  
     80        pix.col = (glstate.material.emission + glstate.material.diffuse) * texColor;  
    7681         
    7782        // save world position in second render target 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2911 r2964  
    7373 
    7474                // sample downsampled texture in order to speed up texture accesses 
    75                 float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz; 
     75                float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 
    7676                //float3 sample_position = tex2D(positions, texcoord).xyz; 
    7777 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao3d.cg

    r2903 r2964  
    7676                        ++ j; 
    7777                        // sample downsampled texture in order to speed up texture accesses 
    78                         float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz; 
     78                        float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 
    7979                        //float3 sample_position = tex2D(positions, texcoord).xyz; 
    8080 
Note: See TracChangeset for help on using the changeset viewer.