[osg-users] World space normal.

Wojciech Lewandowski w.p.lewandowski at gmail.com
Thu Jul 12 06:39:46 PDT 2018


Hi,

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.

Cheers,
Wojtek Lewandowski

czw., 12 lip 2018 o 15:22 Glenn Waldron <gwaldron at gmail.com> napisał(a):

> Marlin,
> This might work:
>
> vec3 normalWorld = mat3(osg_ViewMatrixInverse) * gl_NormalMatrix *
> gl_Normal;
>
> 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.
>
> Glenn Waldron
>
>
> On Wed, Jul 11, 2018 at 9:34 AM Rowley, Marlin R <marlin.r.rowley at lmco.com>
> wrote:
>
>> I have a world space vertex computed as follows:
>>
>>
>>
>> WorldVertex = osg_ViewMatrixInverse * gl_ModelViewMatrix * aVertex;
>>
>>
>>
>> I would like to get the world space normal from this vertex.  Is there an
>> equivalent osg_* matrix that does the same thing?
>>
>>
>>
>> I tried this:
>>
>>
>>
>> NormalWorld = gl_NormalMatrix * gl_Normal;
>>
>>
>>
>> But I know that is only putting the normal in view space.
>>
>>
>>
>> ----------------------------------------
>>
>> 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
>>
> _______________________________________________
> 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/20180712/77a1db2c/attachment.html>


More information about the osg-users mailing list