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 

Hardware skinning computeBound() calculation


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


Joined: 10 Mar 2009
Posts: 58

PostPosted: Thu Jan 18, 2018 4:18 pm    Post subject:
Hardware skinning computeBound() calculation
Reply with quote

I've recently run in to what I believe is a bug.

I'm currently using hardware skinning to animate a character and I'm having some issues with the bounding box calculation of the character.

It seems that applying a scale transform in a parent MatrixTransform is giving me the wrong bounding box size.

For example...

compute bound on the drawables gives me the correct bounding box dimensions, in this case ~14.0.
As computeBound() returns back through the node path during it's calculation the scale gets applied to it and the final radius of the bounding sphere is ~.14.


I am not sure why this is occurring as this functionality seems to work correctly on objects that are not skinned on the hardware.


-Steve
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 396
Location: France

PostPosted: Fri Jan 19, 2018 2:09 pm    Post subject:
Re: Hardware skinning computeBound() calculation
Reply with quote

Hi Steve,

I hope it's the last time i explain that:

-Do you know how hardware skinning work?
If it's the case you know that transformation are managed through vertex shader, so you can't expect osg to keep track of correctly transformed bounds

-Have you look at RigGeometry constuctor?
in osganimation default policy is to scale by 2 untransformed bounds, but it can be user defined via setInitialBound or setComputeBoundCallback.

If your bug persists, give us the model to reproduce.

Cheers

DrPowers wrote:
I've recently run in to what I believe is a bug.

I'm currently using hardware skinning to animate a character and I'm having some issues with the bounding box calculation of the character.

It seems that applying a scale transform in a parent MatrixTransform is giving me the wrong bounding box size.

For example...

compute bound on the drawables gives me the correct bounding box dimensions, in this case ~14.0.
As computeBound() returns back through the node path during it's calculation the scale gets applied to it and the final radius of the bounding sphere is ~.14.


I am not sure why this is occurring as this functionality seems to work correctly on objects that are not skinned on the hardware.


-Steve
Back to top
View user's profile Send private message Visit poster's website
DrPowers
User


Joined: 10 Mar 2009
Posts: 58

PostPosted: Tue Jan 30, 2018 5:38 pm    Post subject:
Reply with quote

I understand this completely and realize that compute bound will return something incorrect since the vertices are manipulated on the vertex shader.

I might have misrepresented my issue.

Even if I set the initial bound to be something I believe is correct... lets say radius=20. The problem is that there are scale transforms in the parental scene graph somewhere that then shrink this radius down to radius=2.

Currently I traverse the node path and apply the inverse of the scale to the initial bound so that initially it is radius=200 and will then pass return it's way back up to result in radius=20.

My question is... is this the correct way of doing this? Is there a better way to compute the bound of the hardware skinned bounding box or am I doing this correctly??
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 396
Location: France

PostPosted: Tue Jan 30, 2018 6:26 pm    Post subject:
Reply with quote

Hi Steve
You say to have a transform scaling x0.1
so you want that shrink your rig...
But you seams not to want the initial bound to be shrink as well
I don't understand what you're doing?

If you want to compute correctbound of a HWskinned rig from the CPU the solution is to merge both SoftWare and HW RigTransform and do the transform on the CPU and GPU independantly.
It's what is done in osgCal but in osg we've choose not to duplicate job so you'll have to write a custom RigTransform for it.
Perhaps I'll do it my self one day but I've always found a way to circumvent the problem with initial bound

Edit: I've also solve the determination of initalbound in another fashion for the purpose of animation baking:
-set initial technique to Software
-artificially update it with an UpdateVisitor you control timestamp and playing all animation
- after each UpdateVisitor exapand a bb by the current computebound
At the end you have the maximal initialbound that garantee you rig not to be badly cull .




Cheers


DrPowers wrote:
I understand this completely and realize that compute bound will return something incorrect since the vertices are manipulated on the vertex shader.

I might have misrepresented my issue.

Even if I set the initial bound to be something I believe is correct... lets say radius=20. The problem is that there are scale transforms in the parental scene graph somewhere that then shrink this radius down to radius=2.

Currently I traverse the node path and apply the inverse of the scale to the initial bound so that initially it is radius=200 and will then pass return it's way back up to result in radius=20.

My question is... is this the correct way of doing this? Is there a better way to compute the bound of the hardware skinned bounding box or am I doing this correctly??
Back to top
View user's profile Send private message Visit poster's website
DrPowers
User


Joined: 10 Mar 2009
Posts: 58

PostPosted: Tue Jan 30, 2018 6:43 pm    Post subject:
Reply with quote

Thanks for the attention Julien.

I'm setting my initial bound for the drawable equal to the computeBound() returned by the initial geometry, which gives me radius = 20. This calculation does not have the scale applied to it.

The character (a whale in this example) renders with dimensions around 20m which should be wrong since there is a scale value of 0.1 applied within it's node path. I would expect to see the whale render with dimensions around 2m

Something somewhere is not getting scaled properly. It's either the hardware skinning (my guess) or something else. Let me try some things and get back with further information.
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 396
Location: France

PostPosted: Tue Jan 30, 2018 8:42 pm    Post subject:
Reply with quote

I don't have requirements to test it by myself but can give you some insight about the vertex shader
gl_ModelViewMatrix in the shader should embed the matrix scale your talking about (try to remove it from the shader if the result is the same-which i doubt- then your scaling transform is not correctly applied)
matrixPalette contains cinematic transforms managed via osgAnimation::StackedTransformElements (stored in Channels of Animation)

my guess is your transform problem comes not from a osg::Transform but from
a osgAnimation::StackedScaleTransform on your Rig

DrPowers wrote:
Thanks for the attention Julien.

I'm setting my initial bound for the drawable equal to the computeBound() returned by the initial geometry, which gives me radius = 20. This calculation does not have the scale applied to it.

The character (a whale in this example) renders with dimensions around 20m which should be wrong since there is a scale value of 0.1 applied within it's node path. I would expect to see the whale render with dimensions around 2m

Something somewhere is not getting scaled properly. It's either the hardware skinning (my guess) or something else. Let me try some things and get back with further information.
Back to top
View user's profile Send private message Visit poster's website
DrPowers
User


Joined: 10 Mar 2009
Posts: 58

PostPosted: Tue Jan 30, 2018 9:46 pm    Post subject:
Reply with quote

So I've concluded that there is extra scaling occurring via the skeleton that we have within our model.

It seems that our skeleton and our geometry are on two different scales and the geometry is getting scaled up on the shader to match the skeleton's dimensions.

I think the fix is to match this geometry with a different skeleton that is of appropriate scale. In the meantime I will set the initial bound to take this extra scaling into account.

In previous instances a skeleton that is too small/large usually would be obvious when an animation started but in this case the vertex/bone weights must have been scaled alongside and it was not an obvious error.

Thank you Julien.
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 [OSG Exporter problem] Export skinnin... tungwert Plugins [osgPlugins] 6 Fri Jun 24, 2016 10:43 am View latest post
No new posts Verify hardware instancing capabilities mateas General 1 Fri Sep 04, 2015 3:09 pm View latest post
No new posts force vsync to false (sofware not har... Christian Schulte General 7 Mon Jul 06, 2015 8:06 am View latest post
No new posts OS X (10.9) Texture2D with hardware c... LEgregius General 8 Thu May 28, 2015 1:52 pm View latest post
No new posts Transform::computeBound optimization scrawl Submission 4 Thu Apr 30, 2015 2:54 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