Changeset 2813 for GTP


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

ssao working ok

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
3 edited

Legend:

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

    r2811 r2813  
    8989 
    9090static int winWidth = 1024; 
    91 static int winHeight = 1024; 
     91static int winHeight = 768; 
    9292static float winAspectRatio = 1.0f; 
    9393 
     
    9898 
    9999// rendertexture 
    100 const static int texWidth = 1024; 
    101 const static int texHeight = 1024; 
     100//const static int texWidth = 1024; 
     101//const static int texHeight = 768; 
     102const static int texWidth = 2048; 
     103const static int texHeight = 2048; 
    102104 
    103105int renderedObjects = 0; 
     
    505507        glGenRenderbuffersEXT(1, &colorsBuffer); 
    506508        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorsBuffer); 
    507         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
     509        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA32F_ARB, texWidth, texHeight); 
    508510         
    509511        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorsBuffer); 
     
    512514        glBindTexture(GL_TEXTURE_2D, colorsTex); 
    513515 
    514         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB,  texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
     516        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB,  texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
    515517        glGenerateMipmapEXT(GL_TEXTURE_2D); 
    516518        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorsTex, 0); 
     
    525527        glGenRenderbuffersEXT(1, &positionsBuffer); 
    526528        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, positionsBuffer); 
    527         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
    528         //glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, GL_RGBA16F_ARB, texWidth, texHeight); 
     529        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA32F_ARB, texWidth, texHeight); 
     530        //glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, GL_RGBA32F_ARB, texWidth, texHeight); 
    529531         
    530532        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_RENDERBUFFER_EXT, positionsBuffer); 
     
    532534        glGenTextures(1, &positionsTex); 
    533535        glBindTexture(GL_TEXTURE_2D, positionsTex); 
    534         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB,  texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
     536        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB,  texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
    535537        glGenerateMipmapEXT(GL_TEXTURE_2D); 
    536538        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, positionsTex, 0); 
     
    550552        glGenRenderbuffersEXT(1, &normalsBuffer); 
    551553        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, normalsBuffer); 
    552         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
     554        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA32F_ARB, texWidth, texHeight); 
    553555         
    554556        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_RENDERBUFFER_EXT, normalsBuffer); 
     
    556558        glGenTextures(1, &normalsTex); 
    557559        glBindTexture(GL_TEXTURE_2D, normalsTex); 
    558         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB,  texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
     560        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB,  texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
    559561        glGenerateMipmapEXT(GL_TEXTURE_2D); 
    560562        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, normalsTex, 0); 
     
    591593        // create color buffer 
    592594        glGenRenderbuffersEXT(1, &occlusionbuffer); 
    593         //glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
     595        //glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA32F_ARB, texWidth, texHeight); 
    594596        glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, GL_FLOAT_RGBA_NV, texWidth2, texHeight2); 
    595597        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, occlusionbuffer); 
     
    598600        glGenTextures(1, &occlusionTex); 
    599601        glBindTexture(GL_TEXTURE_2D, occlusionTex); 
    600         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB,  texWidth2, texHeight2, 0, GL_RGBA, GL_FLOAT, NULL); 
     602        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB,  texWidth2, texHeight2, 0, GL_RGBA, GL_FLOAT, NULL); 
    601603        glGenerateMipmapEXT(GL_TEXTURE_2D); 
    602604        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorTex, 0); 
  • 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} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2811 r2813  
    2626  float4 texCoord: TEXCOORD0;     
    2727 
    28   float4 dummy: WPOS; 
     28  float4 projPos: WPOS; 
    2929  float4 color: COLOR0;   
    3030  float4 worldPos: TEXCOORD1; // world position 
     
    6666  pix.col = tex2D(tex, IN.texCoord.xy); 
    6767  pix.pos = IN.worldPos * maxDepth; 
     68  pix.pos.w = IN.projPos.w; 
    6869  pix.norm = IN.normal; 
    6970 
Note: See TracChangeset for help on using the changeset viewer.