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: 789

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 Problem compiling OSG 3.4.1 osgDB 64 bit tonyor Build system [build] 0 Thu Sep 21, 2017 12:41 am View latest post
No new posts Post Processing Effect - Vertex Shade... guyv General 27 Sat Sep 16, 2017 3:48 am View latest post
No new posts Pro Process Effect Vertex Shader not ... guyv General 1 Fri Sep 15, 2017 10:22 pm View latest post
No new posts Post Process Effect Vertex Shader guyv General 1 Fri Sep 15, 2017 8:29 pm View latest post
No new posts Post Process Effect Shader guyv General 1 Fri Sep 15, 2017 8:27 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