Jump to content
  • Advertisement
Sign in to follow this  
demasprojects

texture dilation filter - need HELP!

This topic is 4319 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!