Moved uniform substitution to infront of vertex attribute substituion to make sure gl_Vertex usage is replaced when required.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14848 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
parent
14ef282297
commit
1020e22c33
@ -1447,6 +1447,18 @@ bool State::convertVertexShaderSourceToOsgBuiltIns(std::string& source) const
|
|||||||
declPos = 0;
|
declPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_useModelViewAndProjectionUniforms)
|
||||||
|
{
|
||||||
|
// replace ftransform as it only works with built-ins
|
||||||
|
State_Utils::replace(source, "ftransform()", "gl_ModelViewProjectionMatrix * gl_Vertex");
|
||||||
|
|
||||||
|
// replace built in uniform
|
||||||
|
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ModelViewMatrix", "osg_ModelViewMatrix", "uniform mat4 ");
|
||||||
|
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ModelViewProjectionMatrix", "osg_ModelViewProjectionMatrix", "uniform mat4 ");
|
||||||
|
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ProjectionMatrix", "osg_ProjectionMatrix", "uniform mat4 ");
|
||||||
|
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_NormalMatrix", "osg_NormalMatrix", "uniform mat3 ");
|
||||||
|
}
|
||||||
|
|
||||||
if (_useVertexAttributeAliasing)
|
if (_useVertexAttributeAliasing)
|
||||||
{
|
{
|
||||||
State_Utils::replaceAndInsertDeclaration(source, declPos, _vertexAlias._glName, _vertexAlias._osgName, _vertexAlias._declaration);
|
State_Utils::replaceAndInsertDeclaration(source, declPos, _vertexAlias._glName, _vertexAlias._osgName, _vertexAlias._declaration);
|
||||||
@ -1461,18 +1473,6 @@ bool State::convertVertexShaderSourceToOsgBuiltIns(std::string& source) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_useModelViewAndProjectionUniforms)
|
|
||||||
{
|
|
||||||
// replace ftransform as it only works with built-ins
|
|
||||||
State_Utils::replace(source, "ftransform()", "gl_ModelViewProjectionMatrix * gl_Vertex");
|
|
||||||
|
|
||||||
// replace built in uniform
|
|
||||||
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ModelViewMatrix", "osg_ModelViewMatrix", "uniform mat4 ");
|
|
||||||
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ModelViewProjectionMatrix", "osg_ModelViewProjectionMatrix", "uniform mat4 ");
|
|
||||||
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ProjectionMatrix", "osg_ProjectionMatrix", "uniform mat4 ");
|
|
||||||
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_NormalMatrix", "osg_NormalMatrix", "uniform mat3 ");
|
|
||||||
}
|
|
||||||
|
|
||||||
OSG_INFO<<"-------- Converted source "<<std::endl<<source<<std::endl<<"----------------"<<std::endl;
|
OSG_INFO<<"-------- Converted source "<<std::endl<<source<<std::endl<<"----------------"<<std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user