hi everybody,

i have a problem when reading the values of user-defined vertex 
attributes in the vertex shader.

THE SITUATION

i implemented an algorithm which generates tracks, left behind by a car 
which drives on a terrain.
the track of one wheel is logically represented in the following way:

1. an osg geometry:
- osg::ref_ptr<osg::Geometry> trackGeom, carries the primitiveSetList 
consisting of arbitrary primitiveSets (triangles, quads, polygons), 
which are built from vertices in the associated vertex array (see below).

2. several binded arrays:
- osg::ref_ptr<osg::Vec3Array> vertices :
...
trackGeom->setVertexArray(vertices.get());
...
- osg::ref_ptr<osg::Vec4Array> colors :
...
trackGeom->setColorArray(colors.get());
trackGeom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
...
- osg::ref_ptr<osg::Vec2Array> texCoords :
...
trackGeom->setTexCoordArray(0, texCoords.get());
...

to prevent the system from crashing when out of memory (driving for 
several hours, continously generating track polygons) i used the object 
'trackGeom' like a queue:
inserting newly created primitiveSets at position 0 ( 
trackGeom->setPrimitiveSet(0,polygon) ) when maxNumPolygons is reached. 
a simple queue.

everything worked fine.

but then i decided to implement a fade out effect of the tracks, using 
my own vertex shader:

( the idea, for better understanding:
the idea was to associate a vertex attribute array with the vertex 
array, for each vertex storing the number of the frame in which it was 
created and obtain the 'relative frame age' of the vertex by comparing 
the number of the current frame with the number of the 'frame of 
creation'. the obtained 'relative frame age' is then used to calculate 
the alpha value of the vertex in the vertex shader. )

3. the associated vertex attribute array:
- osg::ref_ptr<osg::Vec2Array> frameTime :
...
trackGeom->setVertexAttributeArray(9, frameTime.get());
trackGeom->setVertexAttribuBinding(9, osg::Geometry::BIND_PER_VERTEX);
...

THE PROBLEM

as soon as the polygon queue is filled i get wrong vertex attribute 
values, apparently. the other values like texture coordinates and color 
are fine.
in contrary when using NO polygon queue (just pushing the new polygons 
into 'trackGeom' with ...->addPrimitiveSet(polygon)) the vertex 
attribute values are correct.

could there be a problem with some kind of caching of the vertex attributes?
perhaps somebody experienced a similar problem and can help me.

thanks in advance,
daniel

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

Reply via email to