Ignore:
Timestamp:
07/15/08 11:35:23 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
Files:
2 edited

Legend:

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

    r2836 r2837  
    55//#define NUM_SAMPLES 8 
    66#define NUM_SAMPLES 16 
     7 
     8// rule of thumb: approx 1 / NUM_SAMPLES 
     9#define SAMPLE_INTENSITY 0.2 
    710//#define SAMPLE_INTENSITY 0.125f 
    8 // rule of thumb: approx 1 / NUM_SAMPLES 
    9 #define SAMPLE_INTENSITY 0.22 //0.0625f 
    1011 
    1112#define AREA_SIZE 5e-1f 
    12  
     13#define VIEW_CORRECTION_SCALE 0.3f 
     14#define DISTANCE_SCALE 1e-6f 
    1315 
    1416struct fragment 
     
    2325struct pixel 
    2426{ 
    25   float4 color: COLOR0; 
     27        float4 color: COLOR0; 
    2628}; 
    2729 
     
    9698 
    9799                // distance between current position and sample position controls AO intensity. 
    98                 const float distanceScale = 1e-6f; 
    99  
    100100                float distance_intensity =  
    101                         (SAMPLE_INTENSITY * distanceScale) / (distanceScale + length_to_sample * length_to_sample); 
     101                        (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 
    102102 
    103103                // if normal perpenticular to view dir, only half of the samples count 
    104                 float view_correction = 1.0f + 0.5f * (1.0f - dot(currentViewDir, currentNormal)); 
     104                float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 
    105105 
    106106                total_ao += cos_angle * distance_intensity * view_correction; 
     
    119119                                 uniform float3 currentViewDir, 
    120120                                 uniform float noiseMultiplier, 
    121                                  uniform float4 centerPosition) 
     121                                 uniform float4 centerPosition 
     122                                 ) 
    122123{ 
    123124        // the w coordinate from the persp. projection 
     
    158159 
    159160                // distance between current position and sample position controls AO intensity. 
    160                 const float distanceScale = 1e-6f; 
    161  
    162161                float distance_intensity =  
    163                         (SAMPLE_INTENSITY * distanceScale) / (distanceScale + length_to_sample * length_to_sample); 
    164  
    165                 const float view_correction_scale = 0.5f; 
     162                        (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 
     163 
    166164                // if normal perpenticular to view dir, only half of the samples count 
    167                 float view_correction = 1.0f + view_correction_scale * (1.0f - dot(currentViewDir, currentNormal)); 
     165                float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 
    168166 
    169167                total_ao += cos_angle * distance_intensity * view_correction; 
     
    213211                                uniform sampler2D oldTex, 
    214212                                const uniform float4x4 oldModelViewProj, 
    215                                 uniform float maxDepth 
     213                                uniform float maxDepth, 
     214                                uniform float expFactor 
    216215                                ) 
    217216{ 
     
    230229        float4 col = shade(IN, colors, positions, normal.xyz, amb); 
    231230 
    232         //float ao = ssao(IN, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 
    233         float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition);  
    234         float ao = new_col.w; 
    235  
    236         float4 attenuated_color = ao * col + new_col; 
    237         //float4 attenuated_color = ao * col; 
    238  
    239         //OUT.color = ao; 
    240         //OUT.color = ao * col; 
    241         //float4 col1 = attenuated_color; 
    242  
    243         const float x = 0.1f; 
     231        float ao = ssao(IN, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 
     232        float4 attenuated_color = ao * col; 
     233 
     234        //float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition);  
     235        //float ao = new_col.w; 
     236        //float4 attenuated_color = ao * col + new_col; 
     237         
     238        const float x = expFactor; 
    244239 
    245240        float4 dummy = centerPosition * maxDepth; 
     
    254249 
    255250        float oldDepth = col1.w; 
    256  
    257         if ((tex.x >= 0.0f) && (tex.x < 1.0f) && (tex.y >= 0.0f) && (tex.y < 1.0f) && (abs(newDepth - oldDepth) < 9e-4f)) 
    258                 OUT.color = attenuated_color * x + col1 * float4(1.0f - x); 
     251        float depthDif = 1.0f - newDepth / oldDepth; 
     252 
     253        if ((tex.x >= 0.0f) && (tex.x < 1.0f) &&  
     254                (tex.y >= 0.0f) && (tex.y < 1.0f) &&  
     255                (abs(depthDif)  < 9e-4f)) 
     256                OUT.color = attenuated_color * expFactor + col1 * float4(1.0f - expFactor); 
    259257        else 
    260258                OUT.color = attenuated_color; 
    261259 
    262         //OUT.color = float4(centerPosition.w); 
    263         //OUT.color = float4(oldDepth); 
    264         //OUT.color = float4(newDepth); 
    265         //OUT.color = float4(abs(newDepth - oldDepth)); 
    266260        OUT.color.w = tex2D(colors, IN.texCoord.xy).w; 
    267261 
     
    273267                   uniform sampler2D colors, 
    274268                   uniform sampler2D positions, 
    275                    uniform sampler2D normals, 
    276                    uniform sampler2D oldTex 
     269                   uniform sampler2D normals 
    277270                   ) 
    278271{ 
     
    282275        float amb = normal.w; 
    283276 
    284         //OUT.color.xyz = IN.view; 
    285277        // expand normal 
    286278        normal = normalize(normal * 2.0f - float4(1.0f)); 
    287279 
    288280        float4 col = shade(IN, colors, positions, normal.xyz, amb); 
    289         //OUT.color = col; 
    290  
    291         float4 col1 = tex2D(oldTex, IN.texCoord.xy); 
    292  
    293         const float x = 0.01f; 
    294         OUT.color = col * x + col1 * float4(1.0f - x); 
     281        OUT.color = col; 
    295282 
    296283        return OUT; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2836 r2837  
    105105  // hack: squeeze some information about ambient into the texture 
    106106  pix.norm.w = ambient.x; 
    107   pix.pos.w = IN.mypos.w; //IN.projPos.w; 
     107  pix.pos.w = IN.mypos.w; 
    108108  pix.col.w = IN.mypos.z / IN.mypos.w; 
    109109 
Note: See TracChangeset for help on using the changeset viewer.