Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / jGpuSkin - Skeletal animation plugin for DBPro

Author
Message
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 28th Mar 2017 10:54 Edited at: 19th Dec 2017 08:50
Hello everyone, I proudly present jGpuSkin: a skeletal animation plugin for DBPro. Rather than augmenting DBPro's built-in functionality, this plugin is a replacement animation system which was written with the intention of reducing cpu load when using multi-camera renderers. Skeleton data is not represented using DBPro's limb system which helps to avoid overhead within the sync command, and also allows accurate bone transforms to be retrieved pre-sync.

The library makes no attempt to perform mesh deformation on the cpu; All objects handled by this plugin require an appropriate shader, and shaders cannot be shared across multiple objects. Shader bone matrix palettes are represented using float4 arrays, allowing a maximum of 80 weighted bones per object with up to 4 weights per vertex. The matrix palettes only contain bones which directly contribute to mesh deformation, meaning there is no limit to the number of non-weighted bones which can exist within a skeleton. These two features allow the plugin to work with many objects that are normally incompatible with standard fastbone shaders.

Before objects can be used with this plugin, they must be converted into the appropriate format using the provided Import Tool.



[Update 12/19/2017]

Import Tool Updates:
------------------------------------
- Updated the import code to calculate permutation matrices; Enable them by checking "Skeleton->Use Permutation Matrix" within the Tools menu after initial import (loading files which were produced by previous versions will not work).
- Updated the skeleton file format to store permutation matrices for objects which are saved with the "Use Permutation Matrix" option checked. Note: Permutation matrix data will be lost if "Use Permutation Matrix" is not checked while saving.
- Added Mesh tools for flipping vertex normals along each axis.
- Added a wireframe mode, and added backlighting to the default diffuse technique.
- Removed texture handling for the time being.
- Compiled using DBPro9Ex from this version on. If anyone here still uses XP just let me know and I will upload a version compiled with u7_7.
- Removed MSAA option which was added in the last beta, It didn't work well with the skeleton visualization and causes a strange issue with 9Ex

Bug Fixes:
------------------------------------
- Fixed a bug where freshly-imported objects would sometimes not assume their proper bind pose.
- Fixed a critical problem with the import tool's weld object function which was crashing the application (actually works this time...)
- Fixed some bugs with the keyframe reduction tool which were causing the animobject to display the improper animation frame


Plugin Updates:
------------------------------------
- Added better control over when/how AnimObject updates are performed to better suit various usage strategies.
- Implemented a mesh (limb) based LOD system; Uses the animobject's distance from the near plane (re-used culling data) for fast LOD calculation.
- Added the abillity to force a specific mesh LOD when rendering each camera.
- Permutation matrices are now loaded from skeleton data; Requires objects to have been exported using the latest import tool.
- Added SkeletonLOD system which is used to skip recalculating local transforms for certain bones when viewing the animobject at great distances.
- Updated the plugin to collect object data as soon as AnimObject_SetObject is called, rather than waiting for the shader. This removes the need to apply an object and shader before calling certain commands, as well as allowing more settings to be duplicated while cloning.
- Removed default camera mask, AnimObjects now require setting a camera mask before they will render to any cameras.
- Added an example showing how to use the LOD systems; Uses example media which was created and kindly donated by Chris Tate.
- Added an example showing how to render AnimObjects using DBPro's native renderer.

Bug Fixes:
------------------------------------
- Fixed a bug where the permutation matrix wasn't being applied when using object-space bone palettes.


Updated Commands (1):
------------------------------------
AnimObject_Update pAnimObj [, bUpdatePalette ] //New overload, allows for updating the bone palette in addition to the skeleton

