I thought the sampler value was a pointer to a texture? I set the texture unit to 1 because we’ll need the base texture unit 0 later on. My goal is to turn on up to 10 texture units and blend them all together.
To be more clear, he is some more code: mGroupState = mBoundGeometry->getOrCreateStateSet(); mGroupState->getOrCreateUniform("BaseTexSampler", osg::Uniform::SAMPLER_2D)->set(mBaseColor.get()); mGroupState->getOrCreateUniform("BaseWeight", osg::Uniform::FLOAT)->set(mBaseWeight); mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT, mBaseColor, osg::StateAttribute::ON); This sets the base texture unit 1 to be bound to the mBaseColor (which is a osg::ref_ptr<osg::Texture2D>) created before the function call. Then, I do this right afterwards: if (mNumLayers) { int indx = 0; osg::ref_ptr<osg::Texture2D> tex = mTextureMap[indx];// iter->second; mGroupState->getOrCreateUniform("TexLayerSampler0", osg::Uniform::SAMPLER_2D)->set(tex.get()); mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT + 1, tex, osg::StateAttribute::OVERRIDE); } Here I get the texture from a std::map. And then I set the sampler to be bound to the texture. I then bind the texture unit 2 to the texture. -M ---------------------------------------- Marlin Rowley Software Engineer, Staff [cid:image002.jpg@01D39374.DEC5A2E0] Missiles and Fire Control 972-603-1931 (office) 214-926-0622 (mobile) marlin.r.row...@lmco.com<mailto:marlin.r.row...@lmco.com> From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert Osfield Sent: Thursday, April 19, 2018 2:05 PM To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org> Subject: EXTERNAL: Re: [osg-users] Help on multitexturing.. 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.row...@lmco.com<mailto:marlin.r.row...@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 [cid:image002.jpg@01D39374.DEC5A2E0] Missiles and Fire Control 972-603-1931 (office) 214-926-0622 (mobile) marlin.r.row...@lmco.com<mailto:marlin.r.row...@lmco.com> _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org<mailto: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