Hi, Linda > ss->setTextureAttribute(1, tileImgLay); This line is actually does not do anything because default value for 3rd parameter is osg::StateAttribute::OFF You should use either ss->setTextureAttributeAndModes(1, tileImgLay); or ss->setTextureAttribute(1, tileImgLay, osg::StateAttribute::ON); ss->setTextureMode(1, GL_TEXTURE2D_ARRAY, osg::StateAttribute::ON);
Also define version (in first line of your fragment shader) as someone suggested before, because on nvidia hardware it can compile without version sometimes but does not work as expected and shader compiler does not complain about anything. Make sure that images that you loading have same size (128x128) and pixel format. Regarding textures count limitations - this is implementation dependent as stated in gl specification. You can query maximum textures count with glGet(GL_MAX_TEXTURE_UNITS) <- maximum textures count for fixed pipeline multitexturing (about 4 on modern hardware) glGet(GL_MAX_TEXTURE_IMAGE_UNITS) <- maximum textures count accessible in fragment shader program (texture2DArray counts as one texture), 16-32 on modern hardware If you cant get up to GL_MAX_TEXTURE_IMAGE_UNITS textures working check for bad_allock exceptions, and check opengl errors. Cheers, Sergey. 11.06.2011, 12:47, "Linda Lee" <[email protected]>: > Hi, > > I tried add these lines into my code: > > osg::Texture2DArray* tileImgLay; > tileImgLay = new osg::Texture2DArray; > tileImgLay->setTextureSize(128, 128, 2); > tileImgLay->setUseHardwareMipMapGeneration(false); > > tileImgLay->setImage(0, osgDB::readImageFile("test1.bmp")); > tileImgLay->setImage(1, osgDB::readImageFile("est1.bmp")); > ss->setTextureAttribute(1, tileImgLay); > > tileImgLay->setFilter( osg::Texture2DArray::MIN_FILTER, > osg::Texture2DArray::NEAREST); > tileImgLay->setFilter( osg::Texture2DArray::MAG_FILTER, > osg::Texture2DArray::NEAREST); > > ss->addUniform( new osg::Uniform("test", 1) ); > > and in the fragment shader: > > uniform sampler2DArray test; > > and access it using: > > gl_FragColor = texture2DArray(test, vec3(0, 0, 0)); > > However, it fail to work. > > Any ideal why? > > Thank you! > > Cheers, > Linda > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=40370#40370 > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

