Sign in to follow this  
gotov

Hardware Morphing

Recommended Posts

Hello, I'm trying to animate a face using hardware morphing technique(HLSL),and I'm programming in C++. My problem is that I have a variable numbers of morph targets for the same mesh, and because of that my declarations of positions are variable too. ex. In one pass there are 5 morph targets,second time 2 morph targets and so on... Is there same method which I could use for declarations of positions depending on the number of morph targets using in that pass.

Share this post


Link to post
Share on other sites
Well, assuming DX9, you could have different vertex declarations, one for each count of morph targets that are active. You could specify a base vertex format that lives on stream 0, then your first active morph target position value could be added on stream 1, etc.

That way, when you determine your active morph targets for given render, you select and bind the appropriate vertex declaration, bind the vertex offset streams, and map the morph blend percentages into (presumably) your vertex shader constant.

Or, if you wanted to be lazy, you could have, say, 4 morph targets active all the time, and keep one vertex format bound, but bind buffers with all zeroes into the morph streams for the morph targets that aren't active.

Share this post


Link to post
Share on other sites
Thx,
but that doesn't solve my problem because in one mesh I have 16 morph targets, and the caps.MaxStreams is 16, so my graphics card can't handle the number of input streams.
Is there any other way? Maybe something similar to skinning way?

Share this post


Link to post
Share on other sites
Do you want to be able to enable an arbitrary number of morphs at once, or just a few?

For most applications limiting yourself to 1 or 2 morphs is fine. In such a case, create three techniques for rendering: BaseMesh, OneMorph, and TwoMorphs. Bind morph buffers to Stream1 (and 2) whenever a morph is active. You can have 100 morph targets if you want, just so long as only 0, 1, or 2 are active at once.

Share this post


Link to post
Share on other sites
I want enable an arbitrary number of morphs at once. I know that limiting to one or two morphs is fine, but I'm remodeling one students program for 3D rendering so it will be able to use hardware morphing, and in one case, while speaking Japanese use 16 morphs at once.

Share this post


Link to post
Share on other sites
Theoretically, you could write your morph data into one or several textures and using a texturelookup in the vertexshader, but that requires either R2VB or VS30 capable hardware.

Share this post


Link to post
Share on other sites
Quote:
Original post by gotov
Thx,
but that doesn't solve my problem because in one mesh I have 16 morph targets, and the caps.MaxStreams is 16, so my graphics card can't handle the number of input streams.
Is there any other way? Maybe something similar to skinning way?


I'd say do it on the CPU, then.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this