Ignore:
Timestamp:
07/11/08 01:12:05 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r2832 r2833  
    66//#define SAMPLE_INTENSITY 0.5f 
    77//#define SAMPLE_INTENSITY 1.1f 
    8 #define SAMPLE_INTENSITY 0.7f 
     8#define SAMPLE_INTENSITY 0.25f 
    99#define AREA_SIZE 5e-1f 
    1010 
     
    1414  float4 pos: WPOS; // normalized screen position 
    1515  float4 texCoord: TEXCOORD0;  
     16  float3 view: COLOR0; 
    1617}; 
    1718 
     
    5152           uniform float2 samples[NUM_SAMPLES], 
    5253           uniform float3 currentNormal, 
    53            uniform float noiseMultiplier) 
     54           uniform float3 currentViewDir) 
    5455{ 
    5556  // the current world position 
     
    7273     
    7374    //sample noisetex; r stores costheta, g stores sintheta 
    74     float2 noise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 
     75    float2 noise = tex2D(noiseTexture, IN.texCoord.xy * 7.1f).xy * 2.0f - 1.0f; 
    7576         
    7677    // rotation 
     
    9899    //const float maxdist = 5e-1f; 
    99100    const float distanceScale = 1e-6f; 
    100     //float distance_intensity = maxdist - length_to_sample; 
    101     float distance_intensity = (SAMPLE_INTENSITY * distanceScale) / (distanceScale + length_to_sample * length_to_sample); 
    102     //distance_intensity = max(distance_intensity, 0.0f); 
    103     // quadratic influence 
    104     //distance_intensity *= distance_intensity; 
    105      
    106     total_ao += cos_angle * distance_intensity; 
     101 
     102    float distance_intensity =  
     103      (SAMPLE_INTENSITY * distanceScale) / (distanceScale + length_to_sample * length_to_sample); 
     104 
     105    // if normal perpenticular to view dir, only half of the samples count 
     106    float view_correction = (2.0f - dot(currentViewDir, currentNormal)); 
     107 
     108    total_ao += cos_angle * distance_intensity * view_correction; 
    107109  } 
    108110         
     
    133135  float diffuseLight2 = max(dot(normal, light2), 0.0f); 
    134136 
    135   float diffuse = diffuseLight + diffuseLight2; 
     137  //float diffuse = diffuseLight + diffuseLight2; 
     138  float diffuse = diffuseLight; 
    136139 
    137140  return (ambient + diffuse) * color * (1.0f - amb) + amb * color; 
     
    140143 
    141144pixel main_ssao(fragment IN,  
    142                uniform sampler2D colors, 
    143                uniform sampler2D positions, 
    144                uniform sampler2D normals, 
    145                uniform sampler2D noiseTexture, 
    146                uniform float2 samples[NUM_SAMPLES], 
    147                uniform float noiseMultiplier) 
     145                uniform sampler2D colors, 
     146                uniform sampler2D positions, 
     147                uniform sampler2D normals, 
     148                uniform sampler2D noiseTexture, 
     149                uniform float2 samples[NUM_SAMPLES]) 
    148150{ 
    149151  pixel OUT; 
     
    154156  // expand normal 
    155157  normal = normalize(normal * 2.0f - 1.0f); 
     158  float3 viewDir = normalize(IN.view * 2.0f - float(1.0f)); 
    156159 
    157160  float4 col = shade(IN, colors, positions, normal, amb); 
    158   float ao = ssao(IN, positions, noiseTexture, samples, normal, noiseMultiplier); 
     161  float ao = ssao(IN, positions, noiseTexture, samples, normal, viewDir); 
    159162   
    160163   //OUT.color = ao; 
     
    175178  float amb = normal.w; 
    176179 
     180  //OUT.color.xyz = IN.view; 
    177181  // expand normal 
    178   normal = normalize(normal * 2.0f - 1.0f); 
     182  normal = normalize(normal * 2.0f - float4(1.0f)); 
    179183   
    180184  float4 col = shade(IN, colors, positions, normal.xyz, amb); 
Note: See TracChangeset for help on using the changeset viewer.