New Commands (10):
------------------------------------
AnimObject_SetUpdateMode pAnimObj, Mode //0=Optimal update during sync (based on culling), 1=Always Update Skeleton (ignores culling), 2=Full Skeleton Update JGS_Update, 3=Skeleton And Palette Update within JGS_Update
AnimObject_SetLODLevels pAnimObj, LevelCount //defines the number of LOD levels the AnimObject's dbpro object is equipped to display. LevelCount begins at 0 (default)
AnimObject_SetLODDistance pAnimObj, Level, MinRange //defines the minimum distance at which the specified LOD should begin rendering. Level 0 is always assumed to have a MinRange of 0.
AnimObject_SetMeshLOD pAnimObj, Index, Level //defines which LOD level the specified mesh represents
JGS_SetCameraLOD CamID, Level //forces a specific animobject mesh LOD to be used when rendering the specified camera.
AnimObject_SetSkeletonLOD pAnimObj, bEnabled [, Dist#] //Specifies if an animobject should use SkeletonLOD, as well as what distance it should take effect
AnimBone_SetLOD pAnimBone, bUseLOD, bExcludeChildren //specify if a particular bone should participate in the SkeletonLOD system; True means this bone's local transforms will not be updated at great distances.
AnimObject_SetHidden pAnimObj, bHidden //Hide/Show an AnimObject; hidden animobjects are still updated but not rendered
bool = AnimObject_GetHidden(pAnimObj) //Returns an AnimObject's hidden status
AnimObject_UpdatePalette pAnimObj //Updates an AnimObject's bone palette (shader array)



Command List (132 total):


This plugin is still very much a work in progress; all comments, questions, suggestions and bug reports are welcome.

Attachments

Login to view attachments
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Mar 2017 13:38
That's a lovely looking set of commands.

I will definitely download and try out your plugin. I know this is a WIP but please do indicate the intended licence and terms of use whenever you get a chance to do so.

I am writing a very simple matrix transform animation system for my game because of DBPs poor bone optimization and synchronization tweaking functions; but your solution looks way more comprehensive and seems worth investing in. Hopefully I will find no severe complications or conflicts in its implementation; the Enhanced Animation plugin did improve the performance, but it caused too many runtime crashes. After removing that plugin, the game has not experienced any strange crashing all year.

I really want to be able to host larger game maps and gaming events, but without better bone optimization, it would mean a laggy experience for the players no matter the strength of the GPU.

Some kind of CPU collision alignment with what is taking place in the vertex shader will require coding on my part, and I would need to merge your shader with my character's pixel shader; other than that hopefully I should be able to make it work in my game.

I will keep you posted on how my tests turn out in the next few weeks after completing some work I have to do on AI and vehicle physics.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 28th Mar 2017 14:09
Thanks Chris! This plugin is completely free for any purpose including commercial work; It would be nice to include me in a credits screen or whatever but that is not a requirement. As with most free software the plugin/import tool are provided without warranty, but being as this is a wrapper for my personal engine's library you can count on me fixing any issues should they arise. I eagerly await your feedback.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 29th Mar 2017 10:10
Uploaded new version; Fixed a bug with the Import Tool's save option.
Dimis
13
Years of Service
User Offline
Joined: 12th Jun 2011
Location: Athens, Hellas
Posted: 29th Mar 2017 20:08
Good Job revenant chaos, seems quite useful. Besides all the other features, increasing then weighted bone count to 80 is pretty cool. I will give it a try.
But it only works with the animations that are loaded with the object, right? Would you consider adding the option to somehow extract and save the animations as separate files, so they can be used from other objects too? This would make this the absolute animation tool for dbpro.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 30th Mar 2017 00:41
Thanks Dimis! I'm happy to report that the plugin already decouples animation data from the mesh and skeleton. The import tool also allows for extracting/saving keyframe sequences by using File->Save->Animation; picking the "Selection Only" option will export the range of animation frames which are specified by the "frame range" editboxes (application window's lower-right corner).
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 1st Apr 2017 23:58 Edited at: 2nd Apr 2017 00:22
Updated first post with a new version. Now includes Help files, updated plugin and keywords file.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Apr 2017 14:17
Downloading
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 2nd Apr 2017 14:31 Edited at: 2nd Apr 2017 14:31
Great work revenant chaos
I ve get about 45% fps boost with plugin
Bone animations was not DBPro's strong side, so your plugin is very useful I think
Still get a glitch when using loop animation
Source attached

Attachments

Login to view attachments
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 2nd Apr 2017 15:01
Hi Kuper, thanks for testing. Try adding 1 to your firstframe/lastframe IDs.

Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 2nd Apr 2017 15:21
yep, it works
Also check speed vs Enchancement Animations plugin ( which I use for all bone animations )
I get even lower fps then with standart DBPro animations
Bu I get that with your plugin it also possile to blend animations ( character walk and reload and same time , for example ) ?
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 2nd Apr 2017 15:36
Quote: "Bu I get that with your plugin it also possile to blend animations ( character walk and reload and same time , for example ) ?"
Yep, use AnimObject_GetBone() or AnimObject_GetBoneByName() to obtain a pointer to the bone where wish to play the second animation, then use one of the the AnimBone commands (Play/Loop/TransitionTo/TransitionToLoop/BlendTo/BlendToLoop) to control that bone's animation.
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 7th Apr 2017 12:10 Edited at: 7th Apr 2017 12:25
Kuper:
How to use "AnimBone_SetPosition" command"?

