Changeset 3195


Ignore:
Timestamp:
11/29/08 18:24:53 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
7 edited

Legend:

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

    r3193 r3195  
    175175                ambient.x = ambient.y = ambient.z = 0.2f; 
    176176                //diffuse.x = 0.7f; diffuse.y = 0.4f; diffuse.z = 0.2f; 
    177                 diffuse.x = 0.8f; diffuse.y = 0.8f; diffuse.z = 0.4f; 
     177                diffuse.x = 0.4f; diffuse.y = 0.6f; diffuse.z = 0.6f; 
    178178                //diffuse.x = diffuse.y = diffuse.z = 1.0f; 
    179179                spec.x = spec.y = spec.z = .0f; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3194 r3195  
    544544        // multisampling is difficult / costly with deferred shading 
    545545        // at least do some edge blurring  
    546         if (useAntiAliasing) AntiAliasing(fbo, light);// else  
     546        if (useAntiAliasing) AntiAliasing(fbo, light); else  
    547547        Output(fbo); // just output the latest buffer 
    548548 
     
    729729 
    730730        // read the second buffer, write to the first buffer 
    731         FlipFbos(fbo); 
     731        //FlipFbos(fbo); 
    732732        // end of the pipeline => just draw image to screen 
    733         //FrameBufferObject::Release(); 
     733        FrameBufferObject::Release(); 
    734734 
    735735        // the neighbouring texels 
     
    954954        whiteLum = log(WHITE_LUMINANCE); 
    955955         
    956  
    957956        //////////////////// 
    958957        //-- linear interpolate brightness key depending on the current sun position 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3194 r3195  
    77 
    88//#define NUM_SAMPLES 8 
    9 #define NUM_SAMPLES 16 
    10 //#define NUM_SAMPLES 24 
     9//#define NUM_SAMPLES 16 
     10#define NUM_SAMPLES 24 
    1111 
    1212// for quadratic falloff 
    13 //#define SAMPLE_INTENSITY 0.5f 
    14 #define SAMPLE_INTENSITY 0.5f 
     13//#define SAMPLE_INTENSITY 0.9f 
     14#define SAMPLE_INTENSITY 2.0f 
    1515 
    1616//#define SAMPLE_INTENSITY 0.075f 
    1717//#define SAMPLE_INTENSITY 0.2f 
    1818 
    19 //#define SAMPLE_RADIUS 8e-1f 
    2019#define SAMPLE_RADIUS 8e-1f 
     20//#define SAMPLE_RADIUS 15e-1f 
    2121 
    2222//#define DISTANCE_SCALE 1e-1f 
     
    3030//#define NUM_SSAO_FILTERSAMPLES 80 
    3131#define NUM_SSAO_FILTER_SAMPLES 16 
    32 #define NUM_SSAO_FILTER_WIDTH 12.0f 
    33 #define SSAO_CONVERGENCE_WEIGHT 200.0f 
     32#define SSAO_FILTER_WIDTH 12.0f 
     33#define SSAO_CONVERGENCE_WEIGHT 300.0f 
    3434 
    3535 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3193 r3195  
    6868                normalFactor = max(dot(sampleNorm, centerNormal), 1e-3f); 
    6969                //convergenceFactor = min(100.0f, aoSample.y); 
    70                 convergenceFactor = aoSample.y; 
     70                convergenceFactor = aoSample.y + 1.0f; 
    7171 
    7272                // combine the weights 
     
    133133                //samplePos = ReconstructSamplePos(ssaoTex, sampleTexCoord.xy, bl, br, tl, tr); 
    134134 
    135                 len = min(SqrLen(centerPos - samplePos), 1e3f); 
     135                len = min(SqrLen(centerPos - samplePos), 1e2f); 
    136136 
    137137                spatialFactor = 1.0f / max(len, 1e-3f); 
    138138 
    139                 normalFactor = max(step(.01f, dot(sampleNorm, centerNormal)), 1e-3f); 
     139                //normalFactor = max(step(.0f, dot(sampleNorm, centerNormal)), 1e-2f); 
    140140                //normalFactor = max(dot(sampleNorm, samplePos), 1e-3f); 
    141                 convergenceFactor = min(convergenceThresh, aoSample.y + 1); 
     141                convergenceFactor = aoSample.y + 1.0f; 
     142                //convergenceFactor = max(step(0.5f + NUM_SAMPLES, aoSample.y), 1e-2f); 
    142143                //convergenceFactor = aoSample.y; 
    143144 
    144145                // combine the weights 
    145                 w = convergenceFactor * spatialFactor * normalFactor; 
     146                w = convergenceFactor * convergenceFactor * spatialFactor;// * normalFactor; 
    146147                //w = spatialFactor * normalFactor; 
    147148 
     
    177178        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    178179 
     180        float4 dummy; 
     181        const float xoffs = .5f / 1024.0f; 
     182        const float yoffs = .5f / 768.0f; 
     183 
     184        dummy.x = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).y; 
     185        dummy.y = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).y; 
     186        dummy.z = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).y; 
     187        dummy.w = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, -yoffs), 0, 0)).y; 
     188 
     189        const float convergence = min(min(dummy.x, dummy.y), min(dummy.z, dummy.w)); 
     190        //const float convergence = max(max(dummy.x, dummy.y), max(dummy.z, dummy.w)); 
     191        //const float convergence = ao.y; 
     192 
     193        // filter reaches size 1 after thres samples 
     194        const float thres = 500.0f;  
     195 
    179196        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    180         if ((ao.y < 500.0f) && (col.w < 1e10f)) 
     197        if ((convergence < thres) && (col.w < 1e10f)) 
    181198        //if (col.w < 1e10f) 
    182199        { 
     
    185202                const float distanceScale = 1.0f; 
    186203 
    187                 const float convergence = ao.y + 1; 
    188                 const float convergenceScale = SSAO_CONVERGENCE_WEIGHT / (convergence + SSAO_CONVERGENCE_WEIGHT); 
    189  
    190                 const float scale = NUM_SSAO_FILTER_WIDTH * convergenceScale * distanceScale; 
     204                const float convergenceWeight = thres / (SSAO_FILTER_WIDTH - 1.0f); 
     205                const float convergenceScale = convergenceWeight / (convergence + convergenceWeight); 
     206 
     207                const float scale = SSAO_FILTER_WIDTH * convergenceScale * distanceScale; 
    191208 
    192209                // the filtered ssao value 
     
    199216                OUT.illum_col.xyz = col.xyz; 
    200217 
    201         //OUT.illum_col.xyz = float3(ao.x, ao.x, ao.x); 
    202         //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-2f, 0, 1), 1); 
     218        OUT.illum_col.xyz = float3(ao.x, ao.x, ao.x); 
     219        //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-3f, 0, 1), 1); 
     220        //OUT.illum_col.xyz = float3(0, 1.0f - step(0.5f + NUM_SAMPLES, convergence), 1); 
    203221        OUT.illum_col.w = col.w; 
    204222 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3193 r3195  
    6464        OUT.color = col; 
    6565        // store scaled view vector so wie don't have to normalize for e.g., ssao 
    66         OUT.color.w = color.w;// / length(IN.view); 
    67         //OUT.color = color; 
     66        //OUT.color.w = color.w / length(IN.view); 
     67        OUT.color.w = color.w; 
     68 
    6869        return OUT; 
    6970} 
     
    164165 
    165166                float shadowTerm = CalcShadowTerm(IN, shadowMap, sampleWidth, lightSpacePos.xy, lightSpacePos.z, samples, weights, noiseTex); 
    166          
    167167                diffuse *= shadowTerm; 
    168168        } 
     
    296296        pixel pix; 
    297297 
    298         const float3 normal = normalize(tex2Dlod(normalsTex, float4(IN.texCoord, 0 ,0)).xyz); 
     298        //const float3 normal = normalize(tex2Dlod(normalsTex, float4(IN.texCoord, 0 ,0)).xyz); 
     299        const float3 normal = tex2Dlod(normalsTex, float4(IN.texCoord, 0 ,0)).xyz; 
    299300        const float3 difVec = tex2Dlod(diffVals, float4(IN.texCoord, 0 ,0)).xyz; 
    300301 
     
    302303        float4 color = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)); 
    303304 
     305         
     306        float4 dummy; 
     307        const float xoffs = .5f / 1024.0f; 
     308        const float yoffs = .5f / 768.0f; 
     309 
     310        dummy.x = tex2Dlod(colorsTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).w; 
     311        dummy.y = tex2Dlod(colorsTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).w; 
     312        dummy.z = tex2Dlod(colorsTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).w; 
     313        dummy.w = tex2Dlod(colorsTex, float4(IN.texCoord + float2(0, -yoffs), 0, 0)).w; 
     314        color.w =  max(max(dummy.x, dummy.y), max(dummy.z, dummy.w)); 
     315         
    304316        // store scaled view vector so wie don't have to normalize for e.g., ssao 
    305317        color.w /= length(IN.view); 
    306         //color.w = 1; 
    307318 
    308319        // do reprojection and filter out the pixels that are not save 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/normalMapping.cg

    r3168 r3195  
    125125        float3x3 tangToWorldTrafo = transpose(float3x3(tangent, bitangent, normal)); 
    126126         
    127         const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz * 2.0f - float3(1.0f); 
     127        //const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz * 2.0f - float3(1.0f); 
     128        const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz; 
     129        pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm); 
     130        //pix.normal = tangentSpaceNorm; 
    128131         
    129         pix.normal = normalize(mul(tangToWorldTrafo, tangentSpaceNorm)); 
    130                  
    131132        return pix; 
    132133} 
     
    171172        float3x3 tangToWorldTrafo = transpose(float3x3(IN.tangent.xyz, IN.bitangent.xyz, IN.normal.xyz)); 
    172173        const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz; 
    173         pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm); 
     174        //pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm); 
     175        pix.normal = tangentSpaceNorm; 
    174176 
    175177        return pix; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3193 r3195  
    393393        if (eyeSpaceDepth < 1e10f) 
    394394        { 
    395                 //ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight); 
    396                 ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 
     395                ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight); 
     396                //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 
    397397        } 
    398398        else 
Note: See TracChangeset for help on using the changeset viewer.