[osg-users] Textured PointSprites broken when upgrading from 3.5.6 to 3.6.2
Robert Osfield
robert.osfield at gmail.com
Wed Sep 5 09:45:19 PDT 2018
HI Brian,
I am not aware of any issues with textured point sprites in 3.6.
If the rendering flickers between states as you move the eye point
then this is an indication that some state hasn't been consistently
set up in your scene graph so that subgraph that is flickering is
inheriting state randomly from other parts of the scene. An undefined
colour array or texture coord array in an osg::Geometry would cause
this type of isse.
With some much application specific code in your code snippets there
really is just too many unkowns for us to be able to guess what may be
wrong.
The best way for us to help would be if you can create a small example
that illustrates the problem. If there is a bug in your code then
just trying to recreate the code might help you spot this. If there
is an actual bug on the OSG side then this example could be used as a
unit test that we can use to reproduce the bug and help with the debug
process.
Cheers,
Robert.
Robert.
On Wed, 5 Sep 2018 at 17:28, Brian Hutchison <bhutchison at systra.com> wrote:
>
> Hi,
>
> We recently upgraded OSG from 3.5.6 to 3.6.2 and our textured PointSprites stopped working.
>
> In a debug build they work fine but in a release build they do not display or, if they do, they display using a translucent version of the non-textured points which flash on and off as we navigate the scene.
>
> The code is based on the osgpointsprite example - which we cannot get to fail.
>
> The code is used by several features all of which have the bug. If we strip it down to just one feature using this code then it still has the bug. If we strip out the textures then default Points work fine on all features.
>
> Using hard-coded textures instead of loading them from files does not help.
>
> We have tried just about everything we can think of and are about to switch to a combination of non-textured points, billboards & simple geometries as a workaround.
>
>
> Code:
>
> addPointSprite(mModel.base().dataPaths.resourcesPath(),
> PointSpriteShapes::Diamond,
> NodePointSizeLarge,
> NodePointSizeSmall,
> NodePointSizeLarge,
> mNodesGeometry);
>
> const std::map<PointSpriteShapes, const std::string> PointSpriteFileNames = {
> {PointSpriteShapes::Circle, "Circle.png"},
> {PointSpriteShapes::Diamond, "Diamond.png"},
> {PointSpriteShapes::Square, "Square.png"},
> {PointSpriteShapes::MarkerRouteStart, "MarkerRouteStart.png"},
> {PointSpriteShapes::MarkerRouteBroken, "MarkerRouteBroken.png"},
> {PointSpriteShapes::MarkerRouteEnd, "MarkerRouteEnd.png"},
> };
>
> void
> addPointSprite(const std::string & aResourcesPath,
> PointSpriteShapes aSpriteShape,
> float aStartingSize,
> float aMinSize,
> float aMaxSize,
> osg::Node * aNode)
> {
> Expects(PointSpriteFileNames.find(aSpriteShape) != PointSpriteFileNames.end());
>
> auto stateset = aNode->getOrCreateStateSet();
>
> osg::ref_ptr<osg::PointSprite> sprite = new osg::PointSprite();
> sprite->setCoordOriginMode(osg::PointSprite::LOWER_LEFT);
> stateset->setTextureAttributeAndModes(0, sprite, osg::StateAttribute::ON);
>
> auto texture = createTexture(aResourcesPath, PointSpriteFileNames.at(aSpriteShape));
> stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
>
> osg::ref_ptr<osg::Point> point = new osg::Point();
> point->setSize(aStartingSize);
> point->setMinSize(aMinSize);
> point->setMaxSize(aMaxSize);
> if (aMaxSize > aMinSize)
> {
> point->setDistanceAttenuation(osg::Vec3{1.0f, 0.001f, 0.0f});
> }
> stateset->setAttribute(point);
> }
>
> inline osg::ref_ptr<osg::Texture2D>
> createTexture(const std::string & aResourcesPath, const std::string & aImageName)
> {
> const auto imagePath = aResourcesPath + "/images/" + aImageName;
> return new osg::Texture2D(osgDB::readRefImageFile(imagePath));
> }
>
>
>
>
> Are you aware of any issues with textures point sprites in 3.5.6, or can you see what we are doing wrong?
>
> Thanks,
>
> Brian[/code]
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=74665#74665
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
More information about the osg-users
mailing list