Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 10

Thread: MSAA performance in deferred shading

Hybrid View

  1. #1
    Junior Member Regular Contributor
    Join Date
    Sep 2006
    Location
    thailand
    Posts
    130

    MSAA performance in deferred shading

    I have implemented MSAA in deferred shading by calculate lighting at every sample of the pixel and then average it,something like this

    Code :
    vec4 pixelIntenisty = vec4(0.0,0.0,0.0,0.0);
    for(int i=0;i<MSAACount;i++){
       float depth = texelFetch(depthTextureMSAA,texCoord,i);
       vec4 diffuse = texelFetch(diffuseTextureMSAA,texCoord,i);
       vec4 specular = texelFetch(specularTextureMSAA,texCoord,i);
       vec4 normal = textelFetch(normalTextureMSAA,texCoord,i);
       //calculate lighting
       pixelIntenisty += calculateLighting(......);
    }
    //average the pixel intensity
    pixelIntensity = pixelIntensity/MSAACount;

    while this give a good result ,the performane is totally killed.

    so , I am thinking about doing antialiasing only at the edge pixel but that will also invole some kind of edge detection and stencil operation to mark the pixel(which might make thing even more slower).

    Is there any other approch (in OpenGL 3.2-3.3 compatible way) to handle real antialiasing in deferred shader ?

    Cheer
    somboon

  2. #2
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Location
    Poland
    Posts
    109

    Re: MSAA performance in deferred shading

    Texel fetches are slow, but they can be executed in pararel with other operations (math), try mixing texture access with computation instructions.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Sep 2006
    Location
    thailand
    Posts
    130

    Re: MSAA performance in deferred shading

    Can you give some short example ?

    I dont understand the "mixing texture access with computation instruction".

    Is it something like this ?

    in stead of

    Code :
    float depth = texelFetch(depthTextureMSAA,intTexCoord.st,i).r;
    pos.z = - planes.y / (planes.x + depth);
    pos.xy = intViewVector.xy / intViewVector.z*pos.z;

    do this
    Code :
    pos.z = - planes.y / (planes.x + texelFetch(depthTextureMSAA,intTexCoord.st,i).r);
    pos.xy = intViewVector.xy / intViewVector.z*pos.z;


    Thanks

  4. #4
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Location
    Poland
    Posts
    109

    Re: MSAA performance in deferred shading

    No, I meant,

    instead of:
    Code :
    diffuse = texelFetch(...);
    specular = textelFetch(...);
    somethingelse = texelFetch(...);

    do:
    Code :
    diffuse = texelFetch(...);
    (do some math here, but do not use 'diffuse' variable)
    specular = texelFetch(...);
    (math again, assume that 'diffuse' is ready, but do not use 'specular')
    ...

    For me this trick boosted performance about 1.5x (I had 14 texelFetches in shader)

  5. #5
    Junior Member Regular Contributor
    Join Date
    Sep 2006
    Location
    thailand
    Posts
    130

    Re: MSAA performance in deferred shading

    Thank a lot , will definately try this.

    Is this trick also work with standard texture2D ? or the function is already fast enought ?

  6. #6
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Location
    Poland
    Posts
    109

    Re: MSAA performance in deferred shading

    AFAIK all texturing functions are slow, but I'm not sure.
    It is definitely worth testing .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •