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 

Matrix multiplication order


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Flogo
User


Joined: 08 Apr 2016
Posts: 26

PostPosted: Thu Mar 22, 2018 9:53 am    Post subject:
Matrix multiplication order
Reply with quote

Hi everyone !

I don't get why in GLSL you transform a vertex like this:

Code:
vec4 result = matrix * vertex;


While in OSG I have to do it in the reverse order :

Code:
osg::Vec4 result = vertex * matrix;


Is it due to the Matrices major mode that are different from OpenGL and OpenSceneGraph ?

Thanks for demystifying me!
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11971

PostPosted: Thu Mar 22, 2018 11:09 am    Post subject:
Matrix multiplication order
Reply with quote

Hi Florian,

The difference is down to history, the OSG is row major chosen very
earliest days of the OSG (back in 2000) and OpenGL 1.x days, and
OpenGL GLSL ended choosing column major a few years later. The OpenGL
matrices are actually stored the same way as OSG matrices in main
memory.

To change the OSG to be the same convention would have broken user
applications that had already adopted the OSG so I chose not to change
the order once OpenGL GLSL came out. I now regret not just biting the
bullet and forcing the OSG community to swtich, it would have been
painful, but obviously would have easier for new developers. However,
now we even more code base that works with the OSG multiplication
order so it would be even more painful to convert across so we are
stuck.

Robert.


On 22 March 2018 at 09:53, Florian GOLESTIN <> wrote:
Quote:
Hi everyone !

I don't get why in GLSL you transform a vertex like this:


Code:
vec4 result = matrix * vertex;



While in OSG I have to do it in the reverse order :


Code:
osg::Vec4 result = vertex * matrix;



Is it due to the Matrices major mode that are different from OpenGL and OpenSceneGraph ?

Thanks for demystifying me!

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73145#73145








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Flogo
User


Joined: 08 Apr 2016
Posts: 26

PostPosted: Thu Mar 22, 2018 1:13 pm    Post subject:
Reply with quote

Hi Robert,

Thanks for the answer, I understand now.

I worked as a Support Engineer and understand the hard choice of breaking an API Smile

Florian
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11971

PostPosted: Thu Mar 22, 2018 1:54 pm    Post subject:
Matrix multiplication order
Reply with quote

On 22 March 2018 at 13:13, Florian GOLESTIN <> wrote:
Quote:
Hi Robert,

Thanks for the answer, I understand now.

I worked as a Support Engineer and understand the hard choice of breaking an API Smile

Paradoxically I would probably have made the change if I could have
broken the API and forced users to change the problematic code with
the compiler pinpointing the problems. With a change in convention
the code remains compatible so will compile without any issues but
will silently start behaving differently. Users would end up with
applications that compile and run but have these bugs lurking and
appearing in odd, difficult to understand ways.

Another paradox is that OpenGL matrices are stored in main memory as
row major, but the GLSL convention is column major.

Software engineering can just get a bit messy sometimes even when you
have the best of intentions!

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 Stuck with applying an offset to proj... wernerM General 5 Mon Jun 25, 2018 10:11 am View latest post
No new posts Positioning an object based on the Vi... Takarashy General 0 Wed May 23, 2018 3:14 pm View latest post
No new posts Draw two translucent geometries in sp... krikr42 General 8 Fri May 18, 2018 1:42 pm View latest post
No new posts EXTERNAL: Re: Getting the combined ma... Rowley, Marlin R General 0 Tue May 08, 2018 3:25 pm View latest post
No new posts Getting the combined matrix from a Node? Rowley, Marlin R General 2 Mon May 07, 2018 7:01 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