Display errors in HUD happens when using fog state

classic Classic list List threaded Threaded
4 messages Options
S.W S.W
Reply | Threaded
Open this post in threaded view
|

Display errors in HUD happens when using fog state

hi, i try to add some fog effect on my earth refering to the example osgearth_shadercomp, it works fine. But it also causes an extra poblem, it seems all the osgText is influenced and becomes a rectangle.
before i add fog effect on my earthafter add fog effect on my earth
is there anyone who know how to solve the problem?
by the way,here is the code i use:
char s_hazeVertShader[] =
                "#version " GLSL_VERSION_STR "\n"
                "out vec3 v_pos; \n"
                "void setup_haze(inout vec4 VertexVIEW) \n"
                "{ \n"
                "    v_pos = vec3(VertexVIEW); \n"
                "} \n";

        char s_hazeFragShader[] =
                "#version " GLSL_VERSION_STR "\n"
                "in vec3 v_pos; \n"
                "void apply_haze(inout vec4 color) \n"
                "{ \n"
                "    float dist = clamp( length(v_pos)/10000.0, 0, 0.8 ); \n"
                "    color = mix(color, vec4(0.5, 0.5, 0.5, 1.0), dist); \n"
                "} \n";

        osgEarth::VirtualProgram* vp = new osgEarth::VirtualProgram();

        vp->setFunction( "setup_haze", s_hazeVertShader, osgEarth::ShaderComp::LOCATION_VERTEX_VIEW );

        vp->setFunction( "apply_haze", s_hazeFragShader, osgEarth::ShaderComp::LOCATION_FRAGMENT_LIGHTING );

rootNode->getOrCreateStateSet()->setAttributeAndModes( vp, osg::StateAttribute::ON);
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Display errors in HUD happens when using fog state

Is your text under the root node? I suggest moving your text so it's not affected by the shader.
Glenn Waldron / Pelican Mapping
S.W S.W
Reply | Threaded
Open this post in threaded view
|

Re: Display errors in HUD happens when using fog state

hi,Glenn,thanks for your quick reply.
Yes,your clue is right, i put HUD in a node which is the same level as rootNode,and it is no longer being influenced by the fog state.
and there's also something interesting, in fact, before all these modify, all my osgText::Text was influenced into rectangle except the words showed by osgEarth::PlaceNode.
S.W S.W
Reply | Threaded
Open this post in threaded view
|

Re: Display errors in HUD happens when using fog state

In reply to this post by gwaldron
hi,Glenn,thanks for your quick reply.
Yes,your clue is right, i put HUD in a node which is the same level as rootNode,and it is no longer being influenced by the fog state.
and there's also something interesting, in fact, before all these modify, all my osgText::Text was influenced into rectangle except the words showed by osgEarth::PlaceNode.