[osg-users] Help on multitexturing..

Robert Osfield robert.osfield at gmail.com
Thu Apr 19 12:04:59 PDT 2018


Hi Marlin,

The sampler value should be an int, so you shouldn't pass a texture pointer
to your setting of the TexLayerSampler0 second sampler.  Perhaps this was
just a copy and paste error.

As a general note, normally one would assign a base texture on texture unit
0 rather than 1.

Robert.



On 19 April 2018 at 19:06, Rowley, Marlin R <marlin.r.rowley at lmco.com>
wrote:

> Hello,
>
>
>
> I’ve been wracking my brain all day on trying to figure out how to do this
> with no clear examples found online.
>
>
>
> I have this set of calls in my C++:
>
>
>
> mGroupState = mBoundGeometry->getOrCreateStateSet();
>
>       mGroupState->getOrCreateUniform("BaseTexSampler", osg::Uniform::
> SAMPLER_2D)->set(mBaseColor);
>
>       mGroupState->getOrCreateUniform("BaseWeight", osg::Uniform::FLOAT)->
> set(mBaseWeight);
>
>       mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT,
> mBaseColor, osg::StateAttribute::ON);
>
>
>
> I’ve bound this base texture to texture unit (BASE_TEXTURE_UNIT = 1).
>
>
>
> Later in the code, I have this in another function if I create another
> layer with another texture:
>
>
>
> mGroupState->getOrCreateUniform("TexLayerSampler0", osg::Uniform::SAMPLER_2D)->set(tex);
>
>             mGroupState->setTextureAttribute(BASE_TEXTURE_UNIT + 1, tex, osg::StateAttribute::ON);
>
>
>
> Where I’ve created a second texture and want it to reside in texture unit
> 2.
>
>
>
> However, in my shader code when indexing the TexLayerSampler0, I only get
> base texture.
>
>
>
> finalColor = texture(TexLayerSampler0, LayeredTexCoords[0].st);
>
>
>
> Which is wrong.  I’m stil trying to figure out OpenGL and how it works
> along with OSG so sorry for the inexperience.
>
>
>
> -M
>
>
>
> ----------------------------------------
>
> Marlin Rowley
>
> Software Engineer, Staff
>
> [image: cid:image002.jpg at 01D39374.DEC5A2E0]
>
> *Missiles and Fire Control*
>
> 972-603-1931 (office)
>
> 214-926-0622 (mobile)
>
> marlin.r.rowley at lmco.com
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180419/28dd158c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 3114 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180419/28dd158c/attachment.jpg>


More information about the osg-users mailing list