<div dir="ltr"><div><div>Hi Marlin,<br><br></div>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.<br><br></div><div>As a general note, normally one would assign a base texture on texture unit 0 rather than 1.<br></div><div><br></div>Robert.<br><div> <br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 19 April 2018 at 19:06, Rowley, Marlin R <span dir="ltr"><<a href="mailto:marlin.r.rowley@lmco.com" target="_blank">marlin.r.rowley@lmco.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="#0563C1" vlink="#954F72" lang="EN-US">
<div class="m_-2348540358210721595WordSection1">
<p class="MsoNormal">Hello,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’ve been wracking my brain all day on trying to figure out how to do this with no clear examples found online.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I have this set of calls in my C++:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:#dadada">mGroupState </span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">=</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> mBoundGeometry</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8"><wbr>getOrCreateStateSet</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">();</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> mGroupState</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">getOrCreateUnifor<wbr>m</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#d69d85">"BaseTexSampler"</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">osg</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">Unifo<wbr>rm</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#b8d7a3">SAMPLER_2D</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">)-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">set</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada">mBaseColo<wbr>r</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">);</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> mGroupState</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">getOrCreateUnifor<wbr>m</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#d69d85">"BaseWeight"</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">osg</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">Uniform</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#b8d7a3"><wbr>FLOAT</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">)-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">set</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada">mBaseWeight</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">);</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"><u></u><u></u></span></p>
<p class="MsoNormal" style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> mGroupState</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">setTextureAttribu<wbr>teAndModes</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">BASE_TEXTURE_UNIT</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> <wbr>mBaseColor</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">osg</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">StateAttribut<wbr>e</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#b8d7a3">ON</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">);</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’ve bound this base texture to texture unit (BASE_TEXTURE_UNIT = 1).<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Later in the code, I have this in another function if I create another layer with another texture:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<pre style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:#dadada">mGroupState</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">getOrCreateUnifor<wbr>m</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#d69d85">"TexLayerSampler0"</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">osg</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">Uni<wbr>form</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#b8d7a3">SAMPLER_2D</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">)-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">set</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">tex</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">);</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"><u></u><u></u></span></pre>
<pre style="background:#1e1e1e"><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> mGroupState</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">-></span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">setTextureAttribu<wbr>te</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">(</span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">BASE_TEXTURE_UNIT</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">+</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#b5cea8">1</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"> </span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">tex</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">,</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"><wbr> </span><span style="font-size:14.5pt;font-family:Consolas;color:#c8c8c8">osg</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#4ec9b0">StateAttribute</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">::</span><span style="font-size:14.5pt;font-family:Consolas;color:#b8d7a3">ON</span><span style="font-size:14.5pt;font-family:Consolas;color:#b4b4b4">);</span><span style="font-size:14.5pt;font-family:Consolas;color:#dadada"><u></u><u></u></span></pre>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Where I’ve created a second texture and want it to reside in texture unit 2.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">However, in my shader code when indexing the TexLayerSampler0, I only get base texture.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="line-height:18.0pt;background:#1e1e1e"><span style="font-size:13.5pt;font-family:Consolas;color:#d4d4d4">finalColor =
</span><span style="font-size:13.5pt;font-family:Consolas;color:#dcdcaa">texture</span><span style="font-size:13.5pt;font-family:Consolas;color:#d4d4d4">(TexLayerSampler0, LayeredTexCoords[</span><span style="font-size:13.5pt;font-family:Consolas;color:#b5cea8">0</span><span style="font-size:13.5pt;font-family:Consolas;color:#d4d4d4">].</span><span style="font-size:13.5pt;font-family:Consolas;color:#9cdcfe">st</span><span style="font-size:13.5pt;font-family:Consolas;color:#d4d4d4">);<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Which is wrong. I’m stil trying to figure out OpenGL and how it works along with OSG so sorry for the inexperience.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">-M<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d">------------------------------<wbr>----------<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d">Marlin Rowley<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d">Software Engineer, Staff<u></u><u></u></span></p>
<p class="MsoNormal"><img style="width:1.625in;height:.4166in" id="m_-2348540358210721595Picture_x0020_1" src="cid:image001.jpg@01D3D7DE.A1C88160" alt="cid:image002.jpg@01D39374.DEC5A2E0" height="40" width="156"><span style="font-size:10.0pt;font-family:"Times New Roman",serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><i><span style="font-size:12.0pt;font-family:"Times New Roman",serif;color:#1f497d">Missiles and Fire Control</span></i><span style="color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d">972-603-1931 (office)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d">214-926-0622 (mobile)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><a href="mailto:marlin.r.rowley@lmco.com" target="_blank"><span style="color:#0563c1">marlin.r.rowley@lmco.com</span></a></span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<br>______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.<wbr>openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a><br>
<br></blockquote></div><br></div>