Hi Robert,
Yes, the problem was with the models. The application that was generating the
models we use was doing one of two things. It had two basic settings for a
stateset. In one model, the stateset would be set to:
StateSet {
DataVariance STATIC
rendering_hint DEFAULT_BIN
renderBinMode INHERIT
0xba1 ON
0x803a ON
}
and for another model the stateset would be:
StateSet {
DataVariance STATIC
rendering_hint DEFAULT_BIN
renderBinMode INHERIT
GL_CULL_FACE OFF
GL_LIGHTING ON
GL_COLOR_MATERIAL ON
GL_FOG OFF
GL_DEPTH_TEST ON
0xba1 ON
GL_BLEND OFF
0x803a ON
0x8074 OFF
0x8075 OFF
0x8076 OFF
0x8078 ON
Material {
DataVariance STATIC
ColorMode AMBIENT_AND_DIFFUSE
ambientColor 0.2 0.2 0.2 1
diffuseColor 0.8 0.8 0.8 1
specularColor 0 0 0 1
emissionColor 0 0 0 1
shininess 0
}
BlendFunc {
DataVariance STATIC
source SRC_ALPHA
destination ONE_MINUS_SRC_ALPHA
}
textureUnit 0 {
GL_TEXTURE_2D ON
}
textureUnit 1 {
GL_TEXTURE_2D ON
}
textureUnit 2 {
GL_TEXTURE_2D ON
}
textureUnit 3 {
GL_TEXTURE_2D ON
}
}
By themeselves, they render fine in the viewer app. However, added to the same
scene graph, they will *sometimes* completely destroy any resemblence of a
random model's geometry. Basically, I have gone through all the OSG files and
set the statesets equal to the first one and removed all the manual stateset
changes involving vertex arrays (et. al.) The scenes render much nicer now. :)
Thanks SO much for that suggestion.
I am a bit confused as to why the consequences are so severe when using these
two statesets.
Right now I'm looking at VBOs. All of the models have useVertexBufferObjects
FALSE. The useDisplayList setting is TRUE. I've been experimenting with the
viewer app to see what happens when I set useVBOS to TRUE and I appear to get a
significant speedup. Are there any things to watch out for when setting both
these values to TRUE?
Thanks,
Brian
P.S. Yes, the discussion of PROTECTED vs OVERRIDE is in the wiki. Sorry 'bout
that.
On Mon Nov 19 5:33 , 'Robert Osfield' <[EMAIL PROTECTED]> sent:
>Hi Brain,
>
>It really sounds like you models and state are messed up, you
>shouldn't need to go round forcing state on to models if they are set
>up correctly in the first place. These two lines shout out problems
>to me:
>
> ss->setMode(GL_TEXTURE_COORD_ARRAY,
>osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
> ss->setMode(GL_VERTEX_ARRAY, osg::StateAttribute::OVERRIDE |
>osg::StateAttribute::OFF);
>
>osg::Geometry manages vertex arrays completely, you should never set
>these manually yourselves, if you do then you'll be screwing up
>osg::Geometry rendering and resulting in undefined results.
>
>The above settings are most likely hiding as well as causing problems
>in the in your osg::Geometry. I suspect you are adding bugs in you
>database attempt to fix bugs database. As for OVERRIDE, is this is
>not a topic covered in the the QuickStartGuide?
>
>Robert.
>
>
>On Nov 17, 2007 11:24 PM, Brian [EMAIL PROTECTED]> wrote:
>>
>> Hi Robert,
>>
>> Thanks for the tips. One way that we have combatted this issue is to force
>> the same basic StateSet on all the models. This works in some cases, but in
>> others it does not. For example, we do the following stateset changes on
>> each model:
>>
>> osg::StateSet* ss = Model->GetOSGNode()->getOrCreateStateSet();
>> ss->setMode(GL_LIGHTING, osg::StateAttribute::OVERRIDE |
>> osg::StateAttribute::ON);
>> ss->setMode(GL_LIGHT0, osg::StateAttribute::OVERRIDE |
>> osg::StateAttribute::ON);
>> ss->setMode(GL_LIGHT1, osg::StateAttribute::OVERRIDE |
>> osg::StateAttribute::OFF);
>> ss->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE |
>> osg::StateAttribute::ON);
>> ss->setTextureMode(1, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE |
>> osg::StateAttribute::OFF);
>> ss->setTextureMode(2, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE |
>> osg::StateAttribute::OFF);
>> ss->setTextureMode(3, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE |
>> osg::StateAttribute::OFF);
>> ss->setMode(GL_TEXTURE_COORD_ARRAY, osg::StateAttribute::OVERRIDE |
>> osg::StateAttribute::ON);
>> ss->setMode(GL_VERTEX_ARRAY, osg::StateAttribute::OVERRIDE |
>> osg::StateAttribute::OFF);
>> ss->setMode( GL_CULL_FACE, osg::StateAttribute::OVERRIDE |
>> osg::StateAttribute::OFF );
>> ss->setRenderingHint( osg::StateSet::OPAQUE_BIN );
>> ss->setMode(GL_ALPHA_BITS, 8);
>> osg::AlphaFunc* alphafunc = new osg::AlphaFunc;
>> osg::BlendFunc* blendfunc = new osg::BlendFunc;
>> alphafunc->setFunction(osg::AlphaFunc::GREATER,0.08f);
>>
>> blendfunc->setFunction(osg::BlendFunc::SRC_ALPHA,osg::BlendFunc::ONE_MINUS_SRC_ALPHA);
>> ss->setAttributeAndModes(alphafunc, osg::StateAttribute::ON);
>> ss->setAttributeAndModes(blendfunc, osg::StateAttribute::OFF);
>>
>> I wasn't the one who decided on these values, so I don't really know if they
>> are necessary or not. I do know that if they are removed, then our
>> rendering is worse than ever. However, to me it seems that if the model's
>> file is set up correctly, then very little StateSet manipulation would have
>> to occur. Is this a correct assumption?
>>
>> Also, there is a bit of confusion in my office as to what effects OVERRIDE
>> and PROTECTED have on a node. It's my understanding that if OVERRIDE is
>> used on a node, then each of that node's children will be forced to use that
>> state unless they have specifically set another value for that state as
>> being PROTECTED.
>>
>> Thanks,
>> Brian
>>
>>
>> On Sat Nov 17 6:26 , 'Robert Osfield' [EMAIL PROTECTED]> sent:
>>
>>
>> >Hi Brian,
>> >
>> >State leakage in the OSG normally suggests that your osg::Geometry
>> >don't have tex coordinates, normals or colour arrays assigned to them
>> >so they are just inheriting them from what was last sent to OpenGL, if
>> >you add more models then the draw order will jump around and your ill
>> >conditioned models will inherit a far wider range of state, exactly
>> >what they'll inherit will change from frame to frame.
>> >
>> >To fix it you have to find out what models are poorly conditioned and
>> >are missing required arrays - if a particular model has a problem then
>> >convert this one to .osg and have a browse through it to see what
>> >arrays are present and which ones are missing.
>> >
>> >Robert.
>> >
>> >On Nov 17, 2007 10:17 AM, Brian [EMAIL PROTECTED]> wrote:
>> >> Hi,
>> >>
>> >> I have a scene in which I am rendering various models on top of a terrain
>> >> database. Without modifying any of the model's statesets, the scene
>> >> renders horribly (textures missing from some models but not others,
>> >> polygons for some models are rendered incorrectly shooting out in all
>> >> directions, etc.) However, if I load them separately into the viewer
>> >> application, they render perfectly fine. Does anyone have any tips for
>> >> finding the perfect stateset so my models and terrain can render
>> >> correctly? The models themselves are in IVE format. I had thought that
>> >> I might be able to convert them all to the OSG format, and then I could
>> >> modify the statesets for all the models to a "standard" setting, but I
>> >> don't know if that would work or be advisable. This route would take a
>> >> great deal of time, and I would like to avoid it if at all possible.
>> >>
>> >> Any help would be greatly appreciated.
>> >>
>> >> Thanks,
>> >> Brian
>> >>
>> >> _______________________________________________
>> >> osg-users mailing list
>> >> [email protected]
>> >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>> >>
>>
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org