[osg-users] How to use more than 4 texture units?

Jannik Heller scrawl at baseoftrash.de
Wed Jun 17 10:45:35 PDT 2015


I seem to have hit the same problem. Texture slots 0-3 work fine, 4 and up don't show.

To reproduce is very simple, you change the osgbillboard example to bind to texture slot 4.


diff --git a/examples/osgbillboard/osgbillboard.cpp b/examples/osgbillboard/osgbillboard.cpp
index a6243e8..07e9274 100644
--- a/examples/osgbillboard/osgbillboard.cpp
+++ b/examples/osgbillboard/osgbillboard.cpp
@@ -67,7 +67,7 @@ osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const
-    geom->setTexCoordArray(0,tcoords);
+    geom->setTexCoordArray(3,tcoords);
     geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
@@ -76,7 +76,7 @@ osg::Drawable* createSquare(const osg::Vec3& corner,const osg::Vec3& width,const
         osg::StateSet* stateset = new osg::StateSet;
         osg::Texture2D* texture = new osg::Texture2D;
-        stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
+        stateset->setTextureAttributeAndModes(3,texture,osg::StateAttribute::ON);

I'm starting to think there's an OSG bug. I know that my graphics card is capable of handling at least 16 fixed function texture units, because it worked fine in my non-OSG based app. I will look more into this and report back.


Read this topic online here:

More information about the osg-users mailing list