Changeset 2866


Ignore:
Timestamp:
08/25/08 20:20:42 (16 years ago)
Author:
mattausch
Message:

bug: downsampling of positions does not work

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

Legend:

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

    r2865 r2866  
    4242        mFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    4343        // the diffuse color buffer 
    44         mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
     44        mFbo->AddColorBuffer(w, h, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
    4545} 
    4646 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp

    r2862 r2866  
    168168                        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 
    169169 
    170                         glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, w, h, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); 
     170                        glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, mWidth, mHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); 
    171171 
    172172                        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, mDepthTexId, 0); 
     
    178178 
    179179 
    180 int FrameBufferObject::AddColorBuffer(ColorBufferObject::FORMAT col,  
     180int FrameBufferObject::AddColorBuffer(int w, int h, 
     181                                                                          ColorBufferObject::FORMAT col,  
    181182                                                                          ColorBufferObject::WRAP_TYPE wrapType,  
    182183                                                                          ColorBufferObject::FILTER_TYPE filterType,  
     
    190191        int idx = (int)mColorBuffers.size(); 
    191192        ColorBufferObject *colorBuf =  
    192                 new ColorBufferObject(mWidth, mHeight, col, wrapType, filterType, useMipMap, useMultiSampling, idx); 
     193                new ColorBufferObject(w, h, col, wrapType, filterType, useMipMap, useMultiSampling, idx); 
    193194 
    194195        mColorBuffers.push_back(colorBuf); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h

    r2862 r2866  
    5151                Returns the index that allows to retrieve the color buffer object. 
    5252        */ 
    53         int AddColorBuffer(ColorBufferObject::FORMAT col,  
     53        int AddColorBuffer(int w, int h, 
     54                                   ColorBufferObject::FORMAT col,  
    5455                               ColorBufferObject::WRAP_TYPE wrapType,  
    5556                                           ColorBufferObject::FILTER_TYPE filterType,  
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp

    r2865 r2866  
    7878        mNewFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    7979        // the diffuse color buffer 
    80         mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
     80        mNewFbo->AddColorBuffer(w, h, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
    8181         
    8282        mOldFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    8383        // the diffuse color buffer 
    84         mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
     84        mOldFbo->AddColorBuffer(w, h, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
    8585         
    8686 
     
    284284 
    285285 
    286 /*void SsaoShader::DisplayTexture() 
    287 { 
    288         glEnable(GL_TEXTURE_2D); 
    289  
    290         glBindTexture(GL_TEXTURE_2D, mNewFbo->GetColorBuffer(0)->GetTexture()); 
    291  
    292         glDisable(GL_LIGHTING); 
    293          
    294         glMatrixMode(GL_PROJECTION); 
    295         glPushMatrix(); 
    296         glLoadIdentity(); 
    297  
    298         glMatrixMode(GL_MODELVIEW); 
    299         glPushMatrix(); 
    300         glLoadIdentity(); 
    301  
    302         const float offs = 0.5f; 
    303         glOrtho(-offs, offs, -offs, offs, 0, 1); 
    304          
    305         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    306  
    307         glColor4f(1.0f, 1.0f, 1.0f, 1.0f); 
    308         glBegin(GL_QUADS); 
    309  
    310         glTexCoord2f(0, 0); glVertex3f(-offs, -offs, -0.5f); 
    311         glTexCoord2f(1, 0); glVertex3f( offs, -offs, -0.5f); 
    312         glTexCoord2f(1, 1); glVertex3f( offs,  offs, -0.5f); 
    313         glTexCoord2f(0, 1); glVertex3f(-offs,  offs, -0.5f); 
    314  
    315         glEnd(); 
    316  
    317         glEnable(GL_LIGHTING); 
    318         glDisable(GL_TEXTURE_2D); 
    319          
    320         glMatrixMode(GL_PROJECTION); 
    321         glPopMatrix(); 
    322  
    323         glMatrixMode(GL_MODELVIEW); 
    324         glPopMatrix(); 
    325  
    326         PrintGLerror("ssao second pass"); 
    327 }*/ 
    328  
    329  
    330286void SsaoShader::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br) 
    331287{ 
     
    364320        for (int i = 0; i < mWidth * mHeight * 3; i += 3) 
    365321        { 
    366                 // create random samples over sphere 
     322                // create random samples on a circle 
    367323                const float rx = RandomValue(0, 1); 
    368324                const float theta = 2.0f * acos(sqrt(1.0f - rx)); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2865 r2866  
    108108static int texWidth = 1024; 
    109109static int texHeight = 768; 
     110 
     111//static int texWidth = 512; 
     112//static int texHeight = 384; 
     113 
    110114//static int texWidth = 2048; 
    111115//static int texHeight = 2048; 
     
    530534 
    531535        // the diffuse color buffer 
    532         fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
     536        fbo->AddColorBuffer(texWidth, texHeight, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
    533537        // the positions buffer 
    534         fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false, false); 
     538        fbo->AddColorBuffer(512, 512, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false, false); 
    535539        // the normals buffer 
    536540        //fbo->AddColorBuffer(ColorBufferObject::BUFFER_UBYTE, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false, false); 
    537         fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false, false); 
     541        fbo->AddColorBuffer(texWidth, texHeight, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false, false); 
    538542 
    539543        PrintGLerror("fbo"); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg

    r2865 r2866  
    3131 
    3232        nd -= e_barrier.x; 
    33         nd = step(0, nd); 
     33        nd = step(0.0f, nd); 
    3434 
    3535        float ne = saturate(dot(nd, e_weights.x)); 
     
    6464 
    6565        dd = abs(2.0f * dc - dd) - e_barrier.y; 
    66         dd = step(dd, 0); 
     66        dd = step(dd, 0.0f); 
     67 
    6768        float de = saturate(dot(dd, e_weights.y)); 
    6869 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2865 r2866  
    104104                        (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 
    105105 
    106                 // if surface normal perpenticular to view dir, the samples count less => compensate for this 
     106                // if surface normal perpenticular to view dir, some samples probably count less  
     107                // => compensate for this 
    107108                float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 
    108109 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2865 r2866  
    7575        pixel pix; 
    7676 
     77        // save color in first render target 
    7778        pix.col = (ambient + diffuse) * tex2D(tex, IN.texCoord.xy); 
     79        // save world position in second rt 
    7880        pix.pos = IN.worldPos * maxDepth; 
     81        // save normal in third rt 
    7982        pix.norm.xyz = IN.normal * 0.5f + 0.5f; 
    8083 
    8184        // hack: squeeze some information about ambient into the texture 
    8285        pix.norm.w = ambient.x; 
    83         // hack: store projection coordinate for scaling ssao 
     86        // store projection coordinates with positions (used for ssao) 
    8487        pix.pos.w = IN.projPos.w; 
    8588 
Note: See TracChangeset for help on using the changeset viewer.