Changeset 2988


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

eye linear depth not working

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

Legend:

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

    r2986 r2988  
    162162        const Vector3 fc = pos + view * z_far;  
    163163         
    164         cout << "fovx: " << 0.5f * mFovy * aspectRatio << " " << mFovy * 0.5f << endl; 
    165  
    166164        Vector3 t1, t2; 
    167165 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r2987 r2988  
    357357                sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples"); 
    358358 
    359                 sTLParam = cgGetNamedParameter(sCgSsaoProgram, "bl");  
    360                 sTRParam = cgGetNamedParameter(sCgSsaoProgram, "br");  
    361                 sBRParam = cgGetNamedParameter(sCgSsaoProgram, "tl");  
    362                 sBLParam = cgGetNamedParameter(sCgSsaoProgram, "tr");  
     359                sTLParam = cgGetNamedParameter(sCgSsaoProgram, "tl");  
     360                sTRParam = cgGetNamedParameter(sCgSsaoProgram, "tr");  
     361                sBRParam = cgGetNamedParameter(sCgSsaoProgram, "br");  
     362                sBLParam = cgGetNamedParameter(sCgSsaoProgram, "bl");  
    363363        } 
    364364        else 
     
    676676        cgGLSetParameter1f(sMaxDepthParam, mScaleFactor); 
    677677 
    678         Vector3 pos = mCamera->GetPosition(); 
     678        Vector3 pos = mCamera->GetPosition() / mScaleFactor; 
    679679        cgGLSetParameter3f(sEyePosParam, pos.x, pos.y, pos.z); 
    680680         
     
    700700        ComputeViewVectors(tl, tr, bl, br); 
    701701 
    702         cgGLSetParameter3f(sTLParam, tl.x, tl.y, tl.z); 
    703702        cgGLSetParameter3f(sBLParam, bl.x, bl.y, bl.z); 
    704703        cgGLSetParameter3f(sBRParam, br.x, br.y, br.z); 
     704        cgGLSetParameter3f(sTLParam, tl.x, tl.y, tl.z); 
    705705        cgGLSetParameter3f(sTRParam, tr.x, tr.y, tr.z); 
    706706 
     
    730730} 
    731731 
    732 Vector3 RotateY(Vector3 v, float a) 
    733 { 
    734         Vector3 r; 
    735  
    736         r.z = v.z * cos(a) - v.x * sin(a); 
    737         r.x = v.z * sin(a) + v.x * cos(a); 
    738         r.y = v.y; 
    739  
    740         return r; 
    741 } 
    742  
    743  
    744 Vector3 RotateX(Vector3 v, float a) 
    745 { 
    746         Vector3 r; 
    747  
    748         r.y = v.y * cos(a) - v.z * sin(a); 
    749         r.z = v.y * sin(a) + v.z * cos(a); 
    750         r.x = v.x; 
    751  
    752         return r; 
    753 } 
    754  
    755  
    756 Vector3 RotateZ(Vector3 v, float a) 
    757 { 
    758         Vector3 r; 
    759  
    760         r.x = v.x * cos(a) - v.y * sin(a); 
    761         r.y = v.x * sin(a) + v.y * cos(a); 
    762         r.z = v.z; 
    763  
    764         return r; 
    765 } 
    766  
    767732 
    768733Vector3 Interpol(float wx, float wy, Vector3 bl, Vector3 br, Vector3 tl, Vector3 tr) 
     
    788753        tl = Normalize(ntl - ftl); 
    789754        tr = Normalize(ntr - ftr); 
    790  
    791  
    792         Vector3 dummy = Normalize(Interpol(0, 0, bl, br, tl, tr)); 
    793         Vector3 dummy2 = Normalize(Interpol(0.5f, 0.5f, bl, br, tl, tr)); 
    794  
    795         cout << "here3: " << dummy2 << " " << -mCamera->GetDirection() << endl; 
    796755} 
    797756 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2986 r2988  
    8383        OUT.color = col; 
    8484 
    85         OUT.color.xyz = color.w / 1e3f; 
     85        OUT.color.xyz = color.w; 
    8686         
    8787#if 1 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2984 r2988  
    9595        // hack: squeeze some information about ambient into the texture 
    9696        //pix.col.w = glstate.material.emission.x; 
    97         pix.col.w = length(currentPos - IN.worldPos); 
     97        pix.col.w = length((currentPos - IN.worldPos) * maxDepth); 
    9898 
    9999        return pix; 
     
    118118        // hack: squeeze some information about the ambient term into the target 
    119119        //pix.col.w = glstate.material.emission.x; 
    120         pix.col.w = length(currentPos - IN.worldPos); 
     120        pix.col.w = length((currentPos - IN.worldPos) * maxDepth); 
    121121 
    122122        return pix; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2987 r2988  
    5555} 
    5656 
     57 
    5758float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 
    5859{ 
    5960        //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 
    60         float3 x1 = bl * (1.0f - w.x) + br * w.x; 
    61         float3 x2 = tl * (1.0f - w.x) + tr * w.x; 
    62  
    63         float3 v = x1 * (1.0f - w.y) + x2 * w.y; 
     61        float3 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x; 
     62        float3 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x; 
     63 
     64        float3 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y; 
    6465 
    6566        return v; 
    6667} 
     68 
     69 
     70float2 Interpol2(float2 w, float2 bl, float2 br, float2 tl, float2 tr) 
     71{ 
     72        //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 
     73        float2 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x; 
     74        float2 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x; 
     75 
     76        float2 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y; 
     77 
     78        return v; 
     79} 
     80 
    6781 
    6882/** The ssao shader returning the an intensity value between 0 and 1 
     
    8195                   uniform float3 br, 
    8296                   uniform float3 tl, 
    83                    uniform float3 tr, 
    84                    uniform float maxDepth 
     97                   uniform float3 tr 
    8598                   ) 
    8699{ 
     
    92105        float numSamples = 0; 
    93106 
    94         const float y_angle = 0.43633231299858239423092269212215; 
    95         const float x_angle = 0.58177641733144319230789692282954; 
    96107 
    97108        for (int i = 0; i < NUM_SAMPLES; ++ i)  
     
    117128                float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 
    118129 
    119                 float newOffs = 0.5f + offsetTransformed * 0.5f; 
     130                float2 newOffs = 0.5f + offsetTransformed * 0.5f; 
    120131 
    121132                float3 rotView = normalize(Interpol(newOffs, bl, br, tl, tr)); 
    122                 float3 sample_position = (eyePos - rotView * eyeSpaceDepth) / maxDepth; 
     133                float3 sample_position = eyePos - rotView * eyeSpaceDepth; 
    123134                //float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 
    124135 
     
    180191        // the current world position 
    181192        const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 
    182         // the current color 
     193 
     194        const float eyeDepth = tex2D(colors, IN.texCoord.xy).w; 
     195        float3 view2 = normalize(Interpol(IN.texCoord.xy, bl, br, tl, tr)); 
     196         
     197        float4 centerPosition2; 
     198        centerPosition2.xyz = eyePos - view2 * eyeDepth; 
     199        // the current depth 
    183200        const float currentDepth = centerPosition.w; 
    184201 
     
    186203        float3 viewDir = normalize(IN.view); 
    187204 
    188 /*      const float eyeSpaceDepth = tex2D(colors, IN.texCoord.xy).w; 
    189  
    190         float3 sample_position = eyePos - viewDir * eyeSpaceDepth;  
    191  
    192         OUT.illum_col.xyz = centerPosition.xyz * maxDepth -  sample_position; 
    193         OUT.illum_col.w = currentDepth; 
    194         return OUT; 
    195 */ 
    196205        //const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 
    197         const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos, positions, 
    198                 bl, br, tl, tr, maxDepth); 
     206        const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition2, w, viewDir, eyePos, positions, 
     207                bl, br, tl, tr); 
    199208                 
    200209 
Note: See TracChangeset for help on using the changeset viewer.