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 

Setting the transform matrices


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


Joined: 22 Nov 2014
Posts: 24

PostPosted: Wed Aug 09, 2017 8:35 am    Post subject:
Setting the transform matrices
Reply with quote

Hi,

What is the proper way to set the view/projection matrix to a uniform yourself? I've found that trying to deal with the osg_ built-in uniforms which do all sorts of renaming etc is unreliable and would like to be able to just set everything myself manually.

At the moment I'm setting the view / projection matrix uniforms within the camera's initialdrawcallback, but I'm not sure if this is the right way to do it that will ensure the uniform value will only be used within that camera and not within other cameras (since it needs to work across multiple screens and render stages).

Is there some code within OSG that ensures that a uniform assigned to a camera will only apply to the graphics context for the thread that set it?


Thank you!

Cheers,
Chris

_________________
http://www.hrwallingford.com/facilities/ship-simulation-centre
Back to top
View user's profile Send private message
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 767

PostPosted: Wed Aug 09, 2017 8:41 am    Post subject:
Setting the transform matrices
Reply with quote

Hi Chris,


Why are you trying to override the default behavior in the first place?
Simply set the node's matrices by adding a transform node with absolute
reference frame as parent/modify the camera's projection matrix. If you
need it per graphics context you might consider using different scene
graphs per camera(thus context).

Rather than asking for on obscure seeming approach, you might get more
ideas by describing what you are after.

Cheers
Sebastian


Quote:
Hi,

What is the proper way to set the view/projection matrix to a uniform yourself? I've found that trying to deal with the osg_ built-in uniforms which do all sorts of renaming etc is unreliable and would like to be able to just set everything myself manually.

At the moment I'm setting the view / projection matrix uniforms within the camera's initialdrawcallback, but I'm not sure if this is the right way to do it that will ensure the uniform value will only be used within that camera and not within other cameras (since it needs to work across multiple screens and render stages).

Is there some code within OSG that ensures that a uniform assigned to a camera will only apply to the graphics context for the thread that set it?


Thank you!

Cheers,
Chris

------------------------
http://www.hrwallingford.com/facilities/ship-simulation-centre (http://www.hrwallingford.com/facilities/ship-simulation-centre)

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









------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11021

PostPosted: Wed Aug 09, 2017 10:01 am    Post subject:
Setting the transform matrices
Reply with quote

Hi Chris,


I would recommend using the osg_ModelViewMatrix etc. as these are fully supported once you enable them and is far simpler than workarounds like you are trying.  All you need to do is enable the aliasing to get the OSG to generate the uniforms.  The osgsimplegl3 example illustrates how :


    // for non GL3/GL4 and non GLES2 platforms we need enable the osg_ uniforms that the shaders will use,
    // you don't need thse two lines on GL3/GL4 and GLES2 specific builds as these will be enable by default.
    gc->getState()->setUseModelViewAndProjectionUniforms(true);
    gc->getState()->setUseVertexAttributeAliasing(true);


Could you explain what the problem was when trying to the OSG's built in aliasing?


Robert.


On 9 August 2017 at 09:35, Chris Kuliukas < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

What is the proper way to set the view/projection matrix to a uniform yourself? I've found that trying to deal with the osg_ built-in uniforms which do all sorts of renaming etc is unreliable and would like to be able to just set everything myself manually.

At the moment I'm setting the view / projection matrix uniforms within the camera's initialdrawcallback, but I'm not sure if this is the right way to do it that will ensure the uniform value will only be used within that camera and not within other cameras (since it needs to work across multiple screens and render stages).

Is there some code within OSG that ensures that a uniform assigned to a camera will only apply to the graphics context for the thread that set it?


Thank you!

Cheers,
Chris

------------------------
http://www.hrwallingford.com/facilities/ship-simulation-centre (http://www.hrwallingford.com/facilities/ship-simulation-centre)

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





_______________________________________________
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
View user's profile Send private message
ckuliukas
User


Joined: 22 Nov 2014
Posts: 24

PostPosted: Thu Aug 10, 2017 1:11 am    Post subject:
Reply with quote

The problem is whenever I try to use
gc->getState()->setUseModelViewAndProjectionUniforms(true);
gc->getState()->setUseVertexAttributeAliasing(true);
it always seems to screw up something, like the precipitation or particle effects.

I figure if there is a way I can set the projection matrices etc to new variables, instead of overwriting existing gl_whatever variables in shaders, then I can supply my shaders with the data they need without affecting anything else.

_________________
http://www.hrwallingford.com/facilities/ship-simulation-centre
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11021

PostPosted: Thu Aug 10, 2017 5:46 am    Post subject:
Setting the transform matrices
Reply with quote

HI Chris,

On 10 August 2017 at 02:11, Chris Kuliukas < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
The problem is whenever I try to use
    gc->getState()->setUseModelViewAndProjectionUniforms(true);
    gc->getState()->setUseVertexAttributeAliasing(true);
it always seems to screw up something, like the precipitation or particle effects.


This sounds like a bug somewhere.  Could you be specific so we can see if we can reproduce the problem and then hunt down and resolve it.

 
Quote:
I figure if there is a way I can set the projection matrices etc to new variables, instead of overwriting existing gl_whatever variables in shaders, then I can supply my shaders with the data they need without affecting anything else.


There is currently a transition between old fixed function, early GLSL and new GLSL, the introduction of the attribute and built uniform aliasing is part of this transition.  The OSG has to go wholly over to supporting the new GLSL standards so the osg_ uniforms is the way forward.


What specifically is at issue for you is not possible to say as we really don't have enough to go on, attempting to allow local workarounds for the problems you are seeing isn't a good long term solution for you or for us (the more non standard stuff you do locally the less able we are to support you,)


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 setting 2D manipulator bhanu406 General 1 Wed May 31, 2017 4:55 am View latest post
No new posts Setting vertex attribute array of float Bruno Oliveira General 1 Mon Mar 20, 2017 9:55 am View latest post
No new posts uniform buffers for transform stack a... Gedalia Pasternak General 0 Mon Mar 13, 2017 3:17 pm View latest post
No new posts Matrices interpreted wrong in AC load... freqfly Plugins [osgPlugins] 7 Sun Mar 12, 2017 4:37 am View latest post
No new posts Need help with setting/calculating no... szadeklord Plugins [osgPlugins] 1 Wed Jun 29, 2016 12:52 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