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 

Scale problem while transforming object in vertex shader


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


Joined: 31 Mar 2017
Posts: 20

PostPosted: Sat Apr 15, 2017 4:26 pm    Post subject:
Scale problem while transforming object in vertex shader
Reply with quote

Hi,

I have a transform matrix and I want to apply it in shader. I pass it into uniform and set gl_Position = gl_ModelViewProjectionMatrix*my_transfrom_matrix*gl_Vertex.
If I set translate only, everything is ok. If I set translate and scale - translate multiplies by scale and transform is wrong (object is too far if scale>1.0). If I apply this transform not using shader (by SetMatrix) everything is ok. What I am doing wrong?


Thank you!

Cheers,
Yura
Back to top
View user's profile Send private message
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 725

PostPosted: Tue Apr 18, 2017 7:27 am    Post subject:
Scale problem while transforming object in vertex shader
Reply with quote

Hi Yura
Quote:
Hi,

I have a transform matrix and I want to apply it in shader. I pass it into uniform and set gl_Position = gl_ModelViewProjectionMatrix*my_transfrom_matrix*gl_Vertex.
If I set translate only, everything is ok. If I set translate and scale - translate multiplies by scale and transform is wrong (object is too far if scale>1.0). If I apply this transform not using shader (by SetMatrix) everything is ok. What I am doing wrong?
Matrix multiplication is not cummutative in every case.
Try
gl_Position = gl_ModelViewMatrix * matrix * gl_ProjectionMatrix *
gl_Vertex.

Cheers
Sebastian
Quote:


Thank you!

Cheers,
Yura

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









------------------
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 A problem with regard to std:istream ... first_gle General 1 Fri May 26, 2017 6:11 am View latest post
No new posts draw primitive sets and geometry shad... wernerM General 0 Wed May 24, 2017 3:20 pm View latest post
No new posts passing material properties to shader... gpantar General [forum] 0 Mon May 15, 2017 1:17 pm View latest post
No new posts scene object not receiving/casting sh... Meldryt General 0 Thu May 11, 2017 8:01 am View latest post
No new posts Regarding Lod problem in osg Rambabu General 0 Fri Apr 28, 2017 5:12 am 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