Changeset 3006


Ignore:
Timestamp:
10/06/08 03:02:23 (16 years ago)
Author:
mattausch
Message:

tried downsampling

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
6 edited

Legend:

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

    r3005 r3006  
    8787 
    8888static CGparameter sOldModelViewProjMatrixGiParam; 
     89static CGparameter sModelViewProjMatrixGiParam; 
    8990static CGparameter sMaxDepthGiParam; 
    9091static CGparameter sSamplesGiParam;  
     
    286287        //-- the flip-flop fbos 
    287288 
    288         mFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
     289        mFbo = new FrameBufferObject(w / 2, h / 2, FrameBufferObject::DEPTH_NONE); 
    289290 
    290291        mFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     
    297298        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    298299        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    299         mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    300         mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     300        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    301301} 
    302302 
     
    406406                 
    407407                sOldModelViewProjMatrixGiParam = cgGetNamedParameter(sCgGiProgram, "oldModelViewProj"); 
     408                sModelViewProjMatrixGiParam = cgGetNamedParameter(sCgGiProgram, "modelViewProj"); 
    408409                sMaxDepthGiParam = cgGetNamedParameter(sCgGiProgram, "maxDepth"); 
    409410                sTemporalCoherenceGiParam = cgGetNamedParameter(sCgGiProgram, "temporalCoherence"); 
     
    576577                float h = 768; 
    577578 
    578                 float xoffs = 1 / w; 
    579                 float yoffs = 1 / h; 
     579                float xoffs = 0.5f / w; 
     580                float yoffs = 0.5f / h; 
    580581 
    581582                downSampleOffsets[0] =  xoffs; downSampleOffsets[1] =  yoffs; 
     
    609610        mFboIndex = 2 - mFboIndex; 
    610611         
     612 
    611613        FrameBufferObject::Release(); 
    612614        cgGLEnableProfile(RenderState::sCgFragmentProfile); 
     
    638640        { 
    639641        case SSAO: 
     642                DownSample(fbo, colorBufferIdx, mDownSampleFbo, 0); 
     643                DownSample(fbo, 1, mDownSampleFbo, 1); 
     644                DownSample(fbo, 2, mDownSampleFbo, 2); 
     645 
    640646                ComputeSsao(fbo, tempCohFactor, oldProjViewMatrix, projViewMatrix); 
    641647                CombineSsao(fbo); 
    642648                break; 
    643649        case GI: 
    644                 DownSample(fbo); 
    645                 ComputeGlobIllum(fbo, tempCohFactor, oldProjViewMatrix); 
     650                DownSample(fbo, colorBufferIdx, mDownSampleFbo, 0); 
     651                DownSample(fbo, 2, mDownSampleFbo, 2); 
     652                ComputeGlobIllum(fbo, tempCohFactor, projViewMatrix, oldProjViewMatrix); 
    646653                CombineIllum(fbo); 
    647654                break; 
     
    698705        cgGLSetMatrixParameterfc(sOldModelViewProjMatrixParam, (const float *)oldProjViewMatrix.x); 
    699706 
    700         GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    701         GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    702         GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    703  
    704         // generate mip map levels of position in order to improve texture lookup performance 
    705         //glBindTexture(GL_TEXTURE_2D, positionsTex); glGenerateMipmapEXT(GL_TEXTURE_2D); 
    706         //glBindTexture(GL_TEXTURE_2D, colorsTex); glGenerateMipmapEXT(GL_TEXTURE_2D); 
     707        //GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     708        //GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     709        //GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
     710 
     711        GLuint colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 
     712        GLuint positionsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 
     713        GLuint normalsTex = mDownSampleFbo->GetColorBuffer(2)->GetTexture(); 
     714 
     715        glPushAttrib(GL_VIEWPORT_BIT); 
     716        glViewport(0, 0, mFbo->GetWidth(), mFbo->GetHeight()); 
    707717 
    708718        // read the second buffer, write to the first buffer 
     
    711721 
    712722        GLuint oldTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 
    713  
    714723        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    715724 
    716         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    717725        cgGLBindProgram(sCgSsaoProgram); 
    718726 
     
    782790        cgGLDisableTextureParameter(sOldTexParam); 
    783791 
    784  
     792        glPopAttrib(); 
    785793        FrameBufferObject::Release(); 
    786794 
     
    823831        GLuint colorsTex = colorBuffer->GetTexture(); 
    824832        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    825          
    826833        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    827  
    828         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    829834        cgGLBindProgram(sCgAntiAliasingProgram); 
    830835         
     
    868873        colorBufferIdx = 3 - colorBufferIdx; 
    869874        glDrawBuffers(1, mrt + colorBufferIdx); 
    870  
     875         
    871876        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    872         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    873  
     877         
    874878        cgGLBindProgram(sCgDeferredProgram); 
    875879 
     
    904908        cgGLDisableTextureParameter(sNormalsTexDeferredParam); 
    905909 
    906         cgGLDisableProfile(RenderState::sCgFragmentProfile); 
    907  
    908910        FrameBufferObject::Release(); 
    909911 
     
    915917void DeferredRenderer::ComputeGlobIllum(FrameBufferObject *fbo,  
    916918                                                                                float tempCohFactor, 
     919                                                                                const Matrix4x4 &projViewMatrix, 
    917920                                                                                const Matrix4x4 &oldProjViewMatrix) 
    918921{ 
    919922        cgGLSetMatrixParameterfc(sOldModelViewProjMatrixGiParam, (const float *)oldProjViewMatrix.x); 
    920  
    921 //      GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     923        cgGLSetMatrixParameterfc(sModelViewProjMatrixGiParam, (const float *)projViewMatrix.x); 
     924 
     925        //GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    922926        GLuint colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 
    923927        GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    924         GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    925  
    926         // generate mip map levels for position texture 
    927         //glBindTexture(GL_TEXTURE_2D, positionsTex); glGenerateMipmapEXT(GL_TEXTURE_2D); 
     928        GLuint normalsTex = mDownSampleFbo->GetColorBuffer(2)->GetTexture(); 
     929 
     930        glPushAttrib(GL_VIEWPORT_BIT); 
     931        glViewport(0, 0, mFbo->GetWidth(), mFbo->GetHeight()); 
    928932 
    929933        // read the second buffer, write to the first buffer 
     
    934938        GLuint oldSsaoTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 
    935939        GLuint oldIllumTex = mFbo->GetColorBuffer(2 - mFboIndex + 1)->GetTexture(); 
    936  
     940         
    937941        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    938942 
    939         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    940943        cgGLBindProgram(sCgGiProgram); 
    941944 
     
    10151018        FrameBufferObject::Release(); 
    10161019 
     1020        glPopAttrib(); 
     1021 
    10171022        PrintGLerror("globillum first pass"); 
    10181023} 
     
    10331038 
    10341039        glDrawBuffers(1, mrt + colorBufferIdx); 
    1035  
    1036         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    10371040 
    10381041        cgGLBindProgram(sCgCombinedIllumProgram); 
     
    10671070        cgGLDisableTextureParameter(sIllumTexCombinedIllumParam); 
    10681071 
    1069         cgGLDisableProfile(RenderState::sCgFragmentProfile); 
    1070  
    10711072        FrameBufferObject::Release(); 
    10721073 
     
    10891090        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    10901091         
    1091         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    1092  
    10931092        cgGLBindProgram(sCgCombinedSsaoProgram); 
    10941093 
     
    11161115        cgGLDisableTextureParameter(sSsaoTexCombinedSsaoParam); 
    11171116         
    1118         cgGLDisableProfile(RenderState::sCgFragmentProfile); 
    1119  
    11201117        FrameBufferObject::Release(); 
    11211118 
     
    12501247        glDrawBuffers(1, mrt + colorBufferIdx); 
    12511248         
    1252  
    12531249        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    12541250 
    1255         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    12561251        cgGLBindProgram(sCgLogLumProgram); 
    12571252         
     
    13141309 
    13151310 
    1316 void DeferredRenderer::DownSample(FrameBufferObject *fbo) 
    1317 { 
    1318         ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
     1311void DeferredRenderer::DownSample(FrameBufferObject *fbo, int bufferIdx, 
     1312                                                                  FrameBufferObject *downSampleFbo,  
     1313                                                                  int downSampleBufferIdx) 
     1314{ 
     1315        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(bufferIdx); 
    13191316        GLuint colorsTex = colorBuffer->GetTexture(); 
    1320          
    1321         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
     1317 
     1318        glPushAttrib(GL_VIEWPORT_BIT); 
     1319        glViewport(0, 0, downSampleFbo->GetWidth(), downSampleFbo->GetHeight()); 
     1320 
    13221321        cgGLBindProgram(sCgDownSampleProgram); 
    13231322         
     
    13261325 
    13271326        mDownSampleFbo->Bind(); 
    1328  
    1329         glDrawBuffers(1, mrt); 
    1330          
     1327        glDrawBuffers(1, mrt + downSampleBufferIdx); 
     1328 
    13311329        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    1332  
    1333         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    13341330        cgGLBindProgram(sCgDownSampleProgram); 
    1335  
    1336         //glPushAttrib(GL_VIEWPORT_BIT); 
    1337         glViewport(0, 0, mWidth / 2, mHeight / 2); 
    1338          
    1339         glMatrixMode(GL_PROJECTION); 
    1340         glPushMatrix(); 
    1341         glLoadIdentity(); 
    1342  
    1343         const float offs2 = 0.5f; 
    1344         glOrtho(-offs2, offs2, -offs2, offs2, 0, 1); 
    1345  
    1346         glMatrixMode(GL_MODELVIEW); 
    1347         glPushMatrix(); 
    1348         glLoadIdentity(); 
    1349  
     1331         
    13501332        const float offs = 0.5f; 
    13511333 
     
    13601342 
    13611343        cgGLDisableTextureParameter(sColorsTexDownSampleParam); 
    1362  
    13631344        FrameBufferObject::Release(); 
    13641345 
    1365         float *data = (float *)mDownSampleFbo->GetColorBuffer(0)->ReadTexture(); 
    1366         //float *data = (float *)mFbo->GetColorBuffer(colorBufferIdx)->ReadTexture(); 
     1346        /*float *data = (float *)mDownSampleFbo->GetColorBuffer(0)->ReadTexture(); 
    13671347        ExportData(data, mWidth / 2, mHeight / 2); 
    1368         //ExportData(data, mWidth, mHeight); 
    1369  
    1370         glMatrixMode(GL_PROJECTION); 
    1371         glPopMatrix(); 
    1372         glMatrixMode(GL_MODELVIEW); 
    1373         glPopMatrix(); 
    1374  
    1375         //glPopAttrib(); 
    1376         glViewport(0, 0, mWidth, mHeight); 
     1348        delete [] data;*/ 
     1349 
     1350        glPopAttrib(); 
     1351         
    13771352        PrintGLerror("downsample"); 
    1378  
    1379         delete [] data; 
    13801353} 
    13811354 
     
    13941367        colorBufferIdx = 3 - colorBufferIdx; 
    13951368        glDrawBuffers(1, mrt + colorBufferIdx); 
    1396          
    13971369        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    13981370 
    1399         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    14001371        cgGLBindProgram(sCgToneProgram); 
    14011372         
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r2994 r3006  
    7272                                         const Matrix4x4 &projViewMatrix); 
    7373 
    74         void ComputeGlobIllum(FrameBufferObject *fbo, float tempCohFactor, const Matrix4x4 &oldProjViewMatrix); 
     74        void ComputeGlobIllum(FrameBufferObject *fbo, float tempCohFactor, const Matrix4x4 &projViewMatrix, const Matrix4x4 &oldProjViewMatrix); 
    7575 
    7676        void FirstPass(FrameBufferObject *fbo, DirectionalLight *light); 
     
    9090        */ 
    9191        void ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br); 
    92          
    93         void DownSample(FrameBufferObject *fbo); 
    9492 
     93        /** Downsample buffer of fbo to buffer of downSampleFbo. The downSampleFbo must have half the 
     94                resolution of fbo. 
     95        */ 
     96        void DownSample(FrameBufferObject *fbo, int bufferIdx, 
     97                                        FrameBufferObject *downSampleFbo, int downSampleBufferIdx); 
    9598 
    9699 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h

    r3005 r3006  
    116116        unsigned int GetDepthTex() const { return mDepthTexId; } 
    117117 
     118        inline int GetWidth() { return mWidth; } 
     119 
     120        inline int GetHeight() { return mHeight; } 
     121 
     122 
    118123protected: 
    119124 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r3003 r3006  
    6262                                   uniform float2 samples[NUM_SAMPLES], 
    6363                                   uniform float3 currentNormal, 
    64                                    uniform float4 centerPosition, 
     64                                   uniform float3 centerPosition, 
    6565                                   float w, 
    6666                                   uniform float3 eyePos, 
     
    103103                //if ((texcoord.x <= 1.0f) && (texcoord.x >= 0.0f) && (texcoord.y <= 1.0f) && (texcoord.y >= 0.0f)) ++ numSamples; 
    104104 
    105                 // reconstruct world space position from sample 
     105                ////////// 
     106                //-- reconstruct world space position from sample 
     107 
    106108                float4 sample = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)); 
    107109                const float eyeSpaceDepth = sample.w; 
     
    118120                float3 direction_to_sample = vector_to_sample / length_to_sample; 
    119121 
    120                 // Angle between current normal and direction to sample controls AO intensity. 
     122                // use angle between current normal and direction to sample controls AO intensity. 
    121123                float cos_angle = max(dot(direction_to_sample, currentNormal), 0); 
    122124 
     
    153155                   uniform sampler2D oldIllumTex, 
    154156                   const uniform float4x4 oldModelViewProj, 
     157                   const uniform float4x4 modelViewProj, 
    155158                   uniform float maxDepth, 
    156159                   uniform float temporalCoherence, 
     
    166169        float4 norm = tex2D(normals, IN.texCoord.xy); 
    167170        float3 normal = normalize(norm.xyz);     
    168         // something like a constant ambient term 
    169         const float amb = norm.w; 
    170          
    171         /// the current view direction 
    172         //float3 viewDir = normalize(IN.view); 
    173171 
    174172        // the w coordinate from the persp. projection 
    175173        float w = norm.w; 
    176         // the current world position 
    177         const float4 centerPosition2 = tex2D(positions, IN.texCoord.xy); 
    178  
    179         /// reconstruct position from the eye space depth 
    180         float3 viewDir = normalize(IN.view); 
    181         const float eyeDepth = tex2D(colors, IN.texCoord.xy).w; 
    182          
    183         float4 centerPosition; 
     174 
     175 
     176        ///////////// 
     177        //-- reconstruct position from the eye space depth 
     178 
     179        float3 viewDir = Interpol(IN.texCoord.xy, bl, br, tl, tr);//IN.view; 
     180        const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)).w; 
     181         
     182        float3 centerPosition; 
    184183        centerPosition.xyz = eyePos - viewDir * eyeDepth; 
    185  
    186         centerPosition.w = centerPosition2.w; 
    187  
    188         // the current color 
    189         const float4 currentCol = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
    190         // the current depth is stored in the w component 
    191         const float currentDepth = centerPosition.w; 
    192  
    193         GiStruct gi = globIllum(IN, colors, noiseTexture, samples, normal, centerPosition2, w, eyePos, bl, br, tl, tr); 
     184         
     185        //const float3 centerPosition = tex2D(positions, IN.texCoord.xy).xyz; 
     186 
     187 
     188        /////////// 
     189        //-- compute color bleeding + ao 
     190 
     191        GiStruct gi = globIllum(IN, colors, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 
    194192         
    195193 
     
    197195        //-- compute temporally smoothing 
    198196 
    199         float4 realPos = centerPosition * maxDepth; 
    200         realPos.w = 1.0f; 
    201  
    202         float4 oldPos = mul(oldModelViewProj, realPos); 
    203  
    204         const float newDepth = oldPos.z / oldPos.w; 
    205  
    206         float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f; 
    207  
     197        float4 realPos = float4(centerPosition * maxDepth, 1.0f); 
     198 
     199 
     200        // calculcate the current projected depth for next frame 
     201        float4 currentPos = mul(modelViewProj, realPos); 
     202        currentPos /= currentPos.w; 
     203        const float currentDepth = currentPos.z; 
     204         
     205 
     206        /////////// 
     207        //-- reprojection new frame into old one  
     208         
     209        // calculate projected depth 
     210        float4 projPos = mul(oldModelViewProj, realPos); 
     211        projPos /= projPos.w; 
     212 
     213        // the current depth projected into the old frame 
     214        const float projDepth = projPos.z; 
     215 
     216        // fit from unit cube into 0 .. 1 
     217        float2 tex = (projPos.xy) * 0.5f + 0.5f; 
     218 
     219        // retrieve the sample from the last frame 
    208220        float4 oldSsao = tex2D(oldSsaoTex, tex); 
    209221        float4 oldIllum = tex2D(oldIllumTex, tex); 
    210222 
    211223        const float oldDepth = oldSsao.w; 
    212         const float depthDif = 1.0f - newDepth / oldDepth; 
     224        const float depthDif = 1.0f - projDepth / oldDepth; 
    213225 
    214226        float oldWeight = clamp(oldSsao.z, 0, temporalCoherence); 
     227 
    215228        float newWeight; 
    216229 
    217         const float oldNumSamples = oldSsao.y; 
    218         const float oldAvgDepth = oldSsao.z; 
     230        //const float oldNumSamples = oldSsao.y; 
     231        //const float oldAvgDepth = oldSsao.z; 
    219232 
    220233        if (//(temporalCoherence > 0.0f) && 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3005 r3006  
    66 
    77 
    8 #define USE_EYE_SPACE_DEPTH 0 
     8#define USE_EYE_SPACE_DEPTH 1 
    99 
    1010 
     
    7171                   uniform float2 samples[NUM_SAMPLES], 
    7272                   uniform float3 currentNormal, 
    73                    uniform float4 centerPosition, 
     73                   uniform float3 centerPosition, 
    7474                   uniform float scaleFactor, 
    7575                   uniform float3 eyePos, 
     
    161161        pixel OUT; 
    162162 
    163         float4 norm = tex2D(normals, IN.texCoord.xy); 
     163        float4 norm = tex2Dlod(normals, float4(IN.texCoord, 0 ,0)); 
    164164        float3 normal = normalize(norm.xyz); 
    165165 
    166         // a constant ambient term 
    167         const float amb = norm.w; 
    168166        // the w coordinate from the persp. projection 
    169167        float w = norm.w; 
     
    173171        /// reconstruct position from the eye space depth 
    174172        float3 viewDir = IN.view; 
    175         const float eyeDepth = tex2D(colors, IN.texCoord.xy).w; 
    176  
    177         float4 centerPosition; 
     173        const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 
     174 
     175        float3 centerPosition; 
    178176        centerPosition.xyz = eyePos - viewDir * eyeDepth; 
    179         centerPosition.w = centerPosition.w; 
    180177 
    181178        const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 
     
    183180 
    184181        // the current world position 
    185         const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 
     182        const float3 centerPosition = tex2Dlod(positions, float4(IN.texCoord, 0, 0)).xyz; 
    186183 
    187184        const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 
     
    192189        //-- compute temporally smoothing 
    193190 
    194         float4 realPos = centerPosition * maxDepth; 
    195         realPos.w = 1.0f; 
    196  
    197         // calulcate the current depth 
    198         //const float currentDepth = centerPosition.w; 
    199          
    200         // apply modelview matrix 
     191        float4 realPos = float4(centerPosition * maxDepth, 1.0f); 
     192 
     193 
     194        // calculcate the current projected depth for next frame 
    201195        float4 currentPos = mul(modelViewProj, realPos); 
    202196        currentPos /= currentPos.w; 
     
    217211        float2 tex = (projPos.xy) * 0.5f + 0.5f; 
    218212 
    219         // optain the sample from the last frame 
     213        // retrieve the sample from the last frame 
    220214        float4 oldCol = tex2D(oldTex, tex); 
    221215 
    222216        const float oldDepth = oldCol.w; 
     217        const float depthDif = 1.0f - projDepth / oldDepth; 
     218 
     219 
    223220        //const float oldNumSamples = oldCol.y; 
    224221        const float oldWeight = clamp(oldCol.z, 0, temporalCoherence); 
    225  
    226         const float depthDif = 1.0f - projDepth / oldDepth; 
    227222 
    228223        float newWeight; 
     
    264259        pixel OUT; 
    265260 
    266         float4 col = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
    267         float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 
     261        float4 col = tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 
     262        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    268263 
    269264        OUT.illum_col = col * ao.x; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg

    r3005 r3006  
    2828    for(int i = 0; i < 4; ++ i) 
    2929    { 
    30         average += tex2D(colors, IN.texCoord + downSampleOffs[i]); 
     30        average += tex2Dlod(colors, float4(IN.texCoord + downSampleOffs[i],0,0)); 
    3131    } 
    3232         
    3333    average *= 1.0f / 4.0f; 
    3434 
    35     return tex2D(colors, IN.texCoord);//average; 
     35    return average; 
    3636} 
    3737     
Note: See TracChangeset for help on using the changeset viewer.