Re: [osg-users] World space normal.

2018-07-12 Thread Wojciech Lewandowski
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.

Re: [osg-users] World space normal.

2018-07-12 Thread Glenn Waldron
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

Re: [osg-users] World space normal.

2018-07-11 Thread Robert Osfield
Hi Marlin, It can be done, but I strongly recommend that you don't go transforming vertex or normal data into world coordinates in the shader. I know there are some published algorithms that do this but it's a really bad practice and you shouldn't follow it as precision issues on only proper

Re: [osg-users] World space normal.

2018-07-11 Thread shayne.tueller
raph Users Subject: [osg-users] World space normal. 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

[osg-users] World space normal.

2018-07-11 Thread Rowley, Marlin R
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 *