Changeset 2871


Ignore:
Timestamp:
08/26/08 20:45:40 (16 years ago)
Author:
mattausch
Message:

working with 50 frames

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

Legend:

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

    r2869 r2871  
    8787        // the diffuse color buffer 
    8888        mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
     89        mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    8990         
    9091        mOldFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    9192        // the diffuse color buffer 
     93        mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    9294        mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    9395         
     
    140142 
    141143 
    142         sCgCombineProgram =  
     144        /*sCgCombineProgram =  
    143145                cgCreateProgramFromFile(context,  
    144146                                                                CG_SOURCE, 
     
    158160        else 
    159161                cerr << "combined program failed to load" << endl; 
    160  
     162*/ 
    161163 
    162164        /////////////// 
     
    257259        FirstPass(fbo); 
    258260        ComputeSsao(fbo, expFactor); 
    259         Combine(fbo); 
     261        //Combine(fbo); 
    260262        AntiAliasing(fbo); 
    261263 
     
    291293        // read the second buffer, write to the first buffer 
    292294        mNewFbo->Bind(); 
    293         glDrawBuffers(1, mymrt); 
     295        glDrawBuffers(2, mymrt); 
    294296 
    295297        GLuint oldTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
     
    443445void SsaoShader::AntiAliasing(FrameBufferObject *fbo) 
    444446{ 
    445         GLuint colorsTex = mFbo4->GetColorBuffer(0)->GetTexture(); 
    446         //GLuint colorsTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
     447        //GLuint colorsTex = mFbo4->GetColorBuffer(0)->GetTexture(); 
     448        GLuint colorsTex = mNewFbo->GetColorBuffer(1)->GetTexture(); 
    447449        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    448450         
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2870 r2871  
    2727struct pixel 
    2828{ 
    29         float4 color: COLOR0; 
     29        float4 illum_col: COLOR0; 
     30        float4 combined_col: COLOR1; 
    3031}; 
    3132 
     
    3334float2 reflect(float2 pt, float2 n) 
    3435{ 
    35   // distance to plane 
    36   float d = dot(n, pt); 
    37   // reflect around plane 
    38   float2 rpt = pt - d * 2.0f * n; 
    39  
    40   return rpt; 
    41 } 
    42  
    43  
    44 float2 rotate(float2 pt, float2 n) 
     36        // distance to plane 
     37        float d = dot(n, pt); 
     38        // reflect around plane 
     39        float2 rpt = pt - d * 2.0f * n; 
     40        return rpt; 
     41} 
     42 
     43 
     44/*float2 rotate(float2 pt, float2 n) 
    4545{ 
    4646        float2 ptTransformed; 
     
    4949 
    5050        return ptTransformed; 
    51 } 
     51}*/ 
    5252 
    5353 
     
    121121/** Computes ambient occlusion + diffuse reflections 
    122122*/ 
     123/* 
    123124float4 globIllum(fragment IN, 
    124125                                 uniform sampler2D colors, 
     
    149150 
    150151                //sample noisetex; r stores costheta, g stores sintheta 
    151                 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 
     152                float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 
    152153 
    153154                // rotation 
     
    157158                float2 texcoord = IN.texCoord.xy + offsetTransformed * AREA_SIZE * w; 
    158159 
    159                 float3 sample_position = tex2D(positions, texcoord).xyz; 
    160                 float3 sample_color = tex2D(colors, texcoord).xyz; 
     160                float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz; 
     161                float3 sample_color = tex2D(colors, float4(texcoord, 0, 1)).xyz; 
    161162 
    162163                float3 vector_to_sample = sample_position - centerPosition.xyz; 
     
    176177 
    177178                total_ao += cos_angle * distance_intensity * view_correction; 
    178                 total_color += cos_angle * distance_intensity * view_correction * sample_color * 0.3f; 
     179                float scale_factor = 0.3f; 
     180                total_color += cos_angle * distance_intensity * view_correction * sample_color * scale_factor; 
    179181        } 
    180182 
    181183        return float4(total_color, 1.0f - total_ao); 
    182184} 
    183  
     185*/ 
    184186 
    185187/** The mrt shader for screen space ambient occlusion 
     
    200202        pixel OUT; 
    201203 
    202         float4 normal = tex2D(normals, IN.texCoord.xy); 
     204        float4 norm = tex2D(normals, IN.texCoord.xy); 
    203205         
    204206        // the ambient term 
    205         float amb = normal.w; 
     207        const float amb = norm.w; 
    206208 
    207209        // expand normal 
    208         normal = normalize(normal);// * 2.0f - 1.0f); 
     210        float3 normal = normalize(norm.xyz);// * 2.0f - 1.0f); 
    209211        /// the current view direction 
    210212        float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f)); 
    211213 
    212214        // the current world position 
    213         float4 centerPosition = tex2D(positions, IN.texCoord.xy); 
     215        const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 
    214216         
    215217        // the current color 
    216         float4 currentCol = tex2D(colors, IN.texCoord.xy); 
    217         float currentDepth = currentCol.w; 
    218  
    219         float ao = ssao(IN, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 
    220  
    221         //float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition);  
     218        const float4 currentCol = tex2D(colors, IN.texCoord.xy); 
     219        const float currentDepth = currentCol.w; 
     220 
     221        float4 new_col = (float4)ssao(IN, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition); 
     222        //float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition);  
    222223         
    223         // compute temporally smoothed color 
     224 
     225        ///////////////// 
     226        //-- compute temporally smoothed value 
     227 
    224228        float4 realPos = centerPosition * maxDepth; 
    225229        realPos.w = 1.0f; 
     
    227231        float4 oldPos = mul(oldModelViewProj, realPos); 
    228232 
    229         float newDepth = oldPos.z / oldPos.w; 
     233        const float newDepth = oldPos.z / oldPos.w; 
    230234 
    231235        float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f; 
    232236        float4 oldCol = tex2D(oldTex, tex); 
    233237 
    234         float oldDepth = oldCol.w; 
    235         float depthDif = 1.0f - newDepth / oldDepth; 
     238        const float oldDepth = oldCol.w; 
     239        const float depthDif = 1.0f - newDepth / oldDepth; 
    236240 
    237241        if ((tex.x >= 0.0f) && (tex.x < 1.0f) &&  
     
    239243                (abs(depthDif)  < 1e-4f)) 
    240244        { 
    241                 OUT.color = float4(ao * expFactor + oldCol * float4(1.0f - expFactor)); 
     245                OUT.illum_col = new_col * expFactor + oldCol * float4(1.0f - expFactor); 
    242246        } 
    243247        else 
    244248        { 
    245                 OUT.color = (float4)ao; 
    246         } 
    247  
    248  
    249         //OUT.color.xyz = viewDir; 
    250         //OUT.color = attenuated_color; 
    251          
    252         OUT.color.w = currentDepth; 
     249                OUT.illum_col = new_col; 
     250        } 
     251 
     252 
     253        OUT.combined_col = currentCol * OUT.illum_col; 
     254 
     255        OUT.illum_col.w = currentDepth; 
    253256 
    254257        return OUT; 
    255258} 
    256259 
    257  
     260/* 
    258261pixel combined(fragment IN,  
    259262                           uniform sampler2D colors, 
     
    265268        float4 col = tex2D(colors, IN.texCoord.xy); 
    266269        float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 
    267  
    268         OUT.color = float4(1,0,0,0); 
    269         OUT.color = col * ao; 
     270        //float4 illum = tex2D(ssaoTex, IN.texCoord.xy); 
     271 
     272        OUT.illum_col = col * ao; 
    270273 
    271274        return OUT; 
    272 } 
     275}*/ 
Note: See TracChangeset for help on using the changeset viewer.