revenant chaos:
The AnimBone_SetPosition command is used to define a bone's position (or position offset) within it's parent's local coordinate space. If any animations are being played onto the bone, manually defined rotation/position/scale will be overwritten when AnimObject_Update is called. This is not true for bone rotation/position/scale offsets. Much like DBPro's offset limb, the effects of this command are typically not desirable when used in conjunction with multi-weighted geometry.

To achieve inverse kinematics like you show in the picture, you would need to apply rotation offsets to the bones which lead from the pelvis down to each foot.

It should be noted that jGpuSkin was written with forward kinematics in mind, with speed being it's main concern. I do not have any plans to implement IK in the future.

So I get that impossible to offset/rotate bone manually while playin animation? Or it is possible after Update function?
I hope also it is possible to move bones manually to achieve ragdoll effect like this:
https://forum.thegamecreators.com/thread/197129
I also upload source of this example here

Attachments

Login to view attachments
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 7th Apr 2017 23:34 Edited at: 7th Apr 2017 23:35
Hi Kuper, Animations which are playing onto a bone will overwrite the bone's local position, rotation and scale values. This is not true for position, rotation and scale offsets. Offsets are combined with the bone's local transform to calculate it's "final local transform" (which is then concatenated with the parent's final local transform).
If you want complete control over an animobject's skeleton you would not want animations playing onto the bones you wish to control, and those bones should not have any offsets applied. The same holds true for a ragdoll, you would not want the character to continue playing an animation as he flops to the floor. The solution would be to stop any animations before beginning manual control.
I have not yet considered performing ragdolls with the plugin, and as such am not sure what complications might arise. I intend to look into possibilities in the future, but have no current road map for doing so.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 8th Apr 2017 03:50
Just found a bug where setting a bone's local rotation would halt any animations which were playing onto the bone (debug code i forgot to remove). Will be uploading an new version sometime within the next day or so to address the issue and add a few new commands.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 8th Apr 2017 10:15
Uploaded a new version, see first post for details.
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 8th Apr 2017 15:53
Thanks for answers/updates !
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Apr 2017 06:41
Did someone say IK?

You may be interested in https://github.com/TheComet93/ik

It's an extremely fast and leightweight library written in C for solving the inverse kinematics problem. The README is a little bit out of date, but the library is definitely usable at this point.
"Jeb Bush is a big fat mistake" -- Donald Trump
https://vt.tumblr.com/tumblr_o2rvwdLLSF1rmjly4.mp4
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 13th Apr 2017 10:51
Nice work TheComet, thanks for sharing
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 15th Jun 2017 09:59
Just bumping this thread, I do not want it to get locked and will be attempting to use this tool sometime this month.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 20th Aug 2017 02:24 Edited at: 20th Aug 2017 02:25
Updated first post with a new version. Sorry for the lack of updates lately, most of my recent coding time has been devoted to other projects (such as jGfx) but I'm still thinking about this plugin and have some ideas for future updates.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 22nd Aug 2017 12:38
Glad to hear. I promise as soon as I get some financial support for my game I will definately donate towards your work and utilize it.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 28th Aug 2017 10:11
Uploaded a new version, see first post for details.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 6th Sep 2017 16:49
Uploaded a new version, see first post for details.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 24th Sep 2017 16:22
Thanks
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 25th Sep 2017 15:09
You're welcome Chris. I recall reading that you plan to utilize procedural animation, so I was wondering if euler rotations will be enough for your implementation? Would you benefit from bone rotation commands which accept quaternions/matrices?
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Sep 2017 22:47 Edited at: 26th Sep 2017 22:49
I am not sure yet.

From tonight I will be learning how to use your splendid plugin. I think it would be reasonable for me to simply see how far I can get with the work you have performed; if any serious concern needs to be raised, then we can discuss it.

