OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

DoF blur issues for antialiased text


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgPPU [osgPPU]
View previous topic :: View next topic  
Author Message
mikewoz
User


Joined: 15 Mar 2011
Posts: 24

PostPosted: Wed Jun 20, 2012 5:09 pm    Post subject:
DoF blur issues for antialiased text
Reply with quote

Hi,

I'm using a modified version of the osgPPU DoF example and I'm seeing strange artifacts around my text (see attached image).

It's like the blur is applied to a non-antialiased version of the text, but the text is drawn with correctly. This results in a jaggy region of full transparency around each character before the blur.

I also have issues where the blur seems to flicker as the depth of the text changes. It oscillates up/down as the text moves.

Any ideas of what I'm doing wrong? Or suggestions of where to look?

Thanks,
Mike
Back to top
View user's profile Send private message
mikewoz
User


Joined: 15 Mar 2011
Posts: 24

PostPosted: Mon Jun 25, 2012 11:11 pm    Post subject:
Reply with quote

Hi all,

I'm still struggling with this and just wanted to add some extra details.

The problem is that the blur around text near the camera is not being combined with blur further back. It's almost like the blur is being drawn from front to back while text (rendered as glyphs with alpha channel) are being drawn from back to front. Is that possible?

I imagine that this would need to be fixed on the shader side. ie, in depth_of_field_fp.glsl (?):

Code:
void main(void)
{
    vec2 inTex = gl_TexCoord[0].st;

    // compute distance to the viewer
    float a = zFar / ( zFar - zNear );
    float b = zFar * zNear / ( zNear - zFar );

    float depth = texture2D( texDepthMap, inTex ).x;
    float dist = b / ( depth - a );

    // get color map and blurred color map values
    vec4 colorValue = texture2D (texColorMap, inTex).rgba;
    vec4 blurredValue1 = texture2D ( texBlurredColorMap, inTex).rgba;
    vec4 blurredValue2 = texture2D ( texStrongBlurredColorMap, inTex).rgba;

    // now compute the bluriness value
    float blur = clamp(abs(dist - focalLength) / focalRange, 0.0, 1.0);
    float factor1 = 1.0;
    float factor2 = 0.0;

    // compute blend factors
    if (blur > 0.5)
        factor2 = (blur - 0.5) * 2.0;
    else
        factor1 = blur * 2.0;

    // the resulting color value is the combination of blurred and non-blurred map
    vec4 result = mix(colorValue, blurredValue1, factor1);
    gl_FragColor = mix(result, blurredValue2, factor2);
}


ie, will gl_FragColor correctly combine previously drawn alpha values?

Any help would be greatly appreciated.

-Mike
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgPPU [osgPPU] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Vanishing letters in osg::Text Tim Hartter General 13 Sat Apr 22, 2017 10:21 am View latest post
No new posts Missing Text tnassour General 0 Thu Apr 13, 2017 8:55 am View latest post
No new posts How to disable Antialiasing of an ... lq37 General 5 Thu Mar 02, 2017 5:41 pm View latest post
No new posts Text colors in shaders wernerM General 5 Fri Feb 24, 2017 12:00 pm View latest post
No new posts osgText::Text fix for GLES2 (OpenScen... Konstantin Submission 1 Tue Feb 14, 2017 6:37 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP