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 

osggeometryshaders example question


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


Joined: 18 Jun 2015
Posts: 20

PostPosted: Tue Sep 12, 2017 3:12 pm    Post subject:
osggeometryshaders example question
Reply with quote

Hi,

In reference to the osggeometryshaders example, I have a question about a seeming problem when only passing one point to the geometry shader:

If I comment out all but the first push back:
Code:
osg::Vec3Array* vAry = new osg::Vec3Array;
setVertexArray( vAry );
vAry->push_back( osg::Vec3(0,0,0) );
/*vAry->push_back( osg::Vec3(0,1,0) );
vAry->push_back( osg::Vec3(1,0,0) );
vAry->push_back( osg::Vec3(1,1,0) );
vAry->push_back( osg::Vec3(0,0,1) );
vAry->push_back( osg::Vec3(0,1,1) );
vAry->push_back( osg::Vec3(1,0,1) );
vAry->push_back( osg::Vec3(1,1,1) );*/


Nothing shows up. But if I do two, three or more points, every thing works fine. It seems a minimum of two points in the DrawArrays array is required?

Thank you!

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


Joined: 18 Mar 2009
Posts: 11238

PostPosted: Tue Sep 12, 2017 4:29 pm    Post subject:
osggeometryshaders example question
Reply with quote

Hi Mike,


I have just done a quick experiement with the osgshadersexample and found the with one vertex I wouldn't see anything. 

With only a single vertex the bounding box would just be zero sized so the scaling of the camera would likely be a bit off as well as small feature culling wanting to cull this drawable as it would percieve it to be an invisibly small point. To test possibility out I added the line:

        setInitialBound(osg::BoundingBox(0.0f,0.0f,0.0f,1.0f,1.0f,1.0f));


After the set up of the geometry to force the bounding box to a sensible initial size and then it works fine with just a single vertex.  Ideally you'd set the size that the geometry could end up once you apply the vertex/geometry shader modifications so that culling can properly take into account the range the geometry could end up in.



Another approach is you can disable the small feature culling by setting the culling mode to just use the frustum sides (or other modes without SMALL_FEATURE_CULLING see include/osg/CullSettings for details):



    viewer.getCamera()->setCullingMode(osg::CullSettings::VIEW_FRUSTUM_SIDES_CULLING);


You'd also need to set the camera home position as well, but given you will likely have other elements in a real scene graph this is likely not required.


The setInitalBound() or using your own ComputeBoundCallback is probably the most general helpful way to handle position modifications, the Camera settings are really just high level workarounds to this special case of a zero sized scene graph.



Robert.







On 12 September 2017 at 16:12, Mike Greene < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

In reference to the osggeometryshaders example, I have a question about a seeming problem when only passing one point to the geometry shader:

If I comment out all but the first push back:

Code:
osg::Vec3Array* vAry = new osg::Vec3Array;
setVertexArray( vAry );
vAry->push_back( osg::Vec3(0,0,0) );
/*vAry->push_back( osg::Vec3(0,1,0) );
vAry->push_back( osg::Vec3(1,0,0) );
vAry->push_back( osg::Vec3(1,1,0) );
vAry->push_back( osg::Vec3(0,0,1) );
vAry->push_back( osg::Vec3(0,1,1) );
vAry->push_back( osg::Vec3(1,0,1) );
vAry->push_back( osg::Vec3(1,1,1) );*/




Nothing shows up. But if I do two, three or more points, every thing works fine. It seems a minimum of two points in the DrawArrays array is required?

Thank you!

Cheers,
Mike[/code]

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





_______________________________________________
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
tianzjyh
Guest





PostPosted: Wed Sep 13, 2017 1:15 am    Post subject:
osggeometryshaders example question
Reply with quote

Hi,
Beside setting node's bound with setInitialBound(), you can call node's setCullActive() with parameter "false" to disable the culling behavior by node's size, especially for geometry with only one point.

--
Cheers,
TianZJ




Quote:
At 2017-09-12 23:12:45, "Mike Greene" <> wrote:
Quote:
Hi,

In reference to the osggeometryshaders example, I have a question about a seeming problem when only passing one point to the geometry shader:
...
Nothing shows up. But if I do two, three or more points, every thing works fine. It seems a minimum of two points in the DrawArrays array is required?
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71697#71697



------------------
Post generated by Mail2Forum
Back to top
mgreene
User


Joined: 18 Jun 2015
Posts: 20

PostPosted: Wed Sep 13, 2017 12:07 pm    Post subject:
Reply with quote

Thanks!



Cheers,
Mike
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 【NEWBIE】Question about osg::Matri... Jiechang Guo General 5 Fri May 05, 2017 11:54 am View latest post
No new posts osgUtil::Delaunay* question (where is... Trajce Nikolov NICK General 2 Fri Nov 11, 2016 6:19 pm View latest post
No new posts a question on extension functions con... kornerr General 0 Sat Nov 05, 2016 4:56 am View latest post
No new posts Color Change Question szadeklord General 1 Wed Jul 06, 2016 10:05 pm View latest post
No new posts Drawable getBoundingBox() question Rick Irons General 5 Fri Jun 10, 2016 10:10 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