OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

EXTERNAL: Re: World space normal.


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Rowley, Marlin R
Guest





PostPosted: Wed Jul 11, 2018 4:30 pm    Post subject:
EXTERNAL: Re: World space normal.
Reply with quote

Robert,

Are you suggesting that I compute the world space normal in the application and pass it to the shader? I absolutely need world space coordinates. If so, how would I get the normal of the triangle before evaluating the shader?

----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

From: osg-users <> On Behalf Of Robert Osfield
Sent: Wednesday, July 11, 2018 11:26 AM
To: OpenSceneGraph Users <>
Subject: EXTERNAL: Re: World space normal.

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 dataset will cause mayhem - the do the cals in world coordinates only for datasets with a local origin, it's just a mess for any real-word datasets.



Cheers,

Robert.









On Wed, 11 Jul 2018 at 14:17, Rowley, Marlin R < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:

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

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)



_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11973

PostPosted: Thu Jul 12, 2018 8:32 am    Post subject:
EXTERNAL: Re: World space normal.
Reply with quote

Hi Marlin,

On Wed, 11 Jul 2018 at 19:59, Rowley, Marlin R < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Are you suggesting that I compute the world space normal in the application and pass it to the shader?  I absolutely need world space coordinates. If so, how would I get the normal of the triangle before evaluating the shader?


No, I'm suggesting that you shouldn't be computing anything on the GPU in world coordinates, not positions, not normals, not anything.  Any time you convert coordinates from local object coordinates into world coordinates you introduce issues with precision.  On the CPU you can workaround this by using doubles, but on the GPU this is typically an option, so you are using floats that just can't handle the precision issues.


So if you say you "absolutely need word space coordinates" but I'd say, take a step back, come up with a algorithm that use eye coordinates or local coordinate for doing calculations as this is (absolutely:-) required to avoid precision issues.



This may require being a bit creative, but in the end you whole system will work far better, it'll scale better, it'll avoid precision issues.



Robert. 

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts World space normal. Rowley, Marlin R General 4 Wed Jul 11, 2018 1:18 pm View latest post
No new posts problem with picking/intersecting in ... mue General 1 Sat Jun 09, 2018 11:18 am View latest post
No new posts EXTERNAL: Announcement: VulkanSceneGr... Rowley, Marlin R General 0 Mon Jun 04, 2018 3:00 pm View latest post
No new posts VBO Bug with 3.6.1 and Normal Arrays Daniel Emminizer, Code... General 21 Fri Jun 01, 2018 3:01 pm View latest post
No new posts EXTERNAL: Re: EXTERNAL: Re: FBO setup... Rowley, Marlin R General 0 Thu May 10, 2018 12:56 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP