Ignore:
Timestamp:
08/26/08 13:30:31 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg

    r2866 r2867  
    1010}; 
    1111 
    12 //uniform sampler2D s_distort; 
    13 uniform float4 e_barrier = float4(5e-5, 5e-5, 0, 0); 
     12// the barrier for detecting a discontinuity 
     13uniform float4 e_barrier = float4(5e-3, 5e-3, 0, 0); // x = normal, y = depth 
     14// the weights for normal / depth discontinuity 
    1415uniform float4 e_weights = float4(1.0f, 1.0f, 1.0f, 1.0f); // x = normal, y = depth 
    15 uniform float4 e_kernel = float4(0.3f, 1.0f, 1.0f, 1.0f); // x = normal, y = depth 
     16uniform float4 e_kernel = float4(0.35f, 1.0f, 1.0f, 1.0f);  
    1617 
    1718 
     
    2122                        ): COLOR 
    2223{ 
     24        //return tex2D(colors, IN.c.xy); 
    2325        // normal discontinuity filter 
    2426        float3 nc = (float3)tex2D(normals, IN.c.xy); 
     
    8183 
    8284        return (s0 + s1 + s2 + s3) / 4.0f; 
    83         //return float4(w); 
    8485} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2866 r2867  
    77 
    88// rule of thumb: approx 1 / NUM_SAMPLES 
    9 #define SAMPLE_INTENSITY 0.17 
     9#define SAMPLE_INTENSITY 0.15 
    1010//#define SAMPLE_INTENSITY 0.125f 
    1111 
     
    3737  float2 rpt = pt - d * 2.0f * n; 
    3838 
    39   //return pt; 
    4039  return rpt; 
    4140} 
     
    8079 
    8180                //sample noisetex; r stores costheta, g stores sintheta 
    82                 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 
     81                //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 
     82                float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 
    8383 
    8484                // rotation 
    8585                //float2 offsetTransformed = offset; 
    86                 float2 offsetTransformed = rotate(offset, mynoise); 
    87                 //float2 offsetTransformed = reflect(offset, noise); 
     86                //float2 offsetTransformed = rotate(offset, mynoise); 
     87                float2 offsetTransformed = reflect(offset, mynoise); 
    8888 
    8989                // weight with projected coordinate to reach similar kernel size for near and far 
    9090                float2 texcoord = IN.texCoord.xy + offsetTransformed * AREA_SIZE * w; 
    9191 
    92                 float3 sample_position = tex2D(positions, texcoord).xyz; 
     92                // sample downsampled texture in order to speed up texture accesses 
     93                float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz; 
     94                //float3 sample_position = tex2D(positions, texcoord).xyz; 
    9395 
    9496                float3 vector_to_sample = sample_position - centerPosition.xyz; 
     
    112114 
    113115        return (1.0f - total_ao); 
    114         //return float4(dot(currentViewDir, currentNormal)); 
     116        //return dot(currentViewDir, currentNormal); 
    115117} 
    116118 
     
    180182 
    181183 
     184/** function for standard deferred shading 
     185*/ 
    182186float4 shade(fragment IN,  
    183187                         uniform sampler2D colors, 
     
    199203        float3 light2 = normalize(lightDir2.xyz); 
    200204 
    201         float diffuseLight = max(dot(normal, light), 0.0f); 
    202         float diffuseLight2 = max(dot(normal, light2), 0.0f); 
     205        float diffuseLight = saturate(dot(normal, light)); 
     206        float diffuseLight2 = saturate(dot(normal, light2)); 
    203207 
    204208        float diffuse = diffuseLight + diffuseLight2; 
    205         //float diffuse = diffuseLight; 
    206209 
    207210        return (ambient + diffuse) * color * (1.0f - amb) + amb * color; 
     
    227230 
    228231        float4 normal = tex2D(normals, IN.texCoord.xy); 
     232         
     233        // the ambient term 
    229234        float amb = normal.w; 
    230235 
    231236        // expand normal 
    232         normal = normalize(normal * 2.0f - 1.0f); 
     237        normal = normalize(normal);// * 2.0f - 1.0f); 
    233238        /// the current view direction 
    234239        float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f)); 
     
    263268        if ((tex.x >= 0.0f) && (tex.x < 1.0f) &&  
    264269                (tex.y >= 0.0f) && (tex.y < 1.0f) &&  
    265                 (abs(depthDif)  < 8e-5f)) 
     270                (abs(depthDif)  < 1e-4f)) 
    266271        { 
    267272                OUT.color = attenuated_color * expFactor + col1 * float4(1.0f - expFactor); 
     
    292297 
    293298        float4 normal = tex2D(normals, IN.texCoord.xy); 
     299 
     300        // an ambient color term 
    294301        float amb = normal.w; 
    295302 
    296303        // expand normal 
    297         normal = normalize(normal * 2.0f - float4(1.0f)); 
     304        normal = normalize(normal);// * 2.0f - float4(1.0f)); 
    298305 
    299306        float4 col = shade(IN, colors, positions, normal.xyz, amb); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2866 r2867  
    7777        // save color in first render target 
    7878        pix.col = (ambient + diffuse) * tex2D(tex, IN.texCoord.xy); 
     79         
    7980        // save world position in second rt 
    8081        pix.pos = IN.worldPos * maxDepth; 
    8182        // save normal in third rt 
    82         pix.norm.xyz = IN.normal * 0.5f + 0.5f; 
     83        //pix.norm.xyz = IN.normal * 0.5f + 0.5f; 
     84        pix.norm.xyz = IN.normal; 
    8385 
    8486        // hack: squeeze some information about ambient into the texture 
     
    107109        pix.col = diffuse; 
    108110        pix.pos = IN.worldPos * maxDepth; 
    109         pix.norm.xyz = IN.normal * 0.5f + float3(0.5f); 
    110         // hack: squeeze some information about ambient into the texture 
     111        //pix.norm.xyz = IN.normal * 0.5f + float3(0.5f); 
     112        pix.norm.xyz = IN.normal; 
     113        // hack: squeeze some information about the ambient term into the target 
    111114        pix.norm.w = ambient.x; 
    112115        pix.pos.w = IN.mypos.w; 
Note: See TracChangeset for help on using the changeset viewer.