Changeset 2986


Ignore:
Timestamp:
10/01/08 16:44:23 (16 years ago)
Author:
mattausch
Message:

debug version trying to retrieve position from linear eye space depth

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

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r2982 r2986  
    1010winHeight=768 
    1111camPosition=483.398f 242.364f 186.078f 
    12 camDirection=1 0 0 
     12#camDirection=1 0 0 
    1313lightDirection=-0.8f 1.0f -0.7f 
    1414#lightDirection=0.0f 0.0f -1.0f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp

    r2947 r2986  
    8080 
    8181 
    82 void Camera::GetProjectionMatrix(Matrix4x4 &mat) 
     82void Camera::GetProjectionMatrix(Matrix4x4 &mat) const 
    8383{ 
    8484        glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat.x); 
     
    8686 
    8787 
    88 void Camera::GetModelViewMatrix(Matrix4x4 &mat) 
     88void Camera::GetModelViewMatrix(Matrix4x4 &mat) const 
    8989{ 
    9090        mat = mViewOrientation; 
     
    9797 
    9898 
     99void Camera::GetViewOrientationMatrix(Matrix4x4 &mat) const 
     100{ 
     101        mat = mViewOrientation; 
     102} 
     103 
     104 
    99105void Camera::CalcFrustum(Frustum &frustum) 
    100106{ 
     
    132138        glLoadMatrixf((float *)m.x); 
    133139} 
     140 
    134141 
    135142 
     
    155162        const Vector3 fc = pos + view * z_far;  
    156163         
     164        cout << "fovx: " << 0.5f * mFovy * aspectRatio << " " << mFovy * 0.5f << endl; 
     165 
    157166        Vector3 t1, t2; 
    158167 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h

    r2947 r2986  
    7272        /** Returns the current projection matrix. 
    7373        */ 
    74         void GetProjectionMatrix(Matrix4x4 &mat); 
     74        void GetProjectionMatrix(Matrix4x4 &mat) const; 
    7575        /** Returns the current model view matrix. 
    7676        */ 
    77         void GetModelViewMatrix(Matrix4x4 &mat); 
     77        void GetModelViewMatrix(Matrix4x4 &mat) const; 
     78 
     79        void GetViewOrientationMatrix(Matrix4x4 &mat) const; 
    7880        /** Calculates a frustum from the projection and the modelview matrix. 
    7981        */ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r2985 r2986  
    715715} 
    716716 
     717Vector3 RotateY(Vector3 v, float a) 
     718{ 
     719        Vector3 r; 
     720 
     721        r.z = v.z * cos(a) - v.x * sin(a); 
     722        r.x = v.z * sin(a) + v.x * cos(a); 
     723        r.y = v.y; 
     724 
     725        return r; 
     726} 
     727 
     728 
     729Vector3 RotateX(Vector3 v, float a) 
     730{ 
     731        Vector3 r; 
     732 
     733        r.y = v.y * cos(a) - v.z * sin(a); 
     734        r.z = v.y * sin(a) + v.z * cos(a); 
     735        r.x = v.x; 
     736 
     737        return r; 
     738} 
     739 
     740 
     741Vector3 RotateZ(Vector3 v, float a) 
     742{ 
     743        Vector3 r; 
     744 
     745        r.x = v.x * cos(a) - v.y * sin(a); 
     746        r.y = v.x * sin(a) + v.y * cos(a); 
     747        r.z = v.z; 
     748 
     749        return r; 
     750} 
    717751 
    718752void DeferredRenderer::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br) 
     
    726760        tl = Normalize(ntl - ftl); 
    727761        tr = Normalize(ntr - ftr); 
     762 
     763        const float y_angle = 0.43633231299858239423092269212215; 
     764        const float x_angle = 0.58177641733144319230789692282954; 
     765 
     766        const Vector3 view = mCamera->GetBaseDirection(); 
     767 
     768        Vector3 rotView1 = RotateZ(-view, x_angle); 
     769        Vector3 rotView = RotateX(rotView1, y_angle); 
     770 
     771        cout << "view: " << -view << endl; 
     772        Matrix4x4 mat; 
     773         
     774        mCamera->GetViewOrientationMatrix(mat); 
     775        rotView = mat * rotView; 
     776 
     777        cout << "x: " << rotView1 << " y: " << rotView << " " << tr << endl; 
     778 
     779        cout << "x: " << Magnitude(rotView1) << " y: " << Magnitude(rotView) << endl; 
     780        cout << "here3: " << acos(DotProd(rotView1, -view)) << " " << acos(DotProd(rotView, rotView1)) << endl; 
    728781} 
    729782 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2985 r2986  
    8383        OUT.color = col; 
    8484 
    85 OUT.color.w = color.w; 
    86  
     85        OUT.color.xyz = color.w / 1e3f; 
     86         
     87#if 1 
     88 
     89        OUT.color.w = color.w; 
     90 
     91#else 
    8792 
    8893        //////////// 
    8994        //-- write out logaritmic luminance for tone mapping 
    90 /* 
     95 
    9196        float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)); 
    9297 
     
    103108        else 
    104109                OUT.color.w = logLumScaled; 
    105 */ 
     110 
     111#endif 
     112 
    106113        return OUT; 
    107114} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2985 r2986  
    3232 
    3333 
     34float3 RotateY(float3 v, float a) 
     35{ 
     36        float3 r; 
     37 
     38        r.z = v.z * cos(a) - v.x * sin(a); 
     39        r.x = v.z * sin(a) + v.x * cos(a); 
     40        r.y = v.y; 
     41 
     42        return r; 
     43} 
     44 
     45 
     46float3 RotateX(float3 v, float a) 
     47{ 
     48        float3 r; 
     49 
     50        r.y = v.y * cos(a) - v.z * sin(a); 
     51        r.z = v.y * sin(a) + v.z * cos(a); 
     52        r.x = v.x; 
     53 
     54        return r; 
     55} 
    3456 
    3557/** The ssao shader returning the an intensity value between 0 and 1 
     
    4365                   uniform float scaleFactor, 
    4466                   uniform float3 viewDir, 
    45                    uniform float3 eyePos 
     67                   uniform float3 eyePos, 
     68                   uniform sampler2D positions, 
     69                   uniform float3 bl, 
     70                   uniform float3 br, 
     71                   uniform float3 tl, 
     72                   uniform float3 tr 
    4673                   ) 
    4774{ 
     
    5279        float total_ao = 0.0; 
    5380        float numSamples = 0; 
     81 
     82        const float y_angle = 0.43633231299858239423092269212215; 
     83        const float x_angle = 0.58177641733144319230789692282954; 
    5484 
    5585        for (int i = 0; i < NUM_SAMPLES; ++ i)  
     
    75105                float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 
    76106 
    77                 float3 sample_position = eyePos - viewDir * eyeSpaceDepth;  
    78                  
     107                float rotx = offsetTransformed.x * -x_angle; 
     108                float roty = offsetTransformed.y * -y_angle; 
     109 
     110                float3 rotView_x = RotateY(viewDir, x_angle); 
     111                float3 rotView = RotateX(rotView_x, y_angle); 
     112 
     113                float3 sample_position = eyePos - rotView * eyeSpaceDepth; 
     114                //float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 
    79115 
    80116                float3 vector_to_sample = sample_position - centerPosition.xyz; 
     
    117153                   uniform float maxDepth, 
    118154                   uniform float temporalCoherence, 
    119                    uniform float3 eyePos 
     155                   uniform float3 eyePos, 
     156                   uniform float3 bl, 
     157                   uniform float3 br, 
     158                   uniform float3 tl, 
     159                   uniform float3 tr 
    120160                   ) 
    121161{ 
     
    137177        float3 viewDir = normalize(IN.view); 
    138178 
    139         const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 
     179        /*const float eyeSpaceDepth = tex2D(colors, IN.texCoord.xy).w; 
     180 
     181        float3 sample_position = eyePos - viewDir * eyeSpaceDepth;  
     182 
     183        OUT.illum_col.xyz = centerPosition.xyz - sample_position; 
     184        OUT.illum_col.w = currentDepth; 
     185        return OUT;*/ 
     186 
     187        //const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 
     188        const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos, positions, 
     189                uniform float3 bl, 
     190                uniform float3 br, 
     191                uniform float3 tl, 
     192                uniform float3 tr); 
    140193                 
    141194 
     
    206259        float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 
    207260 
    208         OUT.illum_col = col * ao.x; 
    209         //OUT.illum_col.w = ao.w; 
     261        //OUT.illum_col = col * ao.x; 
     262        OUT.illum_col = float4(ao.x,ao.x,ao.x, ao.w); 
    210263        OUT.illum_col.w = col.w; 
    211264 
Note: See TracChangeset for help on using the changeset viewer.