The first thing I am going to do is try out some primitive animation tests. I will create a simple animation with a few shapes in Blender, run through the conversion process and get used to the workflow.

Then I will start using real-time eular rotations to see how far I can get. I am hoping for this to be enough for my demo at the very least.

Kind Regards
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Oct 2017 20:44
Hi Revenant Chaos

I was wondering what you think is causing the following problem.

When I export my animated meshes from Blender, and import them into the jGpuSkin Import Tool, the display order of the vertices of my meshes are invalid. This is also the case when loading the converted jGpuSkin objects into DarkBASIC when sourced from Blender.

Blender has a python script for its Direct X mesh exports which produces the meshes I am importing.

The attachment to this post contains an example of what a primitive wrecking ball looked like in Blender, compared to the one loaded into your software. At first it looked like the normals were back to front, but the verts are drawing in the wrong order; or perhaps I am mistaken.

If you get a spare moment, I'd very much appreciate your input.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 27th Oct 2017 06:30 Edited at: 27th Oct 2017 06:33
Hi Chris,
It doesn't look like the attachment worked, but a google search suggests blender's exporter may have issues with vertex winding order in some cases. The import tool uses DBP's save object command to convert .X objects to .DBO before parsing. It then constructs vertex/index buffers using memory read directly from the .DBO file, so there shouldn't be any vertex re-ordering going on. Do the .X objects render properly when loaded by DBP? If yes, do they still work after using DBPro to convert them to .DBO? Could you test forcing clockwise backface culling within the shader? That can be done by adding CullMode = CW; to each technique pass.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Oct 2017 20:04 Edited at: 27th Oct 2017 20:06
Your fast response is greatly appreciated.

I will attach via HTTP, here is the link: http://www.binarymodularonline.tk/sf/problems/BlenderExportTests.zip

Quote: "Do the .X objects render properly when loaded by DBP? If yes, do they still work after using DBPro to convert them to .DBO?"

Yes, and yes.I actually use DBO format for most of my models which are successfully converted from the .X files from Blender with no issues. I am using U77.

Quote: "Could you test forcing clockwise backface culling within the shader? That can be done by adding CullMode = CW; to each technique pass."

I can try. Are you referring to the "Diffuse_Skin" shader? or "jGpuSkin_Include" ?
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 27th Oct 2017 21:25 Edited at: 27th Oct 2017 21:26
Hi Chris,
That is a strange one, the screen shot looks like the vertex winding order and normals are both inverted.

Quote: "Are you referring to the "Diffuse_Skin" shader? or "jGpuSkin_Include" ?"

That would be added to the "Diffuse_SkinN" which is loaded for the animobject. "jGpuSkin_Include" is used as common place for defining shader array sizes without needing to modify actual shader files at load time.

I'm not yet sure what is causing the issue, but looks like it could be solved by updating the importer with tools for reversing vertex winding order and normals.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Oct 2017 22:52
Spot on there Revenant Chaos. CullMode = CW produced got rid of the problem. Demonstration image here.

The weird lines and character rotation in the image are not problems.Solution found; unless you suggest otherwise.

There is a reasonable bone limit which prevented me including facial expression bones in my exported mesh. The less bones the better for performance; but facial bones are convenient; would you recommend that I implement vertex shaded facial expressions, or split the head into another object with its own bones?


revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 28th Oct 2017 02:30 Edited at: 28th Oct 2017 02:30
Awesome, it looks like the normals were correct after all. When I get a chance I will update the importer with the aforementioned tools to provide an actual fix, consider that shader modification to be a work-around for the time being.

Quote: "would you recommend that I implement vertex shaded facial expressions, or split the head into another object with its own bones?"

I have never experimented with morph-target style vertex animation and so can't comment on performance, but I can see benefits to separating the head in either case. Some initial thoughts are:
- It might be difficult to implement morph-target animation into jGpu's shaders while staying within VS/PS3.0's limits.
- A non-animated version of the head could still be a part of the animobject, but then scaled to 0 and replaced with an animated version when facial expressions are needed.
- It could be easier to get characters to look at specific points in space if the head is separate.

Vertex animation would provide much greater control over the result, but I think bone animation would be easier to implement.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 28th Oct 2017 09:21
I've been playing around with the model you provided and have found something interesting; re-creating the object from mesh causes the same issues jGpuSkin is having.



