Re: [osg-users] Help on multitexturing..

2018-04-20 Thread Sebastian Messerschmidt

Hi Marlin,


Re-phrasing Roberts advice:

osg::Uniform* sampler = new osg::Uniform(osg::Uniform::SAMPLER_2D, 
"NameOfTheSamplerInGLSL");

sampler->set(0); //assign unit
ss->addUniform(sampler);
ss->setTextureAttribute(0/*unit*/, texture0 ,osg::StateAttribute:ON );

osg::Uniform* sampler_1 = new osg::Uniform(osg::Uniform::SAMPLER_2D, 
"NameOfTheSamplerInGLSL_1");

sampler->set(1); //assign unit
ss->addUniform(sampler);
ss->setTextureAttribute(1/*unit*/, texture1 ,osg::StateAttribute:ON );

This works fine with two sampler2D objects in GLSL.


HTH & Cheers
Sebastian

Am 19.04.2018 um 20:06 schrieb Rowley, Marlin R:

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 



___
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


Re: [osg-users] Help on multitexturing..

2018-04-19 Thread Robert Osfield
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 
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@01D39374.DEC5A2E0]
>
> *Missiles and Fire Control*
>
> 972-603-1931 (office)
>
> 214-926-0622 (mobile)
>
> marlin.r.row...@lmco.com
>
>
>
> ___
> 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


[osg-users] Help on multitexturing..

2018-04-19 Thread Rowley, Marlin R
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

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org