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

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


Hi,

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.


Code:

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
     (*tcoords)[1].set(1.0f,0.0f);
     (*tcoords)[2].set(1.0f,1.0f);
     (*tcoords)[3].set(0.0f,1.0f);
-    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;
         texture->setImage(image);
-        stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
+        stateset->setTextureAttributeAndModes(3,texture,osg::StateAttribute::ON);
         geom->setStateSet(stateset);
     }
 




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.

Cheers,
Jannik

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64111#64111








More information about the osg-users mailing list