It seems like the object has a matrix which is used to apply corrections when loaded by DBPro, but those corrections are lost if the object is re-created from mesh. It appears that either the Y or Z axis is inverted (causing the culling issue), and that the Y and Z axes are swapped (causing the rotation issue). This seems to suggest your models are likely being mirrored front-to-back, and that reversing vertex winding order Isn't really a solution. Although this makes me feel a bit farther away from providing you with a fix, at least now I have some clue where these inconsistencies are coming from.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Oct 2017 22:15
Quote: "When I get a chance I will update the importer with the aforementioned tools to provide an actual fix, consider that shader modification to be a work-around for the time being."


Thank you, that is greatly appreciated and will be very useful. The work-around will suffice until any fix is made available in the tool.

Another requested tool feature will be to have adjustable camera movement speeds for viewing small models.

Quote: "difficult to implement morph-target animation into jGpu's shaders...
A non-animated version of the head could still be a part of the animobject...
It could be easier to get characters to look at specific points in space if the head is separate."


After gaining a better understanding of your system, I'd be more likely to find an adequate solution. I will engineer a way to load all bones for the face, limbs and fingers without exceeding the bone count limit, and will have excluded all unused bones for performance enhancement. This may be impossible with one object, but appears essential for my project.

Quote: " It seems like the object has a matrix which is used to apply corrections when loaded by DBPro, but those corrections are lost if the object is re-created from mesh."


That is very telling. So, this is what happens when you make a mesh from my Blender bone animated model. A contrast to what happens with models with no bones.

The Blender export script has to convert Blender's Z axis to DBPro's Y axis. Perhaps it is within this conversion that the 'correction' is taking place.

After over half a decade using Blender for DBPro; this is not the biggest problem I have had to face, and will not get in the way of any progress whatsoever. But it might be a pain for your other future customers.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 29th Oct 2017 16:06 Edited at: 29th Oct 2017 16:23
Quote: "Another requested tool feature will be to have adjustable camera movement speeds for viewing small models."

Wonderful idea, I will add it to my to-do list.

Quote: "The Blender export script has to convert Blender's Z axis to DBPro's Y axis. Perhaps it is within this conversion that the 'correction' is taking place."

That looks to be the culprit, swapping the Y and Z axes back allows the mesh object to render properly with no scaling or rotation needed.

At this point I feel certain that the object uses a matrix to perform the axis swap at render time, I just need to figure out where that little bugger is hiding. Though I do find it strange that Blender's exporter doesn't apply the conversion directly to the vertex/bone data...

Quote: "After over half a decade using Blender for DBPro; this is not the biggest problem I have had to face, and will not get in the way of any progress whatsoever."

Glad to hear it man.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 29th Oct 2017 21:06
Quote: "That looks to be the culprit, swapping the Y and Z axes back allows the mesh object to render properly with no scaling or rotation needed...
I do find it strange that Blender's exporter doesn't apply the conversion directly to the vertex/bone data..."


Yes, it is rather strange. I will most likely adjust my export parameters to correct the problem.

Hopefully I will be successful in getting procedural limb rotation animations to work so that the posing reflects the running speed, items in hand, physical condition and viewing angle of the characters.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 31st Oct 2017 04:04 Edited at: 1st Nov 2017 20:28
Hi Chris,
I've attached an updated version of the plugin which implements a permutation matrix so you can swap the axes back at runtime. This should allow objects which were exported into any coordinate system to work with my plugin, and if I do eventually locate the mysterious matrix this will pave the way for an update which automatically utilizes it.

This version adds one new command:
AnimObject_SetPermutationMatrix pAnimObj, m11#, m12#, m13#, m21#, m22#, m23#, m31#, m32#, m33#

To correct the issues with your particular objects call: AnimObject_SetPermutationMatrix pAnimObj, 1.0,0.0,0.0, 0.0,0.0,1.0, 0.0,1.0,0.0
From what I can tell everything matches DBPro's behavior after the matrix is applied, but this hasn't been thoroughly tested so let me know if you find any more inconsistencies.

This version also fixes a frustum culling issue which caused the far plane to be ignored. I'm releasing just the dll for this update until more work is completed.

[Edit] Download removed

Attachments

