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 

osg::Vec3Array as uniform to Shader


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


Joined: 11 Jun 2015
Posts: 57
Location: Brazil

PostPosted: Sat Mar 03, 2018 8:41 pm    Post subject:
osg::Vec3Array as uniform to Shader
Reply with quote

Hi,

can I pass a osg::Vec3Array as uniform to Shader?

...

Thank you!

Cheers,
Rômulo
Back to top
View user's profile Send private message
romulogcerqueira
User


Joined: 11 Jun 2015
Posts: 57
Location: Brazil

PostPosted: Sun Mar 04, 2018 5:56 am    Post subject:
Reply with quote

Hi,

I found a way to solve this problem: converting the array to texture.

Follows an example:

Code:

osg::ref_ptr<osg::Image> image = new osg::Image;
image->setImage(myVec3Array->size(), 1, 1, GL_RGBA8, GL_RGBA, GL_FLOAT, (unsigned char*) &myVec3Array[0], osg::Image::NO_DELETE);

osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
texture->setImage(image);

...

ss->addUniform( new osg::Uniform("vertexMap", texture) );


...

Thank you!

Cheers,
Rômulo[/code]
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12094

PostPosted: Sun Mar 04, 2018 9:17 am    Post subject:
osg::Vec3Array as uniform to Shader
Reply with quote

The three options you have are :

To use the array support in osg::Uniform that enables use of array
of Vec3, It internally manages the array so you
can't just pass in an osg::Vec3Array, by you have
setNumElements/setElement(..) methods.

To use an float RGB osg::Image like you have done

To use the shader_pipeline branch that as a osg::Vec3ArrayUniform
class, this isn't an osg::Vec3Array but is
pretty close,


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


Joined: 11 Jun 2015
Posts: 57
Location: Brazil

PostPosted: Mon Mar 05, 2018 9:15 pm    Post subject:
Reply with quote

Thanks, Robert.
...

Thank you!

Cheers,
Rômulo
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 with output - OSG/Shader romulogcerqueira General 3 Sat Aug 04, 2018 6:36 pm View latest post
No new posts OSG vec3array size() function working... ak477 General 0 Fri Jul 06, 2018 5:57 pm View latest post
No new posts Constructor parameters of osg::Uniform wernerM General 5 Thu Jun 28, 2018 11:29 am View latest post
No new posts Shader Program stops working after Ch... ceranco General 0 Mon May 21, 2018 3:09 pm View latest post
No new posts Shader composition with multiple func... hartwigw General 1 Sat May 12, 2018 9:59 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