Ignore:
Timestamp:
07/13/08 23:51:02 (16 years ago)
Author:
mattausch
Message:

research version: implemented temporal smoothing and color bleeding

File:
1 edited

Legend:

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

    r2833 r2834  
    3939 
    4040///////////// 
    41 //-- textures 
     41//-- fbos 
     42 
    4243GLuint fbo; 
     44GLuint fbo1; 
     45GLuint fbo2; 
     46 
     47bool isFirstTexture = true; 
     48 
     49///////////// 
     50//-- renderbuffers 
     51 
    4352 
    4453GLuint depthBuffer; 
     
    4655GLuint positionsBuffer; 
    4756GLuint colorsBuffer; 
     57GLuint colorsBuffer1; 
     58GLuint colorsBuffer2; 
    4859GLuint normalsBuffer; 
     60 
     61 
     62///////////// 
     63//-- textures 
     64 
    4965 
    5066GLuint positionsTex; 
    5167GLuint colorsTex; 
     68GLuint colorsTex1; 
     69GLuint colorsTex2; 
     70 
    5271GLuint normalsTex; 
    5372 
     
    169188 
    170189// ssao number of samples 
    171 #define NUM_SAMPLES 8 
     190//#define NUM_SAMPLES 8 
     191#define NUM_SAMPLES 16 
    172192 
    173193// ssao random spherical samples 
    174194static float samples[NUM_SAMPLES * 2]; 
     195 
     196static Matrix4x4 matProjectionView = IdentityMatrix(); 
    175197 
    176198 
     
    249271 
    250272static CGparameter sModelViewProjMatrixParam; 
     273static CGparameter sOldModelViewProjMatrixParam; 
    251274static CGparameter sMaxDepthParam; 
    252275static CGparameter sMaxDepthParamTex; 
    253276 
    254277static CGparameter sSamplesParamSsao;  
    255 //static CGparameter sNoiseMultiplierParam;;  
    256  
    257  
     278 
     279static CGparameter sOldTexParam; 
     280static CGparameter sOldTexParamSsao; 
     281 
     282static CGparameter sNoiseMultiplierParam; 
    258283 
    259284static void cgErrorCallback() 
     
    439464void InitCg(void)  
    440465{ 
    441         GenerateSamples(); 
    442  
    443466        // Setup Cg 
    444467        cgSetErrorCallback(cgErrorCallback); 
     
    488511 
    489512                cgGLSetParameter1f(sMaxDepthParamTex, 10.0f / myfar); 
     513                Debug << "maxdepth: " << 10.0f / myfar << endl; 
    490514        } 
    491515        else 
     
    535559                sNormalsTexParamSsao = cgGetNamedParameter(sCgSsaoProgram, "normals");   
    536560                sNoiseTexParamSsao = cgGetNamedParameter(sCgSsaoProgram, "noiseTexture"); 
    537                 //sNoiseMultiplierParam = cgGetNamedParameter(sCgSsaoProgram, "noiseMultiplier"); 
     561                sNoiseMultiplierParam = cgGetNamedParameter(sCgSsaoProgram, "noiseMultiplier"); 
     562                sOldModelViewProjMatrixParam = cgGetNamedParameter(sCgSsaoProgram, "oldModelViewProj"); 
    538563                 
    539564                cgGLDisableTextureParameter(sNoiseTexParamSsao); 
    540565 
    541566                sSamplesParamSsao = cgGetNamedParameter(sCgSsaoProgram, "samples"); 
     567                sOldTexParamSsao = cgGetNamedParameter(sCgSsaoProgram, "oldTex");   
     568 
     569                GenerateSamples(); 
    542570                cgGLSetParameterArray2f(sSamplesParamSsao, 0, NUM_SAMPLES, (const float *)samples); 
    543571        } 
     
    561589                sPositionsTexParam = cgGetNamedParameter(sCgDeferredProgram, "positions");   
    562590                sColorsTexParam = cgGetNamedParameter(sCgDeferredProgram, "colors");   
    563                 sNormalsTexParam = cgGetNamedParameter(sCgDeferredProgram, "normals");   
     591                sNormalsTexParam = cgGetNamedParameter(sCgDeferredProgram, "normals");  
     592 
     593                sOldTexParam = cgGetNamedParameter(sCgDeferredProgram, "oldTex");   
    564594        } 
    565595        else 
     
    569599        PrintGLerror("init"); 
    570600 
    571         cout << "cg initialised" << endl; 
     601        cout << "cg initialization successful" << endl; 
    572602} 
    573603 
     
    619649        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorsBuffer); 
    620650         
    621         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, texWidth, texHeight); 
     651        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
    622652        int samples = 8; 
    623653        //glEnable(GL_MULTISAMPLE_ARB); 
     
    628658        glBindTexture(GL_TEXTURE_2D, colorsTex); 
    629659 
    630         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 
     660        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
    631661        glGenerateMipmapEXT(GL_TEXTURE_2D); 
    632662        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorsTex, 0); 
     
    651681        glGenTextures(1, &positionsTex); 
    652682        glBindTexture(GL_TEXTURE_2D, positionsTex); 
    653         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB,  texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
     683        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
    654684        //glGenerateMipmapEXT(GL_TEXTURE_2D); 
    655685        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, positionsTex, 0); 
     
    675705        glGenTextures(1, &normalsTex); 
    676706        glBindTexture(GL_TEXTURE_2D, normalsTex); 
    677         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 
    678         //glGenerateMipmapEXT(GL_TEXTURE_2D); 
     707        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 
    679708        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, normalsTex, 0); 
    680709 
     
    699728        PrintFBOStatus(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); 
    700729         
     730         
     731 
     732        ////////////////////////////////// 
     733 
     734 
     735 
     736        glGenFramebuffersEXT(1, &fbo1); 
     737        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo1); 
     738 
     739         
     740        //////////// 
     741        //-- colors buffer 
     742 
     743        glGenRenderbuffersEXT(1, &colorsBuffer1); 
     744        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorsBuffer1); 
     745         
     746        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
     747        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorsBuffer1); 
     748         
     749        glGenTextures(1, &colorsTex1); 
     750        glBindTexture(GL_TEXTURE_2D, colorsTex1); 
     751 
     752        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
     753        glGenerateMipmapEXT(GL_TEXTURE_2D); 
     754        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorsTex1, 0); 
     755 
     756        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
     757        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 
     758 
     759        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 
     760        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 
     761 
     762        PrintFBOStatus(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); 
     763 
     764 
     765 
     766        ///////////////////////// 
     767 
     768        glGenFramebuffersEXT(1, &fbo2); 
     769        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo2); 
     770 
     771         
     772        //////////// 
     773        //-- colors buffer 
     774 
     775        glGenRenderbuffersEXT(1, &colorsBuffer2); 
     776        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorsBuffer2); 
     777         
     778        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
     779        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorsBuffer2); 
     780         
     781        glGenTextures(1, &colorsTex2); 
     782        glBindTexture(GL_TEXTURE_2D, colorsTex2); 
     783 
     784        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
     785        glGenerateMipmapEXT(GL_TEXTURE_2D); 
     786        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorsTex2, 0); 
     787 
     788        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
     789        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 
     790 
     791        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 
     792        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 
     793 
     794        PrintFBOStatus(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); 
     795 
    701796        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
    702797 
     
    9171012void SetupEyeView() 
    9181013{ 
     1014        Matrix4x4 matViewing, matProjection; 
     1015 
     1016        if (renderType == RenderState::DEFERRED) 
     1017        { 
     1018                cgGLSetMatrixParameterfc(sOldModelViewProjMatrixParam, (const float *)matProjectionView.x); 
     1019        } 
     1020 
    9191021        glMatrixMode(GL_PROJECTION); 
    9201022        glLoadIdentity(); 
     
    9321034        glLightfv(GL_LIGHT1, GL_POSITION, position1); 
    9331035 
     1036         
     1037        camera->GetModelViewMatrix(matViewing); 
     1038        camera->GetProjectionMatrix(matProjection); 
     1039 
     1040        matProjectionView = matViewing * matProjection; 
    9341041         
    9351042        if (renderType == RenderState::DEFERRED) 
     
    9421049                static Matrix4x4 identity = IdentityMatrix(); 
    9431050                cgGLSetMatrixParameterfc(SceneEntity::sModelMatrixParam, (const float *)identity.x); 
    944         }        
     1051        }                
    9451052} 
    9461053 
     
    11241231                perfGraph->AddData(algTime); 
    11251232 
    1126                 /*float col[3]; 
    1127                 switch (renderMode) 
    1128                 { 
    1129                 case RenderTraverser::CHCPLUSPLUS: 
    1130                         col[0] = 1.0f; col[1] = 0.0f; col[2] = 0.0f; 
    1131                         break; 
    1132                 case RenderTraverser::CHC: 
    1133                         col[0] = 0.0f; col[1] = 1.0f; col[2] = 1.0f; 
    1134                         break; 
    1135                 case RenderTraverser::STOP_AND_WAIT: 
    1136                         col[0] = 1.0f; col[1] = 1.0f; col[2] = 0.0f; 
    1137                         break; 
    1138                 case RenderTraverser::CULL_FRUSTUM: 
    1139                         col[0] = 1.0f; col[1] = 0.0f; col[2] = 1.0f; 
    1140                         break; 
    1141                 default: 
    1142                         col[0] = 1.0f; col[1] = 0.0f; col[2] = 0.0f; 
    1143                 } 
    1144                 perfGraph->SetGraphColor(col); 
    1145                 */ 
    11461233                perfGraph->Draw(); 
    11471234        } 
     
    11521239 
    11531240        DisplayStats(); 
     1241 
     1242        isFirstTexture = !isFirstTexture; 
    11541243 
    11551244        glutSwapBuffers(); 
     
    15301619        glPushMatrix(); 
    15311620        glLoadIdentity(); 
     1621 
    15321622        gluOrtho2D(0, winWidth, 0, winHeight); 
    15331623 
     
    15401630void End2D()  
    15411631{ 
     1632        glMatrixMode(GL_PROJECTION); 
    15421633        glPopMatrix(); 
     1634 
    15431635        glMatrixMode(GL_MODELVIEW); 
    15441636        glPopMatrix(); 
     
    15701662 
    15711663        const float offs = box.Size().x * 0.3f; 
    1572         //const float yoffs = box.Size().y * 0.5f; 
    1573  
     1664         
    15741665        Vector3 pos = camera->GetPosition(); 
    15751666 
     
    15781669        visCamera->SetPosition(vizpos); 
    15791670         
     1671        glPushAttrib(GL_VIEWPORT_BIT); 
    15801672        glViewport(winWidth - winWidth / 3, winHeight - winHeight / 3, winWidth / 3, winHeight / 3); 
    15811673 
    15821674        glMatrixMode(GL_PROJECTION); 
     1675        glPushMatrix(); 
     1676 
    15831677        glLoadIdentity(); 
    15841678         
     
    15861680 
    15871681        glMatrixMode(GL_MODELVIEW); 
     1682        glPushMatrix(); 
    15881683 
    15891684        visCamera->SetupCameraView(); 
     
    16091704        visualization->Render(); 
    16101705         
    1611         // reset vp 
    1612         glViewport(0, 0, winWidth, winHeight); 
     1706         
     1707        // reset previous settings 
     1708        glPopAttrib(); 
     1709 
     1710        glMatrixMode(GL_PROJECTION); 
     1711        glPopMatrix(); 
     1712        glMatrixMode(GL_MODELVIEW); 
     1713        glPopMatrix(); 
    16131714} 
    16141715 
     
    18801981 
    18811982 
     1983void DisplayRenderTexture3() 
     1984{ 
     1985        glEnable(GL_TEXTURE_2D); 
     1986 
     1987        if (isFirstTexture) 
     1988                glBindTexture(GL_TEXTURE_2D, colorsTex1); 
     1989        else 
     1990                glBindTexture(GL_TEXTURE_2D, colorsTex2); 
     1991 
     1992        glDisable(GL_LIGHTING); 
     1993         
     1994        glMatrixMode(GL_PROJECTION); 
     1995        glPushMatrix(); 
     1996        glLoadIdentity(); 
     1997 
     1998        glMatrixMode(GL_MODELVIEW); 
     1999        glPushMatrix(); 
     2000        glLoadIdentity(); 
     2001 
     2002        const float offs = 0.5f; 
     2003        glOrtho(-offs, offs, -offs, offs, 0, 1); 
     2004         
     2005        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     2006 
     2007        glColor4f(1.0f, 1.0f, 1.0f, 1.0f); 
     2008        glBegin(GL_QUADS); 
     2009 
     2010        glTexCoord2f(0, 0); glVertex3f(-offs, -offs, -0.5f); 
     2011        glTexCoord2f(1, 0); glVertex3f( offs, -offs, -0.5f); 
     2012        glTexCoord2f(1, 1); glVertex3f( offs,  offs, -0.5f); 
     2013        glTexCoord2f(0, 1); glVertex3f(-offs,  offs, -0.5f); 
     2014 
     2015        glEnd(); 
     2016 
     2017        glEnable(GL_LIGHTING); 
     2018        glDisable(GL_TEXTURE_2D); 
     2019         
     2020        glMatrixMode(GL_PROJECTION); 
     2021        glPopMatrix(); 
     2022 
     2023        glMatrixMode(GL_MODELVIEW); 
     2024        glPopMatrix(); 
     2025 
     2026        PrintGLerror("displaytexture3"); 
     2027} 
     2028 
     2029 
    18822030void DisplayRenderTexture() 
    18832031{ 
     2032        GLuint oldTex; 
     2033 
     2034        if (isFirstTexture) 
     2035        { 
     2036                glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo1); 
     2037                oldTex = colorsTex2; 
     2038        } 
     2039        else  
     2040        { 
     2041                glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo2); 
     2042                oldTex = colorsTex1; 
     2043        } 
     2044 
     2045        glPushAttrib(GL_VIEWPORT_BIT); 
     2046        glViewport(0, 0, texWidth, texHeight); 
     2047 
     2048        glDrawBuffers(1, mrt); 
     2049 
    18842050        glDisable(GL_ALPHA_TEST); 
    18852051        glDisable(GL_TEXTURE_2D); 
     
    19062072                cgGLBindProgram(sCgSsaoProgram); 
    19072073                 
     2074                cgGLSetTextureParameter(sPositionsTexParamSsao, positionsTex); 
    19082075                cgGLEnableTextureParameter(sPositionsTexParamSsao); 
    1909                 cgGLSetTextureParameter(sPositionsTexParamSsao, positionsTex); 
    1910          
     2076 
     2077                cgGLSetTextureParameter(sColorsTexParamSsao, colorsTex); 
    19112078                cgGLEnableTextureParameter(sColorsTexParamSsao); 
    1912                 cgGLSetTextureParameter(sColorsTexParamSsao, colorsTex); 
    1913  
     2079 
     2080                cgGLSetTextureParameter(sNormalsTexParamSsao, normalsTex); 
    19142081                cgGLEnableTextureParameter(sNormalsTexParamSsao); 
    1915                 cgGLSetTextureParameter(sNormalsTexParamSsao, normalsTex); 
    1916  
     2082 
     2083                cgGLSetTextureParameter(sNoiseTexParamSsao, noiseTex); 
    19172084                cgGLEnableTextureParameter(sNoiseTexParamSsao); 
    1918                 cgGLSetTextureParameter(sNoiseTexParamSsao, noiseTex); 
    1919  
    1920                 //cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 7.0f)); 
     2085 
     2086                cgGLSetTextureParameter(sOldTexParamSsao, oldTex); 
     2087                cgGLEnableTextureParameter(sOldTexParamSsao); 
     2088 
     2089                cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 17.0f)); 
     2090 
     2091                //GenerateSamples(); cgGLSetParameterArray2f(sSamplesParamSsao, 0, NUM_SAMPLES, (const float *)samples); 
    19212092        } 
    19222093        else 
     
    19242095                cgGLBindProgram(sCgDeferredProgram); 
    19252096 
     2097                cgGLSetTextureParameter(sPositionsTexParam, positionsTex); 
    19262098                cgGLEnableTextureParameter(sPositionsTexParam); 
    1927                 cgGLSetTextureParameter(sPositionsTexParam, positionsTex); 
    1928          
     2099 
     2100                cgGLSetTextureParameter(sColorsTexParam, colorsTex); 
    19292101                cgGLEnableTextureParameter(sColorsTexParam); 
    1930                 cgGLSetTextureParameter(sColorsTexParam, colorsTex); 
    1931  
     2102 
     2103                cgGLSetTextureParameter(sNormalsTexParam, normalsTex); 
    19322104                cgGLEnableTextureParameter(sNormalsTexParam); 
    1933                 cgGLSetTextureParameter(sNormalsTexParam, normalsTex); 
     2105 
     2106                cgGLSetTextureParameter(sOldTexParam, oldTex); 
     2107                cgGLEnableTextureParameter(sOldTexParam); 
    19342108        } 
    19352109 
     
    19522126        glEnd(); 
    19532127 
    1954         cgGLDisableTextureParameter(sColorsTexParamSsao); 
    1955         cgGLDisableTextureParameter(sPositionsTexParamSsao); 
    1956         cgGLDisableTextureParameter(sNormalsTexParamSsao); 
    19572128         
    19582129        if (useSsao) 
     2130        { 
     2131                cgGLDisableTextureParameter(sColorsTexParamSsao); 
     2132                cgGLDisableTextureParameter(sPositionsTexParamSsao); 
     2133                cgGLDisableTextureParameter(sNormalsTexParamSsao); 
    19592134                cgGLDisableTextureParameter(sNoiseTexParamSsao); 
     2135                cgGLDisableTextureParameter(sOldTexParamSsao); 
     2136        } 
     2137        else 
     2138        { 
     2139                cgGLDisableTextureParameter(sColorsTexParam); 
     2140                cgGLDisableTextureParameter(sPositionsTexParam); 
     2141                cgGLDisableTextureParameter(sNormalsTexParam); 
     2142                cgGLDisableTextureParameter(sOldTexParam); 
     2143        } 
    19602144 
    19612145        cgGLDisableProfile(RenderState::sCgFragmentProfile); 
     
    19702154        glPopMatrix(); 
    19712155 
    1972          
     2156        glPopAttrib(); 
     2157 
    19732158        PrintGLerror("displaytexture"); 
     2159 
     2160        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
     2161 
     2162        DisplayRenderTexture3(); 
    19742163} 
    19752164 
     
    20142203#else 
    20152204 
    2016 /*void GenerateSamples() 
    2017 { 
    2018         float scale = 1.0f / (float)NUM_SAMPLES; 
    2019  
    2020         //////// 
    2021         //-- generate uniformly distributed spherical samples 
    2022  
    2023         for (int i = 0; i < NUM_SAMPLES; ++ i) 
    2024         { 
    2025                 // create stratified samples over sphere 
    2026                 const float rx = ((float)i + RandomValue(0, 1)) * scale; 
    2027                 const float ry = ((float)i + RandomValue(0, 1)) * scale; 
    2028  
    2029                 const float theta = 2.0f * acos(sqrt(1.0f - rx)); 
    2030                 const float phi = 2.0f * M_PI * ry; 
    2031  
    2032                 Vector3 unit = Vector3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta)); 
    2033  
    2034                 ////// 
    2035                 //-- we sample in texture space => store 2D component 
    2036  
    2037                 // q: project to plane or just drop z? 
    2038                 Vector3 proj = unit / (1.0f + fabs(unit.z)); 
    2039                 //Vector3 proj = unit; 
    2040  
    2041                 samples[i + 0] = proj.x; 
    2042                 samples[i + 1] = proj.y; 
    2043                 //cout << samples[i] << " " << samples[i + 1] << endl; 
    2044         } 
    2045 }*/ 
    20462205 
    20472206void GenerateSamples() 
    20482207{ 
    20492208        // generates poisson distribution on disc 
    2050         //float factor = 5.0f; 
    2051         float minDist = 2.0f;//factor / sqrt((float)NUM_SAMPLES); 
    2052  
    2053         cout << "minDist= " << minDist << endl; 
     2209        float minDist = 2.0f / sqrt((float)NUM_SAMPLES); 
     2210 
     2211        //cout << "minDist before= " << minDist << endl; 
    20542212 
    20552213        for (int i = 0; i < NUM_SAMPLES * 2; i += 2) 
     
    20962254                        } 
    20972255                } 
    2098                 cout << "sample: " << samples[i] << " " << i /2 << " " << samples[i + 1] << " r: " << sqrt(samples[i] * samples[i]  + samples[i + 1] * samples[i + 1]) << " tries: " << totalTries << endl; 
    2099         } 
    2100  
    2101         cout << "minDist= " << minDist << endl; 
     2256                //cout << "sample: " << samples[i] << " " << i /2 << " " << samples[i + 1] << " r: " << sqrt(samples[i] * samples[i]  + samples[i + 1] * samples[i + 1]) << " tries: " << totalTries << endl; 
     2257        } 
     2258 
     2259        //cout << "minDist after= " << minDist << endl; 
    21022260} 
    21032261 
     
    21182276        float t2 = w_far * 0.5f; 
    21192277 
     2278#if 0 
    21202279        bl = Normalize(-Vector3(-t1, -t2, 1.0f)); 
    21212280        br = Normalize(-Vector3( t1, -t2, 1.0f)); 
    21222281        tl = Normalize(-Vector3(-t1,  t2, 1.0f)); 
    21232282        tr = Normalize(-Vector3( t1,  t2, 1.0f)); 
    2124  
     2283#else 
     2284        bl = -Normalize(camera->GetDirection()); 
     2285        br = -Normalize(camera->GetDirection()); 
     2286        tl = -Normalize(camera->GetDirection()); 
     2287        tr = -Normalize(camera->GetDirection()); 
     2288#endif 
    21252289        // normalize to 0 .. 1 
    21262290        bl = bl * 0.5f + 0.5f; 
Note: See TracChangeset for help on using the changeset viewer.