Login to view attachments
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 31st Oct 2017 13:31
I tested it. It's a fantastic solution. Immensely appreciated, and exceedingly reassuring to see this work well thus far. I've never seen more than hi-res 50 exclusive character models animate so smoothly before; quite surpassing in comparison to past solutions. This plugin will essentially make DBP a viable tool for MOBAs and RTS games for people who know what they are doing; and will help open things up for my game.

Can't wait to see the end results, but first I have got lots of animation coding to do.

I also want to tap into your graphics plug-in to start getting things ready for December. This is going to be lots of fun.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 1st Nov 2017 12:34
Awesome, glad to hear things are working out. I am happy to have your feedback and enthusiasm, thanks for testing.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 1st Nov 2017 20:26 Edited at: 6th Nov 2017 17:47
Hi Chris,
Here is another update to the plugin; I've finished implementing the permutation matrix so culling and getting/setting bone transforms should work properly for your objects.

[Edit] Download Removed

Attachments

Login to view attachments
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Nov 2017 20:13 Edited at: 2nd Nov 2017 20:18
Oh really, many thanks for the timely deed; very thoughtful of you to update your plugin in consideration of my intention of writing the procedural animation code.

And congratulations on obtaining your new badges

At this moment I am fixing some dead reckoning problems with my movement code, a few discrepancies in the game item collection functions, and a little bit of particle effect work; I will then be using your system to animate the combat, movement and general posing. which should be fun. I also will play around with scaling so that the mesh changes appearance when the characters put on weight or gain muscle - which is a game mechanic.

Two questions I'd like to ask you for you to kindly consider when you get a spare moment. These questions are really just a request for your general advice, prior to thorough investigation.

1: I have tried a vast number of 3D particle effect techniques and systems within DBPro. From plugins, to billboards and shaders. What I have found is that all solutions share one thing in common. They all are as laggy, as, hell. Even using vertex point sprite shaders; once you load up a couple of particle effects on screen; things slow down like crazy. Moving a particle from point A to point B with the CPU; be it in my code or in plugin code, or the DBPro Sync pipeline is a no no. The GPU is not too happy with painting large point sprites either.

I saw that your other plugin has instancing functions which may be of use for particle effects.

The question is; what do you think is the best way to apply movement animation fitting of particle effects such as fire, smoke and explosions with minimal impact on lag?

I word this question openly because I want to know what you would do.

2: For procedural animations, it might be far more CPU and GPU efficient for me to blend multiple animations together, bound to class variables such as 'HeadAngle' and 'FingerAngle' which could simply blend one animation, such as the 'stand animation', with another, 'turn head left animation'. On a per bone basis.

Is there some way for me to feed your animation shader blend of animations using:
AnimBone_InterpolateFrames pAnimBone, pAnimTrackA, FrameIDA, pAnimTrackB, FrameIDB, Alpha, bExcludeChildren

But in such a way that it loops both animations? Or do I need to use the CPU to blend the animations on a frame by frame basis, using your function above?

It might be that my first intention of setting the bone angles with the CPU will be more efficient; your blending functions brought to my attention that it might be more efficient to blend multiple animations so that the GPU can just play back the combined result without much work on the CPU.

OK this is another question, so that makes 3. The question is, let me know if you prefer these long questions, or if you prefer straight to the point ones. I appreciate that you are likely busy, and a short couple of paragraphs would suffice; but some people prefer to have me give them the big picture.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 3rd Nov 2017 16:11
Quote: "congratulations on obtaining your new badges"

Woah, thanks for the nominations, I will wear them with pride. It could have been weeks before I noticed, not sure how long I had the Tool Maker badge before I realized it lol

Quote: "I also will play around with scaling so that the mesh changes appearance when the characters put on weight or gain muscle"

You will want to limit the amount of scaling which is applied to individual bones. Non-uniform scaling will result in distorted vertex normals and cannot be properly supported without cutting the bone palette size in half to make room for inverse transpose matrices. The existing limit of 80 weighted bones already consumes 240 of the 256 constant registers available in shader model 3. You might find a more favorable solution once additional features have been added, previously I had only considered manually assembling objects from different parts to achieve character customization. DBPro's Change Mesh command can potentially be used to swap different body parts, but I am planning to add exclusion for individual meshes within AnimObjects which may provide a more efficient alternative. Although costly, you could also try using texture look-ups within a vertex shader to apply vertex offsets from texture data.

