Ignore:
Timestamp:
07/04/08 00:51:25 (16 years ago)
Author:
mattausch
Message:

ssao working ok

File:
1 edited

Legend:

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

    r2812 r2813  
    6767 
    6868  //const float areaSize = 4.0f;   
    69   const float areaSize = 4e-3f; 
    70   const float sampleIntensity = 0.1f; 
     69  const float areaSize = 5e-1f; 
     70  //const float areaSize = 1e-4f; 
     71  const float sampleIntensity = 0.2f; 
    7172   
    7273  for (int i = 0; i < SAMPLES; i ++) { 
     
    7677    float3 noise = tex2D(noiseTexture, IN.texCoord.xy).xyz * 2.0f - 1.0f; 
    7778 
    78     // float2 offsetTransformed = offset; 
    79     float2 offsetTransformed; 
    80     offsetTransformed.x = noise.r*offset.x - noise.g*offset.y; 
    81     offsetTransformed.y = noise.g*offset.x + noise.r*offset.y; 
     79    float2 offsetTransformed = offset; 
     80    //float2 offsetTransformed; 
     81    //offsetTransformed.x = noise.r*offset.x - noise.g*offset.y; 
     82    //offsetTransformed.y = noise.g*offset.x + noise.r*offset.y; 
    8283                 
    83     float2 texcoord = IN.texCoord.xy + offsetTransformed * areaSize;// * (1.0f - centerPositionW.w); 
     84    // weight with projected coordinate to reach similar kernel size for near and far 
     85    float2 texcoord = IN.texCoord.xy + offsetTransformed * areaSize * centerPositionW.w; 
    8486     
    8587    float3 sample_position = tex2D(positions, texcoord).xyz; 
    8688     
    8789    float3 vector_to_sample = sample_position - centerPosition; 
    88     // vector_to_sample.z = -vector_to_sample.z; 
    8990    float length_to_sample = length(vector_to_sample); 
    9091    float3 direction_to_sample = vector_to_sample / (length_to_sample + 1e-9f); 
     
    9596     
    9697    // distance between current position and sample position controls AO intensity. 
    97     const float maxdist = 5e-1f; 
     98    const float maxdist = 1e-1f; 
    9899    //const float scale = 50.0f; 
    99100 
     
    116117{ 
    117118  pixel OUT; 
    118   //float4 lightDir = float4(1.0f, 1.0f, 1.0f, 0.0f); 
    119 float4 lightDir = float4(0.0f, 1.0f, 0.0f, 0.0f); 
     119  float4 lightDir = float4(1.0f, 1.0f, 1.0f, 0.0f); 
     120  //float4 lightDir = float4(0.0f, 1.0f, 0.0f, 0.0f); 
    120121   
    121122  float4 color = tex2D(colors, IN.texCoord.xy); 
     
    126127  float4 position = tex2D(positions, IN.texCoord.xy); 
    127128 
    128   float4 ambient = float4(0.1f); 
     129  float4 ambient = float4(0.3f); 
    129130 
    130131  // float3 L = normalize(lightPosition - position); 
     
    135136 
    136137  float ao = ssao(IN, positions, normals, ProjTrafo, noiseTexture); 
    137   OUT.color = ao; //(ambient + diffuse) * color; 
    138   //OUT.color = (ambient + diffuse) * color; 
     138  OUT.color = ao;  
     139  //OUT.color = ao * (ambient + diffuse) * color; 
     140 
     141  //float4 currentPos = tex2D(normals, IN.texCoord.xy) * 0.5f + 0.5f; 
     142  //float4 currentPos = tex2D(positions, IN.texCoord.xy); 
     143  //OUT.color = currentPos.w; 
    139144   
    140   //float4 currentPos = tex2D(positions, IN.texCoord.xy); 
    141   //OUT.color = currentPos; 
    142   //float4 currentPos = tex2D(normals, IN.texCoord.xy) * 0.5f + 0.5f; 
    143   //OUT.color = currentPos; 
    144    
     145     
    145146  return OUT; 
    146147} 
Note: See TracChangeset for help on using the changeset viewer.