Skip to main content
GameDev.net gamedev.net
🔒 Locked

texture dilation filter - need HELP!

Started by demasprojects Feb 13, 2007 at 3:05 PM 0 replies 2k views
Original Post
demasprojects
demasprojects
i' m implementing real time skin rendering using lightmap blurring like in ATI Ruby demo, i have found presentation slides from GDC 04-05, and a chapter in GPU gems1 about that http://ati.amd.com/developer/gdc/Gosselin_skin.pdf http://ati.amd.com/developer/siggraph04/Sander_SkinSketch.pdf and discussed in thread http://www.beyond3d.com/forum/archive/index.php/t-10661.html here is UV parametrization of the mesh( it is not perfect ) pic1: http://img470.imageshack.us/my.php?image=uvheadmapsg2.jpg alpha channel of a texture used in blur shader to know where sampling outside boundaries pic2: http://img213.imageshack.us/my.php?image=alphavp8.jpg my problems come after blurring lightmap: due to large filter kernel 9x9 and subsequent blur pass, texture seams become evident (black eyes and mouth countours) pic3: http://img206.imageshack.us/my.php?image=blutlightmapvr4.jpg relevant code snippet of lightmap computation fragment shader alphaMap is pic2

gl_FragColor.rgb = AshikShirDiff(NdotL, dot(N, V), lightColor );
 gl_FragColor.a = texture2D(alphaMap, gl_TexCoord[0].st).a; //1 outside texture boundaryes
blurring fragment shader(vertical same as horizontal): skinSamp1 is the light map

vec4 weight[5] = {
        {0.021, 0.0, 0.0, 1.0},
        {0.07, 0.0, 0.0, 1.0},
        {0.13, 0.086, 0.086, 1.0},
        {0.179, 0.244, 0.244, 1.0},
        {0.2, 0.33, 0.33, 1.0},
    };


vec4 mainCol = texture2D(skinSamp1, vec2(gl_TexCoord[0].s,gl_TexCoord[0].t)) * weight[4];
    vec4 OutCol = mainCol;
    float flag = OutCol.a;
    
    vec4 currCol = texture2D(skinSamp1, vec2(gl_TexCoord[0].s+ TexelIncrement * 4.0,gl_TexCoord[0].t)) * weight[0];
    OutCol += currCol ;
    flag = max(flag, currCol.a);
    if (currCol.a < mainCol.a)
        mainCol = currCol;

    currCol = texture2D(skinSamp1, vec2(gl_TexCoord[0].s+ TexelIncrement * 3.0,gl_TexCoord[0].t)) * weight[1];
    OutCol += currCol ;
    flag = max(flag, currCol.a);
    if (currCol.a < mainCol.a)
        mainCol = currCol;
 
     currCol = texture2D(skinSamp1, vec2(gl_TexCoord[0].s+ TexelIncrement * 2.0,gl_TexCoord[0].t)) * weight[2];
    OutCol += currCol ;
    flag = max(flag, currCol.a);
    if (currCol.a < mainCol.a)
        mainCol = currCol;
        
    currCol = texture2D(skinSamp1, vec2(gl_TexCoord[0].s+ TexelIncrement * 1.0,gl_TexCoord[0].t)) * weight[3];
    OutCol += currCol ;
    flag = max(flag, currCol.a);
    if (currCol.a < mainCol.a)
        mainCol = currCol;    
  
     currCol = texture2D(skinSamp1, vec2(gl_TexCoord[0].s- TexelIncrement * 1.0,gl_TexCoord[0].t)) * weight[3];
    OutCol += currCol ;
    flag = max(flag, currCol.a);
    if (currCol.a < mainCol.a)
        mainCol = currCol;

     currCol = texture2D(skinSamp1, vec2(gl_TexCoord[0].s- TexelIncrement * 2.0,gl_TexCoord[0].t)) * weight[2];
    OutCol += currCol ;
    flag = max(flag, currCol.a);
    if (currCol.a < mainCol.a)
        mainCol = currCol;
        
    currCol = texture2D(skinSamp1, vec2(gl_TexCoord[0].s- TexelIncrement * 3.0,gl_TexCoord[0].t)) * weight[1];
    OutCol += currCol ;
    flag = max(flag, currCol.a);
    if (currCol.a < mainCol.a)
        mainCol = currCol;
    
    currCol = texture2D(skinSamp1, vec2(gl_TexCoord[0].s- TexelIncrement * 4.0,gl_TexCoord[0].t)) * weight[0];
    OutCol += currCol ;
    flag = max(flag, currCol.a);
    if (currCol.a < mainCol.a)
        mainCol = currCol;
 
   if (flag == 1.0)
        gl_FragColor = vec4(mainCol.xyz, 1.0);
    else gl_FragColor = vec4(OutCol.xyz, 0.0);
i implemented dilation filter like explained in ATI presentation but with wrong result. alphaMap is same resolution of lightMap any ideas to remove these artifacts due to several blurring pass? thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.