Changeset 2811 for GTP


Ignore:
Timestamp:
07/03/08 17:52:45 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r2800 r2811  
    171171        } 
    172172        else 
     173        { 
    173174                texcoords = NULL; 
     175        } 
     176 
     177        for (int i = 0; i < vertexCount; i += 3) 
     178        { 
     179                Triangle3 tri(vertices[i], vertices[i + 1], vertices[i + 2]); 
     180                Vector3 n = tri.GetNormal(); 
     181                normals[i + 0] = n; 
     182                normals[i + 1] = n; 
     183                normals[i + 2] = n; 
     184        } 
    174185 
    175186        return new Geometry(vertices, normals, texcoords, vertexCount, true); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2810 r2811  
    8989 
    9090static int winWidth = 1024; 
    91 static int winHeight = 768; 
     91static int winHeight = 1024; 
    9292static float winAspectRatio = 1.0f; 
    9393 
     
    9898 
    9999// rendertexture 
    100 const static int texWidth = 2048; 
    101 const static int texHeight = 2048; 
     100const static int texWidth = 1024; 
     101const static int texHeight = 1024; 
    102102 
    103103int renderedObjects = 0; 
     
    331331        //bvh = bvhLoader.Load("data/city/model/city.bvh", sceneEntities); 
    332332 
    333         myfar = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 
     333        myfar = 1.0f * Magnitude(bvh->GetBox().Diagonal()); 
    334334 
    335335        if (!bvh) 
     
    550550        glGenRenderbuffersEXT(1, &normalsBuffer); 
    551551        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, normalsBuffer); 
    552         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, texWidth, texHeight); 
     552        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
    553553         
    554554        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_RENDERBUFFER_EXT, normalsBuffer); 
     
    556556        glGenTextures(1, &normalsTex); 
    557557        glBindTexture(GL_TEXTURE_2D, normalsTex); 
    558         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 
     558        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB,  texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
    559559        glGenerateMipmapEXT(GL_TEXTURE_2D); 
    560560        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, normalsTex, 0); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2810 r2811  
    5757 
    5858  // the normal on the current position 
    59   float3 centerNormal = tex2D(normals, IN.texCoord.xy).xyz * 2.0f - 1.0f; 
    60  
     59  float3 centerNormal = tex2D(normals, IN.texCoord.xy).xyz; 
     60  normalize(centerNormal); 
     61   
    6162  // Check in a circular area around the current position. 
    6263  // Shoot vectors to the positions there, and check the angle to these positions. 
     
    6667 
    6768  //const float areaSize = 4.0f;   
    68   const float areaSize = 5e-3f; 
    69   const float sampleIntensity = 0.1; 
     69  const float areaSize = 4e-3f; 
     70  const float sampleIntensity = 0.1f; 
    7071   
    7172  for (int i = 0; i < SAMPLES; i ++) { 
     
    7576    float3 noise = tex2D(noiseTexture, IN.texCoord.xy).xyz * 2.0f - 1.0f; 
    7677 
     78    //    float2 offsetTransformed = offset; 
    7779    float2 offsetTransformed; 
    7880    offsetTransformed.x = noise.r*offset.x - noise.g*offset.y; 
     
    8486     
    8587    float3 vector_to_sample = sample_position - centerPosition; 
     88    // vector_to_sample.z = -vector_to_sample.z; 
    8689    float length_to_sample = length(vector_to_sample); 
    87     float3 direction_to_sample = vector_to_sample / length_to_sample; 
     90    float3 direction_to_sample = vector_to_sample / (length_to_sample + 1e-9f); 
    8891     
    8992    // Angle between current normal and direction to sample controls AO intensity. 
     
    9295     
    9396    // distance between current position and sample position controls AO intensity. 
    94     const float scale = 5e-1f; 
     97    const float maxdist = 5e-1f; 
     98    //const float scale = 50.0f; 
    9599 
    96     float distance_intensity = scale * (1.0f - length_to_sample); 
     100    float distance_intensity = maxdist - length_to_sample; 
    97101    distance_intensity = max(distance_intensity, 0.0f); 
    98102     
     
    112116{ 
    113117  pixel OUT; 
    114   float4 lightDir = float4(1.0f, 1.0f, 1.0f, 0.0f); 
     118  //float4 lightDir = float4(1.0f, 1.0f, 1.0f, 0.0f); 
     119float4 lightDir = float4(0.0f, 1.0f, 0.0f, 0.0f); 
    115120   
    116121  float4 color = tex2D(colors, IN.texCoord.xy); 
     
    121126  float4 position = tex2D(positions, IN.texCoord.xy); 
    122127 
    123   float4 ambient = float4(0.3f); 
     128  float4 ambient = float4(0.1f); 
    124129 
    125130  // float3 L = normalize(lightPosition - position); 
     
    132137  OUT.color = ao; //(ambient + diffuse) * color; 
    133138  //OUT.color = (ambient + diffuse) * color; 
     139   
    134140  //float4 currentPos = tex2D(positions, IN.texCoord.xy); 
     141  //OUT.color = currentPos; 
     142  //float4 currentPos = tex2D(normals, IN.texCoord.xy) * 0.5f + 0.5f; 
    135143  //OUT.color = currentPos; 
    136144   
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2810 r2811  
    1616  float4 color: COLOR0;   
    1717  float4 worldPos: TEXCOORD1; // world position 
    18   float3 norm: TEXCOORD2; 
     18  float3 normal: TEXCOORD2; 
    1919}; 
    2020 
     
    2929  float4 color: COLOR0;   
    3030  float4 worldPos: TEXCOORD1; // world position 
    31   float3 norm: TEXCOORD2; 
     31  float3 normal: TEXCOORD2; 
    3232}; 
    3333 
     
    5454   // eye pos with linear depth 
    5555   //OUT.worldPos = OUT.position; 
    56    OUT.norm = IN.normal; 
     56   OUT.normal = IN.normal; 
    5757 
    5858   return OUT; 
     
    6666  pix.col = tex2D(tex, IN.texCoord.xy); 
    6767  pix.pos = IN.worldPos * maxDepth; 
    68   pix.norm = IN.norm * 0.5f + 0.5f; 
     68  pix.norm = IN.normal; 
    6969 
    7070  return pix; 
Note: See TracChangeset for help on using the changeset viewer.