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 

conversion from .vert/.frag files to cpp inline


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


Joined: 10 Jul 2014
Posts: 7

PostPosted: Tue May 15, 2018 6:47 am    Post subject:
conversion from .vert/.frag files to cpp inline
Reply with quote

Hi all,

is there any easy 'conversion utility' to create cpp inlined definition of shader sources from .vert / .frag files?

Thanks!

Cheers,
Christoph
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12027

PostPosted: Tue May 15, 2018 7:28 am    Post subject:
conversion from .vert/.frag files to cpp inline
Reply with quote

Hi Christoph,

On 15 May 2018 at 07:47, Christoph Dohmen <> wrote:
Quote:
is there any easy 'conversion utility' to create cpp inlined definition of shader sources from .vert / .frag files?

There is the osg2cpp example, you need to build OpenSceneGraph with
the BULD_EXAMPLES set to ON to build it. To use it to generate cpp
files from your shaders run:


osg2cpp --shader myshaderfile.frag

This will generate a myshaderfile_frag.cpp file that you can include.

Within the OSG code base this is used in the osgParctile, osgTerrain,
osgVolume and osgText libraries - look in their shaders/
subdirectories directories.

The way to use the files in your main source code is also demonstrated
in the above NodeKits, for instance in
OpenSceneGraph/src/osgText/Text.cpp (in 3.6) you'll find:


{
DEBUG_MESSAGE<<"Using shaders/osgText_Text.vert"<<std::endl;

#include "shaders/osgText_Text_vert.cpp"
program->addShader(osgDB::readRefShaderFileWithFallback(osg::Shader::VERTEX,
"shaders/osgText_Text.vert", osgText_Text_vert));
}

{
DEBUG_MESSAGE<<"Using shaders/osgText_Text.frag"<<std::endl;

#include "shaders/osgText_Text_frag.cpp"
program->addShader(osgDB::readRefShaderFileWithFallback(osg::Shader::FRAGMENT,
"shaders/osgText_Text.frag", osgText_Text_frag));
}


This loads the original .vert or .frag file if it's available
otherwise it falls back to the version that is compiled in.

Cheers,
Robert.


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


Joined: 10 Jul 2014
Posts: 7

PostPosted: Tue May 15, 2018 8:28 am    Post subject:
Reply with quote

Hi Robert,

that's it, I tried several osg examples but missed the osg2cpp one Sad

Thank you!

Cheers,
Christoph
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 osgQt include files Michael W. Hall General 2 Sat Aug 11, 2018 9:14 pm View latest post
No new posts How to setup Msvcp2013 so that header... peter_k General 1 Tue Jul 03, 2018 3:14 pm View latest post
No new posts Open to updates to the Doxygen config... Orphen General 2 Thu Jun 28, 2018 6:53 am View latest post
No new posts Writing .osg files: how to set colors... eMiliano General 0 Tue Jun 19, 2018 2:02 pm View latest post
No new posts osgDB::readRefNodeFiles() crashes wit... peter_k General 4 Fri Jun 08, 2018 9:18 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