<div dir="ltr">Hi,<div><br><div>Was going to propose what Glenn already proposed. This should work with uniform scales on x,y,z coord. And IMHO that formula is more precise when dealing with normals than vertices. Thats because the precision issues are somewhat related to huge earth translation offsets in ModelView matrix. NormalMatrix and mat3(osg_ViewMatrixInvers) not include the translation offset part.</div></div><div><br></div><div>Cheers,</div><div>Wojtek Lewandowski</div></div><br><div class="gmail_quote"><div dir="ltr">czw., 12 lip 2018 o 15:22 Glenn Waldron <<a href="mailto:gwaldron@gmail.com">gwaldron@gmail.com</a>> napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Marlin,<div>This might work:</div><div><br></div><div>vec3 normalWorld = mat3(osg_ViewMatrixInverse) * gl_NormalMatrix * gl_Normal;</div><div><br></div><div>But like Robert says, world coordinates on the GPU will lead to precision loss, so only do it if you are content with a low-precision result.</div><div><br clear="all"><div><div dir="ltr" class="m_-7805903657793467086gmail_signature" data-smartmail="gmail_signature"><div class="m_-7805903657793467086gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Glenn Waldron</div></div></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 11, 2018 at 9:34 AM Rowley, Marlin R <<a href="mailto:marlin.r.rowley@lmco.com" target="_blank">marlin.r.rowley@lmco.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="m_-7805903657793467086m_-4251815879523918795WordSection1">
<p class="MsoNormal">I have a world space vertex computed as follows:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">WorldVertex = osg_ViewMatrixInverse * gl_ModelViewMatrix * aVertex;<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I would like to get the world space normal from this vertex. Is there an equivalent osg_* matrix that does the same thing?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I tried this:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">NormalWorld = gl_NormalMatrix * gl_Normal; <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">But I know that is only putting the normal in view space.<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">----------------------------------------<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 width="156" height="40" style="width:1.625in;height:.4166in" id="m_-7805903657793467086m_-4251815879523918795Picture_x0020_1" alt="cid:image002.jpg@01D39374.DEC5A2E0"><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>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div>