Hi,
While working with a pretty basic osg-based app I noticed that shader code
modification related vertex attribute aliasing (e.g. renaming from gl_Normal to
osg_Normal and then treating it as a generic vertex attribute) is active if
State::setUseModelViewAndProjectionUniforms(true) is called without much regard
to State::setUseVertexAttributeAliasing(false).
Aside from being a bit counter-intuitive, it led (in my case) to rendering
issues since the shaders modified by osg contain custom attributes like
osg_Normal but osg internally keeps using things like glNormalPointer(..) to
provide the vertex information because of setUseVertexAttributeAliasing(false).
Issues vanish if both setUseModelViewAndProjectionUniforms(..) and
setUseVertexAttributeAliasing(..) set true (or false, obviously).
The fix for me was pretty simple: I needed to surround the code responsible for
aliasing-related shader source alteration in
State::convertVertexShaderSourceToOsgBuiltIns(..) with a single if statement,
i.e.:
Code:
if(_useVertexAttributeAliasing)
{
State_Utils::replaceAndInsertDeclaration(source, declPos,
_vertexAlias._glName, _vertexAlias._osgName,
_vertexAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos,
_normalAlias._glName, _normalAlias._osgName,
_normalAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos,
_colorAlias._glName, _colorAlias._osgName,
_colorAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos,
_secondaryColorAlias._glName, _secondaryColorAlias._osgName,
_secondaryColorAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos,
_fogCoordAlias._glName, _fogCoordAlias._osgName,
_fogCoordAlias._declaration);
for (size_t i=0; i<_texCoordAliasList.size(); i++)
{
const VertexAttribAlias& texCoordAlias = _texCoordAliasList[i];
State_Utils::replaceAndInsertDeclaration(source, declPos,
texCoordAlias._glName, texCoordAlias._osgName, texCoordAlias._declaration);
}
}
Is my understanding of how setUseVertexAttributeAliasing(..) should work
correct? Is the above modification actually a fix or am I missing the point?
Thanks,
Kuba[/code]
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59716#59716
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org