Changeset 3018 for GTP/trunk


Ignore:
Timestamp:
10/09/08 11:48:06 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
4 edited

Legend:

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

    r3017 r3018  
    898898        cgGLSetParameter3f(sLightDirParam, lightDir.x, lightDir.y, lightDir.z); 
    899899 
    900  
    901         glColor3f(1.0f, 1.0f, 1.0f); 
    902  
     900        Vector3 tl, tr, bl, br; 
     901        ComputeViewVectors(tl, tr, bl, br); 
     902         
     903        // note: slightly larger texture could hide ambient occlusion error on border but costs resolution 
    903904        const float offs = 0.5f; 
    904  
     905         
    905906        glBegin(GL_QUADS); 
    906907 
    907         glTexCoord2f(0, 0); glVertex3f(-offs, -offs, -0.5f); 
    908         glTexCoord2f(1, 0); glVertex3f( offs, -offs, -0.5f); 
    909         glTexCoord2f(1, 1); glVertex3f( offs,  offs, -0.5f); 
    910         glTexCoord2f(0, 1); glVertex3f(-offs,  offs, -0.5f); 
     908        glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-offs, -offs, -0.5f); 
     909        glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( offs, -offs, -0.5f); 
     910        glTexCoord2f(1, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tr.x, tr.y, tr.z); glVertex3f( offs,  offs, -0.5f); 
     911        glTexCoord2f(0, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tl.x, tl.y, tl.z); glVertex3f(-offs,  offs, -0.5f); 
    911912 
    912913        glEnd(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3017 r3018  
    273273static CGparameter sEyePosParam; 
    274274 
    275 static CGparameter sTLParam; 
    276 static CGparameter sTRParam; 
    277 static CGparameter sBRParam; 
    278 static CGparameter sBLParam; 
    279  
    280 static CGparameter sTLParamTex; 
    281 static CGparameter sTRParamTex; 
    282 static CGparameter sBRParamTex; 
    283 static CGparameter sBLParamTex; 
    284  
    285275static Matrix4x4 viewProjMat = IdentityMatrix(); 
    286276static Matrix4x4 oldViewProjMat = IdentityMatrix(); 
     
    566556                sEyePosParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "eyePos"); 
    567557                RenderState::sTexParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tex"); 
    568          
    569                 sTLParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tl");  
    570                 sTRParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tr");  
    571                 sBRParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "br");  
    572                 sBLParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "bl");  
    573558        } 
    574559        else 
     
    588573 
    589574                sEyePosParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "eyePos"); 
    590                  
    591                 sTLParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "tl");  
    592                 sTRParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "tr");  
    593                 sBRParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "br");  
    594                 sBLParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "bl");  
    595575        } 
    596576        else 
     
    939919        cgGLSetParameter3f(sEyePosParamTex, pos.x, pos.y, pos.z); 
    940920 
    941         Vector3 tl, tr, bl, br; 
    942         ComputeViewVectors(tl, tr, bl, br); 
    943  
    944         cgGLSetParameter3f(sBLParam, bl.x, bl.y, bl.z); 
    945         cgGLSetParameter3f(sBRParam, br.x, br.y, br.z); 
    946         cgGLSetParameter3f(sTLParam, tl.x, tl.y, tl.z); 
    947         cgGLSetParameter3f(sTRParam, tr.x, tr.y, tr.z); 
    948  
    949         //cout<<bl << " " << br << endl; 
    950         cgGLSetParameter3f(sBLParamTex, bl.x, bl.y, bl.z); 
    951         cgGLSetParameter3f(sBRParamTex, br.x, br.y, br.z); 
    952         cgGLSetParameter3f(sTLParamTex, tl.x, tl.y, tl.z); 
    953         cgGLSetParameter3f(sTRParamTex, tr.x, tr.y, tr.z); 
    954  
    955921 
    956922        // draw to 3 color buffers 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3017 r3018  
    7878         
    7979        OUT.color = col; 
    80         OUT.color.w = color.w; 
     80 
     81        // store scaled view vector from now on so wie don't have to normalize for e.g., ssao 
     82        float3 viewDir = IN.view; 
     83        const float lenView = length(viewDir); 
     84 
     85        OUT.color.w = color.w / lenView; 
    8186 
    8287        return OUT; 
     
    160165        /// reconstruct position from the eye space depth 
    161166        float3 viewDir = IN.view; 
     167        const float lenView = length(viewDir); 
     168        viewDir /= lenView; 
     169 
    162170        const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 
    163171 
     
    195203        OUT.color = useShading ? (ambient + diffuse) * color : color; 
    196204 
    197         OUT.color.w = color.w; 
     205        // store scaled view vector from now on so wie don't have to normalize for e.g., ssao 
     206        OUT.color.w = color.w / lenView; 
    198207 
    199208        return OUT; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r3017 r3018  
    1717  float4 worldPos: TEXCOORD1; // world position 
    1818  float3 normal: TEXCOORD2; 
    19   float4 projPos: TEXCOORD3; 
    2019}; 
    2120 
     
    3130        float4 worldPos: TEXCOORD1; // world position 
    3231        float3 normal: TEXCOORD2; 
    33         float4 projPos: TEXCOORD3; 
    3432}; 
    3533 
     
    5957 
    6058        OUT.normal = IN.normal; 
    61         OUT.projPos = OUT.position; 
    6259 
    6360        return OUT; 
     
    104101 
    105102        // compute eye linear depth 
    106         const float4 projPos = IN.projPos / IN.projPos.w; 
    107          
    108         float2 screenCoord = projPos.xy * 0.5f + 0.5f; 
    109          
    110         const float3 viewVec = Interpol(screenCoord, bl, br, tl, tr); 
    111         const float invMagView = 1.0f / length(viewVec); 
    112         // note: has to done in this order, otherwise strange precision problems! 
    113         pix.col.w = invMagView * length(eyePos - IN.worldPos.xyz); 
     103        pix.col.w = length(eyePos - IN.worldPos.xyz); 
    114104 
    115105        return pix; 
     
    133123        // hack: squeeze some information about the ambient term into the target 
    134124        //pix.col.w = glstate.material.emission.x; 
    135          
    136         // compute eye linear depth and scale with lenght to avoid sqr root in pixel shader 
    137         const float4 projPos = IN.projPos / IN.projPos.w; 
    138          
    139         float2 screenCoord = projPos.xy * 0.5f + 0.5f; 
    140         const float magView = length(Interpol(screenCoord, bl, br, tl, tr)); 
    141         pix.col.w = length(eyePos - IN.worldPos.xyz) / magView; 
     125        pix.col.w = length(eyePos - IN.worldPos.xyz); 
    142126 
    143127        return pix; 
Note: See TracChangeset for help on using the changeset viewer.