Hi Paul,

I can't find example that use TextureArray in osg example.
but I can answer to your question.

2011/9/26 Paul Palumbo <[email protected]>

> Where can I find an example on how to use a TextureArray with OSG?
>
> I'm trying to setup a uniform to send this TextureArray to my fragment
> shader and I'm confused on how to do this. Usually, you'd send a texture to
> the shader by setting the texture uniform to the texture number so I thought
> I would need to do this for a TextureArray:
>   geometry->getOrCreateStateSet()->setTextureAttribute(BASE_TEX_ID,
> textureArray, osg::StateAttribute::ON);
>
that is good


>   sset->addUniform(
>        new osg::Uniform(osg::Uniform::SAMPLER_2D_ARRAY, "textureArray",
> BASE_TEX_ID));
>
The third argument is the size of the uniform variable.
1 for value (float, int, vector, textureIndex, ...)
>1 for an array of value (float[], int[], textureIndex[], ...)

the size of the TextureArray is the depth component of Texture2DArray.
you can specify it by Texture2DArray::setDepthTexture(...), or by adding an
image
Texture2DArray::setImage(unsigned int layer, osg::Image * image);


HTH
David Callu


However, when I assign BASE_TEX_ID to 0, I'm getting:
> "Uniform numElements < 1 is invalid"
>
> from this call:
> Uniform::Uniform( Type type, const std::string& name, int numElements ) :
>
> This seems to imply that the third argument to the Uniform constructor
> isn't the texture number but the TextureArray size (?).   Then how do you
> set this TextureArray to a particular texture number?
>
> I'm confused...  Is there an example out there that shows how to use a
> TextureArray?
>
> Paul P.
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=43014#43014
>
>
>
>
>
> _______________________________________________
> 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

Reply via email to