Skip to content

Instantly share code, notes, and snippets.

@candycode
Created May 18, 2012 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save candycode/5d7e4fde9857d87b1bd1 to your computer and use it in GitHub Desktop.
Save candycode/5d7e4fde9857d87b1bd1 to your computer and use it in GitHub Desktop.
Add osg_Viewport uniform to GLSL
Index: src/osgUtil/SceneView.cpp
===================================================================
--- src/osgUtil/SceneView.cpp (revision 13031)
+++ src/osgUtil/SceneView.cpp (working copy)
@@ -424,6 +424,11 @@
osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_ViewMatrixInverse",osg::Uniform::FLOAT_MAT4);
uniform->set(osg::Matrix::inverse(getViewMatrix()));
}
+ if( _activeUniforms && getCamera() && getCamera()->getViewport() ) {
+ osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_Viewport",osg::Uniform::FLOAT_VEC2);
+ osg::Viewport* v = getCamera()->getViewport();
+ uniform->set( osg::Vec2( v->width(), v->height() ) );
+ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment