Dear all,

my project needs gl3 features and so I use the following methods:

camera->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(useGL3);

camera->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(useGL3);

Of course I need my own shaders then.
But I also like having built-in functionality like StatsHandler.
To set a simple shader for the StatsHandlers camera I do like that:

osgViewer::StatsHandler*sthd=newosgViewer::StatsHandler;

view->addEventHandler(sthd);

if(useGL3){
stateSet=sthd->getCamera()->getOrCreateStateSet();

stateSet->getOrCreateUniform(BASE_TEXTURE_UNIFORM,osg::Uniform::INT_SAMPLER_2D)->set(BASE_TEXTURE_UNIT);

stateSet->setTextureAttributeAndModes(BASE_TEXTURE_UNIT,textur_weiss.get(),osg::StateAttribute::ON);

installDefaultShader(stateSet);

}

The shaders are really simple:
VERTEX

uniformmat4osg_ModelViewProjectionMatrix;
uniformmat4osg_ModelViewMatrix;

uniformmat3osg_NormalMatrix;

uniformvec3lightPosition0=vec3(0.0f,0.0f,1.0f);

invec4osg_Vertex;

invec4osg_Normal;

invec4osg_Color;

invec4osg_MultiTexCoord0;

outvec3normal;

outvec3lightDir;

outvec4vertexColor;

outvec2textureCoord;

voidmain(){

normal=normalize(osg_NormalMatrix*osg_Normal.xyz);

vec3vertexPos=vec3(osg_ModelViewMatrix*osg_Vertex);

lightDir=normalize(lightPosition0-vertexPos);

vertexColor=osg_Color;

textureCoord=osg_MultiTexCoord0.xy;

gl_Position=osg_ModelViewProjectionMatrix*osg_Vertex;

}


FRAGMENT

uniformsampler2DbaseTexture;

invec3normal;
invec3lightDir;

invec4vertexColor;

invec2textureCoord;

outvec4fragData;

voidmain(){

vec4textureColor=texture2D(baseTexture,textureCoord);
fragData=vertexColor*textureColor;

}


That works fine for the graphics but all text is black. Obviously text does not set osg_Color .
Unfortunately I failed discovering the reason in the sources of osg.

Can anyone give me a hint on how to solve this?

Many thanks in advance

- Werner -

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to