diff --git a/include/osg/State b/include/osg/State index ed7025a0a..64beb580d 100644 --- a/include/osg/State +++ b/include/osg/State @@ -256,7 +256,7 @@ class OSG_EXPORT State : public Referenced typedef std::vector VertexAttribAliasList; /** Reset the vertex attribute aliasing to osg's default. This method needs to be called before render anything unless you really know what you're doing !*/ - void resetVertexAttributeAlias(bool compactAliasing=true); + void resetVertexAttributeAlias(bool compactAliasing=true, unsigned int numTextureUnits=8); /** Set the vertex attribute aliasing for "vertex". This method needs to be called before render anything unless you really know what you're doing !*/ void setVertexAlias(const VertexAttribAlias& alias) { _vertexAlias = alias; } diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 0ee23fa12..406247426 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -827,18 +827,19 @@ Polytope State::getViewFrustum() const } -void State::resetVertexAttributeAlias(bool compactAliasing) +void State::resetVertexAttributeAlias(bool compactAliasing, unsigned int numTextureUnits) { _texCoordAliasList.clear(); _attributeBindingList.clear(); if (compactAliasing) { - setUpVertexAttribAlias(_vertexAlias,0, "gl_Vertex","osg_Vertex","attribute vec4 "); - setUpVertexAttribAlias(_normalAlias, 1, "gl_Normal","osg_Normal","attribute vec3 "); - setUpVertexAttribAlias(_colorAlias, 2, "gl_Color","osg_Color","attribute vec4 "); + unsigned int slot = 0; + setUpVertexAttribAlias(_vertexAlias, slot++, "gl_Vertex","osg_Vertex","attribute vec4 "); + setUpVertexAttribAlias(_normalAlias, slot++, "gl_Normal","osg_Normal","attribute vec3 "); + setUpVertexAttribAlias(_colorAlias, slot++, "gl_Color","osg_Color","attribute vec4 "); - _texCoordAliasList.resize(5); + _texCoordAliasList.resize(numTextureUnits); for(unsigned int i=0; i<_texCoordAliasList.size(); i++) { std::stringstream gl_MultiTexCoord; @@ -846,11 +847,11 @@ void State::resetVertexAttributeAlias(bool compactAliasing) gl_MultiTexCoord<<"gl_MultiTexCoord"<