Ignore:
Timestamp:
12/08/08 18:48:21 (16 years ago)
Author:
mattausch
Message:

worked on lense flare

File:
1 edited

Legend:

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

    r3213 r3214  
    7979static float ssaoFilterWeights[NUM_SSAO_FILTER_SAMPLES]; 
    8080 
    81 static Texture *sHaloTex[4]; 
     81static Texture *sHaloTex[5]; 
    8282 
    8383int DeferredRenderer::colorBufferIdx = 0; 
     
    300300static void PrepareLenseFlare() 
    301301{ 
    302         string textures[] = {"lens1.jpg", "lens2.jpg", "lens3.jpg", "lens4.jpg"}; 
    303  
    304         for (int i = 0; i < 4; ++ i) 
     302        string textures[] = {"flare4.tga", "lens2.jpg", "lens3.jpg", "lens4.jpg", "lens1.jpg"}; 
     303 
     304        for (int i = 0; i < 5; ++ i) 
    305305        { 
    306306                sHaloTex[i] = new Texture(model_path + textures[i]); 
    307307 
    308                 sHaloTex[i]->SetBoundaryModeS(Texture::CLAMP); 
    309                 sHaloTex[i]->SetBoundaryModeT(Texture::CLAMP); 
     308                sHaloTex[i]->SetBoundaryModeS(Texture::BORDER); 
     309                sHaloTex[i]->SetBoundaryModeT(Texture::BORDER); 
    310310 
    311311                sHaloTex[i]->Create(); 
     
    501501        string lenseFlareParams[] =  
    502502                {"colorsTex", "flareTex1", "flareTex2", "flareTex3", "flareTex4",  
    503                  "vectorToLight", "distanceToLight"}; 
    504  
    505         sCgLenseFlareProgram->AddParameters(lenseFlareParams, 0, 7); 
     503                 "flareTex5", "vectorToLight", "distanceToLight"}; 
     504 
     505        sCgLenseFlareProgram->AddParameters(lenseFlareParams, 0, 8); 
    506506 
    507507 
     
    555555                                                          bool useToneMapping, 
    556556                                                          bool useAntiAliasing, 
     557                                                          bool lightSourceVisible, 
    557558                                                          ShadowMap *shadowMap 
    558559                                                          ) 
     
    567568        if (mShadingMethod != 0) 
    568569        { 
    569                 // downsample fbo buffers 
    570                 PrepareSsao(fbo); 
     570                PrepareSsao(fbo); // downsample fbo buffers 
    571571        } 
    572572 
     
    584584                CombineIllum(fbo); 
    585585                break; 
    586         default: // DEFAULT 
     586        default: 
    587587                // do nothing: standard deferred shading 
    588588                break; 
     
    598598 
    599599 
    600         LenseFlare(fbo, light); 
     600        if (lightSourceVisible) 
     601                LenseFlare(fbo, light); 
    601602 
    602603        // multisampling is difficult / costly with deferred shading 
     
    12771278        // the sun is a large distance in the reverse light direction 
    12781279        // => extrapolate light pos 
    1279          
    12801280        const Vector3 lightPos = light->GetDirection() * -1e3f; 
    12811281 
    1282         Vector3 projLightPos = mProjViewMatrix * lightPos * 0.5f + Vector3(0.5f); 
    1283         cout << "lightPos " << projLightPos << endl; 
    1284  
    1285         // check if light is visible in the image 
    1286         if ((projLightPos.x < -0.2f) || (projLightPos.y < -0.2f) || 
    1287                 (projLightPos.x >= 1.2f) || (projLightPos.y >= 1.2f)) 
     1282        float w; 
     1283        Vector3 projLightPos = mProjViewMatrix.Transform(w, lightPos, 1.0f); 
     1284        projLightPos /= w; 
     1285        projLightPos = projLightPos * 0.5f + Vector3(0.5f); 
     1286 
     1287        //Vector3 dummy = mProjViewMatrix * lightPos; 
     1288 
     1289        // check if light out of image range 
     1290        /*if ((projLightPos.x < -0.2f) || (projLightPos.y < -0.2f) || 
     1291                (projLightPos.x >= 1.2f) || (projLightPos.y >= 1.2f) ||  
     1292                (w < .0f)) 
    12881293                return; 
    1289  
     1294*/ 
    12901295        // vector to light from screen center in texture space 
    12911296        Vector3 vectorToLight = projLightPos - Vector3(0.5f); 
     
    12951300        vectorToLight /= distanceToLight; 
    12961301 
    1297         cout << "dist " << distanceToLight << " v " << vectorToLight << endl; 
     1302        //cout << "dist " << distanceToLight << " v " << vectorToLight << endl; 
    12981303 
    12991304 
     
    13101315        sCgLenseFlareProgram->SetTexture(i ++, sHaloTex[2]->GetId()); 
    13111316        sCgLenseFlareProgram->SetTexture(i ++, sHaloTex[3]->GetId()); 
     1317        sCgLenseFlareProgram->SetTexture(i ++, sHaloTex[4]->GetId()); 
    13121318        sCgLenseFlareProgram->SetValue2f(i ++, vectorToLight.x, vectorToLight.y); 
    13131319        sCgLenseFlareProgram->SetValue1f(i ++, distanceToLight); 
Note: See TracChangeset for help on using the changeset viewer.