Quote: "What do you think is the best way to apply movement animation"

I would absolutely stay away from vertex point sprites for anything which requires motion or visual consistency; Updating vertex buffers is a real performance killer, and point sprites are not guaranteed to render consistently across different hardware. jGfx's GeoInst command set isn't recommended for rendering particles, it is far more suitable for rendering static geometry. It stores instance data within vertex buffers and will likely be too slow to update each loop. Additionally, as Kuper recently discovered, the GeoInst command set does not work properly with alpha blending. After looking through DBPro's source I've come to the conclusion that certain render states require objects to participate in DBP's internal object manager, and therefore can't be properly supported by third-party renderers. The first thing I would investigate is using shader arrays to store particle data, and then referencing it within the vertex shader using indices passed through the vertexdata. This does mean that the number of particles per object would be limited, but it should be fast to update and will support all available render states.

Quote: "Is there some way for me to feed your animation shader blend of animations using... ...But in such a way that it loops both animations"
Quote: "...blending functions brought to my attention that it might be more efficient to blend multiple animations so that the GPU can just play back the combined result without much work on the CPU."

Bone transforms are calculated on the cpu no matter which commands are used, the result is then passed to the gpu where the vertex shader uses them to transform vertices. At the moment there isn't a way to play/loop two animations simultaneously; For now that will require manually calculating frame IDs and calling the command you mentioned, but it would make it impossible to transition between different animations while doing so. I will think about the best way to implement this, but I may wind up just adding commands to control a secondary animation which is blended with the existing animation. This way the secondary animations could also blend/transition between different sequences along with the main animation. However I could see this causing issues in certain cases; for example blending different walking animations onto pelvis/leg bones could create alignment issues between the feet and ground. With the current implementation I think the best solution is to use bone rotation offsets to add variation/expression.

I don't have any problems with long messages, write as little or much as you see fit.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Nov 2017 20:12 Edited at: 3rd Nov 2017 20:15
Thanks for the practical advice, it was very helpful.

So...

Quote: "
You will want to limit the amount of scaling which is applied to individual bones. Non-uniform scaling will result in distorted vertex normals and cannot be properly supported without cutting the bone palette size in half to make room for inverse transpose matrices. "


I'll certainly avoid non-uniform scaling. I will need to efficiently implement variable character height and weight visually in some form of a way which does not cause problems. Over the course of the next few weeks I will probably find a solution.

Quote: "DBPro's Change Mesh command can potentially be used to swap different body parts, but I am planning to add exclusion for individual meshes within AnimObjects which may provide a more efficient alternative"


I will be providing mesh modification in the character editor; so I suppose I could perform a runtime bake a couple of meshes with a few weight and height variations.

Quote: "Although costly, you could also try using texture look-ups within a vertex shader to apply vertex offsets from texture data."

Yes, that is true. I was thinking about using vertex shading for changing the appearance of the characters in real time; but I am not going to take the gamble, with this game being online in an open world, there are already enough variables which could end up hindering the performance; Murphy's law and all.

This would have probably looked fantastic without much work; but baking the mesh seems to be the better idea for the much needed engine performance. At some point in this project I am going to have to take on the splendid task of animating crowds .

Quote: "I would absolutely stay away from vertex point sprites"

Quote: "The first thing I would investigate is using shader arrays to store particle data, and then referencing it within the vertex shader using indices passed through the vertexdata. This does mean that the number of particles per object would be limited, but it should be fast to update and will support all available render states."


Understood.

Quote: "jGfx's GeoInst command set isn't recommended for rendering particles, it is far more suitable for rendering static geometry."

I am using a lot of instancing in my level parsing; it will be interesting to see how I can improve things with your plugin.

Quote: "For now that will require manually calculating frame IDs and calling the command you mentioned, but it would make it impossible to transition between different animations while doing so."

Quote: "but I may wind up just adding commands to control a secondary animation which is blended with the existing animation."


The main goal is for me to play back a running animation with the legs, and a holding of a weapon animation with the arms; or rotating the eyes while having the face look around will standing still; stopping all animation and binding the rotations and positions to a physics ragdoll effects, then blending back into standing position as the character gets up from the floor.

I will have to play around with blending, setting frames and setting rotations to find what works for each situation. I am going to strive to use a single mesh for the whole job, for better performance because I have to incorporate additional resources for comic shading, clothing and weapons.

