Re: [osg-users] How to use more than 4 texture units?
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 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to use more than 4 texture units?
Oops, posted wrong code - that should have been 4 instead of 3, of course. Code: diff --git a/examples/osgbillboard/osgbillboard.cpp b/examples/osgbillboard/osgbillboard.cpp index a6243e8..64f893c 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(4,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(4,texture,osg::StateAttribute::ON); geom-setStateSet(stateset); } -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64112#64112 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to use more than 4 texture units?
Hi Jannik, I suspect your driver only supports 4 texture units using the fixed function. Check the GL_MAX_TEXTURE_UNITS value to verify: GLint units; glGetIntegerv(GL_MAX_TEXTURE_UNITS, units); My GeForce GTX 760 only supports 4 fixed function texture units, but up to 32 units using the shader pipeline. Are you sure the non-OSG based app was using the fixed function pipeline? Cheers, Farshid On Wed, Jun 17, 2015 at 10:47 AM, Jannik Heller scr...@baseoftrash.de wrote: Oops, posted wrong code - that should have been 4 instead of 3, of course. Code: diff --git a/examples/osgbillboard/osgbillboard.cpp b/examples/osgbillboard/osgbillboard.cpp index a6243e8..64f893c 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(4,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(4,texture,osg::StateAttribute::ON); geom-setStateSet(stateset); } -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64112#64112 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to use more than 4 texture units?
Hi Farshid, Are you sure the non-OSG based app was using the fixed function pipeline? Ah, that's most definitely it. Yes, I was using shaders before. I totally forgot there were separate limits for fixed-function and shader texture units. Thanks for the help, Jannik -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64114#64114 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to use more than 4 texture units?
Hi Hailong, The OSG itself places no restriction on the number of texture units, but some OpenGL drivers can do, particularly for the fixed function pipeline, perhaps you are hitting up against this. I know that NVIdia have recently reduced the number of texture units they support using the fixed function pipeline. Robert. On 21 January 2014 14:37, Hailong FU longlong_...@163.com wrote: Hi, Right now I am texturing a digital surface model using many (more than 4) airborne images, for example I want to texture the 6 facades of a building. I am using OSG to do the meshing and texturing. However, I found one object can only show the first 4 image textures, the 5th 6th won't show up. What's the problem when I use more than 4 texture units for one geometry? Could you give some hint please? osg::ref_ptrosg::StateSet stateOne = new osg::StateSet(); stateOne-setDataVariance(osg::Object::DYNAMIC); for(int i=0; i imgs; i++) { osg::ref_ptrosg::Texture2D texture = new osg::Texture2D; texture-setDataVariance(osg::Object::DYNAMIC); texture-setImage(img[i]); texture-setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_BORDER); texture-setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_BORDER); texture-setWrap(osg::Texture::WRAP_R,osg::Texture::CLAMP_TO_BORDER); texture-setBorderColor(osg::Vec4d(1,1,1,0)); osg::ref_ptrosg::TexEnv texenv = new osg::TexEnv; texenv-setMode(osg::TexEnv::MODULATE); stateOne-setTextureAttribute(i,texenv,osg::StateAttribute::ON); texture-setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT); texture-setResizeNonPowerOfTwoHint(1); stateOne-setTextureAttributeAndModes(i,texture,osg::StateAttribute::ON); } geode-getDrawable(0)-setStateSet(stateOne); ... Thank you! Cheers, Hailong -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57945#57945 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How to use more than 4 texture units?
Hi, Right now I am texturing a digital surface model using many (more than 4) airborne images, for example I want to texture the 6 facades of a building. I am using OSG to do the meshing and texturing. However, I found one object can only show the first 4 image textures, the 5th 6th won't show up. What's the problem when I use more than 4 texture units for one geometry? Could you give some hint please? osg::ref_ptrosg::StateSet stateOne = new osg::StateSet(); stateOne-setDataVariance(osg::Object::DYNAMIC); for(int i=0; i imgs; i++) { osg::ref_ptrosg::Texture2D texture = new osg::Texture2D; texture-setDataVariance(osg::Object::DYNAMIC); texture-setImage(img[i]); texture-setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_BORDER); texture-setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_BORDER); texture-setWrap(osg::Texture::WRAP_R,osg::Texture::CLAMP_TO_BORDER); texture-setBorderColor(osg::Vec4d(1,1,1,0)); osg::ref_ptrosg::TexEnv texenv = new osg::TexEnv; texenv-setMode(osg::TexEnv::MODULATE); stateOne-setTextureAttribute(i,texenv,osg::StateAttribute::ON); texture-setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT); texture-setResizeNonPowerOfTwoHint(1); stateOne-setTextureAttributeAndModes(i,texture,osg::StateAttribute::ON); } geode-getDrawable(0)-setStateSet(stateOne); ... Thank you! Cheers, Hailong -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57945#57945 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org