Ignore:
Timestamp:
07/07/08 16:34:07 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r2819 r2820  
    1 #define SAMPLES 24 
    2  
     1#define NUM_SAMPLES 8 
     2#define SAMPLE_INTENSITY 0.6 
     3#define AREA_SIZE 3e-1f 
    34// kustls magic sample positions 
    4 static const float2 samples[SAMPLES] = 
     5/*static const float2 samples[NUM_SAMPLES] = 
    56{ 
    67  {-0.326212f, -0.405805f}, 
     
    2829  {0.32194f, 0.932615f}, 
    2930  {0.791559f, 0.597705f} 
    30 }; 
     31};*/ 
    3132 
    3233 
     
    6061           uniform sampler2D positions, 
    6162           uniform sampler2D normals, 
    62            uniform sampler2D noiseTexture                                
     63           uniform sampler2D noiseTexture, 
     64           uniform float2 samples[NUM_SAMPLES] 
    6365           ) 
    6466{ 
     
    7981 
    8082  //const float areaSize = 5e-1f; 
    81   const float areaSize = 3e-1f; 
    82   const float sampleIntensity = 0.2f; 
     83  //const float areaSize = 3e-1f; 
     84  //const float sampleIntensity = 0.2f; 
    8385   
    84   for (int i = 0; i < SAMPLES; i ++) { 
     86  for (int i = 0; i < NUM_SAMPLES; i ++) { 
    8587    float2 offset = samples[i]; 
    8688     
     
    9597                 
    9698    // weight with projected coordinate to reach similar kernel size for near and far 
    97     float2 texcoord = IN.texCoord.xy + offsetTransformed * areaSize * w; 
     99    float2 texcoord = IN.texCoord.xy + offsetTransformed * AREA_SIZE * w; 
    98100     
    99101    float3 sample_position = tex2D(positions, texcoord).xyz; 
     
    101103    float3 vector_to_sample = sample_position - centerPosition.xyz; 
    102104    float length_to_sample = length(vector_to_sample); 
    103     float3 direction_to_sample = vector_to_sample / (length_to_sample + 1e-9f); 
     105    float3 direction_to_sample = vector_to_sample / length_to_sample; 
    104106     
    105107    // Angle between current normal and direction to sample controls AO intensity. 
     
    115117    distance_intensity = max(distance_intensity, 0.0f); 
    116118     
    117     total_ao += cos_angle * sampleIntensity * distance_intensity; 
     119    total_ao += cos_angle * SAMPLE_INTENSITY * distance_intensity; 
    118120  } 
    119121         
     
    122124 
    123125 
    124 pixel main(fragment IN,  
    125            uniform sampler2D colors, 
    126            uniform sampler2D positions, 
    127            uniform sampler2D normals, 
    128            uniform sampler2D noiseTexture) 
     126float4 shade(fragment IN,  
     127             uniform sampler2D colors, 
     128             uniform sampler2D positions, 
     129             uniform sampler2D normals) 
    129130{ 
    130   pixel OUT; 
    131  
    132131  float4 lightDir = float4(0.8f, -1.0f, 0.7f, 0.0f); 
    133132  float4 lightDir2 = float4(-0.5f, 0.5f, 0.4f, 0.0f); 
     
    152151  float diffuse = diffuseLight + diffuseLight2; 
    153152 
    154   //float ao = ssao(IN, positions, normals, noiseTexture); 
    155   float ao = 1.0f; 
    156   //OUT.color = ao;  
    157   OUT.color = ao * (ambient + diffuse) * color; 
     153  return (ambient + diffuse) * color; 
     154} 
     155 
     156 
     157pixel main(fragment IN,  
     158           uniform sampler2D colors, 
     159           uniform sampler2D positions, 
     160           uniform sampler2D normals, 
     161           uniform sampler2D noiseTexture, 
     162           uniform float2 samples[NUM_SAMPLES]) 
     163{ 
     164  pixel OUT; 
     165 
     166  float4 col = Shade(IN, positions, normals); 
     167  float ao = ssao(IN, positions, normals, noiseTexture, samples); 
     168  //float ao = 1.0f; 
     169  OUT.color = ao * col;  
     170  //OUT.color = ao * (ambient + diffuse) * color; 
    158171  //OUT.color = (ambient + diffuse) * color; 
    159172       
Note: See TracChangeset for help on using the changeset viewer.