The next 4 weeks will be a good test for your plugins. I might end up finding workarounds and solutions I've not yet thought about.

Kind Regards
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 3rd Nov 2017 22:17
Quote: "The main goal is for me to play back a running animation with the legs, and a holding of a weapon animation with the arms; or rotating the eyes while having the face look around will standing still"

That level of control can be achieved using the AnimBone commands to issue animations on a per-bone basis. In most cases you won't need to call a command for each and every bone, the AnimBone animation commands use an additional flag to specify if animations should propagate to the bone's children as well. For example, in the case of controlling the walking animation; you could loop the animation to the pelvis bone with the bExcludeChildren flag set to 1 (prevent the spine and up from playing the animation), then again for each hip bone with the flag set to 0 (propagate to the knees and feet). Applying the same concept to the rest of the skeleton should be flexible enough for your needs.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Nov 2017 23:14 Edited at: 3rd Nov 2017 23:15
That looks like the perfect solution. Saves me from bone control overkill.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 6th Nov 2017 17:48
Uploaded a new version, see first post for details.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 7th Nov 2017 13:30
Fantastic! I will update my plugin and will be working closely with it later in the week, next week.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 23rd Nov 2017 15:58 Edited at: 23rd Nov 2017 15:59
OK from this moment onward I will be implementing your plugin into my game.

I am going to take a gamble and boldly attempt to approach this implementation in an unorthodox manner for the following reasons:

• My original goal as discussed above was to be able to play more than one animation on a character

• I need to ideally use jGpuSkin without changing all references to limb position queries used by hitboxes, LOD objects, network links etc, etc.

• I need to ideally use the plugin without much rewriting work to be done with the comic book character shaders whenever the plugin gets updated


The method I am going to use to accomplish these requirements is as follows:

• Add a base animation object, and one or two hidden animation objects. When multi-animations are required such as when the player runs while rotating the arms while rotating the head, each of the additional objects will play a different animation to the main one. I can then use manual rotation of limbs on the main object when they are required to play a separate animation using the hidden objects as references. This will run slower than just having one object, but this will reduce programming development time and animation export time which is a bigger issue.

• It would take very a long time to locate and change all references to limb positions and rotations across multiple functions and to keep track of how the changes affect the system. Too much potential for mistakes. I will store a low poly excluded traditional DBP character object and set its limb rotations to the rotations of the jGpuSkin. Now there is no need to change the game code to reference the jGpuSkin limb position queries. These reference objects will not affect the performance.

• I will have to adjust the comic book character shaders incorporating what you have provided in the diffuse shaders with the inclusion of jGpuSkin_Include.fxi. And do the same with anything else which uses bones. I will skip the pixel shader you provided as a starter, and will add the include, structures and vertex shader.


Hopefully, I will get this to work. It should be a good balance between having the features I need and having sufficient performance.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 24th Nov 2017 02:41 Edited at: 24th Nov 2017 02:43
Hi Chris,

Quote: "My original goal as discussed above was to be able to play more than one animation on a character"

Quote: "Add a base animation object, and one or two hidden animation objects. When multi-animations are required such as when the player runs while rotating the arms while rotating the head, each of the additional objects will play a different animation to the main one"

I'm not sure what you mean by "multi-animations". The plugin already allows playing unique animations on a per-bone basis, and rotation offsets can be used to add variation to those animations. Or is this how you plan to implement playing/looping multiple animations per bone?

Quote: "I will store a low poly excluded traditional DBP character object and set its limb rotations to the rotations of the jGpuSkin"

I see some problems with this implementation; DBPro's and jGpuSkin's bone rotation angles are not equivalent; using the same angles on both objects will result in different rotations. DBPro's Rotate Limb command offsets the specified rotation using the bone's local bind pose matrix. However, DBPro does not apply this offset to rotations calculated from keyframe data. jGpuSkin does not use bind pose matrices when getting/setting bone angles, allowing manually defined rotation angles to match rotation angles calculated from keyframe data. Additionally DBPro fails to return the correct limb direction (world-space) angles with your objects. You may have better luck manually assembling your low poly character objects out of cubes to avoid the quirks and overhead of DBPro's animated objects.

Login to post a reply

Server time is: 2024-11-16 22:26:35
Your offset time is: 2024-11-16 22:26:35