2011/9/26 Paul Palumbo <paul1...@yahoo.com>

> Let me phrase my question better...
>
> How do I associate a Texture2DArray defined in my stateset with a
> particular Uniform so that it can be accessible in the shader? For regular
> textures, this would be done using the Texture Unit number.
>

this is the same thing for Texture2DArray, you define the Texture Unit
number in the StateSet
and in the uniform:

int textureUnit = 0;
osg::StateSet * ss = node->getOrCreateStateSet();
ss->setTextureAttributeAndMode( textureUnit, textureObject );

osg::Uniform * uniform = new osg::Uniform(osg::Uniform::SAMPLER_2D_ARRAY,
"textureArray", 1);
uniform->set( textureUnit );
or
uniform->set( (int) 0 );  // don't forget to cast in int, some compiler
define 0 as an unsigned int

ss->addUniform(uniform);



Also, is it valid to have a Texture2DArray defined as having a texture
> format of GL_LUMINANCE_ALPHA32F_ARB?
>
> I've defined my texture array like this:
>
> Code:
> osg::Texture2DArray *textureArray = new osg::Texture2DArray();
> textureArray->setTextureSize(0, 0, depth);
>

textureSize = 0, 0, depth,
you have depth texture, with each have a size of 0 by 0, strange.
the size must be the size of texture read in the loop 'for (int i = 0;
i<depth; i++) ...'


>
> textureArray->setInternalFormatMode(osg::Texture2DArray::USE_IMAGE_DATA_FORMAT);
>
> textureArray->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR_MIPMAP_LINEAR);
> textureArray->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
> textureArray->setUseHardwareMipMapGeneration(true);
>
> for (int i = 0; i<depth; i++)
> {
>   char filenameStr[1040];
>   snprintf(filenameStr, 1040, "/%06d.tiff", i);
>   std::string filename = directory + filenameStr;
>   osg::ref_ptr<osg::Image> image = osgDB::readImageFile(filename);
>   image->setInternalTextureFormat(GL_LUMINANCE_ALPHA32F_ARB);
>   textureArray->setImage(i, image.get());
> }
> geode->addDrawable(polyGeom);
> polyGeom->getOrCreateStateSet()->setTextureAttribute(TEX_ARRAY_ID,
> textureArray, osg::StateAttribute::ON);
> osg::ref_ptr<osg::Uniform> TextureArrayUniform =
>      new osg::Uniform(osg::Uniform::SAMPLER_2D_ARRAY, "textureArray",
> TEX_ARRAY_ID);
>

here, there are an error, this is not TEX_ARRAY_ID but just 1, see note
before.



> geode->getOrCreateStateSet()->addUniform(TextureArrayUniform.get());
>
>
> This is too complicate to give you a valid answer, depend to your hardware
and need to look OpenGL specification.
 You can use the free tool gDEBugger <http://www.gremedy.com/> to debug your
opengl call.
 You can specify to gDEBugger to break on openGL error.
 and you immediatly know what opengl function call do an error.

HTH
David Callu

>
> And I'm getting this OpenGL error when compiling my TextureArray:
>
> > Warning: detected OpenGL error 'invalid enumerant' at
> StateSet::compileGLObejcts() compiling texture attribute.
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=43018#43018
>
>
>
>
>
> _______________________________________________
> 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

Reply via email to