From 1020e22c33ac57e4f14bfac10fd1e889babd2b83 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 20 Apr 2015 09:39:00 +0000 Subject: [PATCH] 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 --- src/osg/State.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/osg/State.cpp b/src/osg/State.cpp index ca31060fa..27329136f 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -1447,6 +1447,18 @@ bool State::convertVertexShaderSourceToOsgBuiltIns(std::string& source) const 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) { 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 "<