Page 1 of 1

Vertex Color Morphing

Posted: Wed Sep 16, 2009 7:05 am
by ekt
While a mesh is animating with morphing, it would be useful to be able to morph also color/alpha.
Today ogre manages only positional vertex buffer.
This would allow neat tricks like changing some mesh parts color or fading them during the animation. Artists could control this from their 3d app while designing the animation.

What do you think of it?

Re: Vertex Color Morphing

Posted: Thu Sep 17, 2009 8:37 pm
by madmarx
Maybe I am wrong but I thought this was already available through the Ogre::AnimableValue (OgreAnimable.h) + KeyFrame ?

Edit : well, I am wrong. Doing 1 animable for each vertex would be overkill !

Re: Vertex Color Morphing

Posted: Thu Sep 24, 2009 10:43 pm
by nedelman
I'd like to see normal morphing as well. As it is, the same normals are always used which results in incorrect lighting.

Re: Vertex Color Morphing

Posted: Tue Sep 29, 2009 4:49 pm
by sinbad
The reason is that the overhead for storing snapshots of all vertex properties is quite large, so we limited it to the position buffer - you should use skeletal animation for efficient animation of normals. You can't even interpolate normals 'properly' with morphing anyway, although you may be able to get away with a linear interpolate and renormalise in some limited cases. It may be something we can add as an option, but it comes up as a request extremely rarely.

Regarding vertex colours, a far more efficient way of doing this is to use a shader, or even simply a set scrolling texture coords referencing a texture which describes the colour animation. This is orders of magnitude faster than actually physically animating the vertex colours.

Re: Vertex Color Morphing

Posted: Wed Apr 21, 2010 4:20 pm
by berger
Hello,
I have a question that relates to this thread. I am developing a facial animation program using blend shapes. The blend shapes are derived from high-resolution shape capture and CANNOT be approximated by bones. I want to use Ogre pose animation for this, but the gist I'm getting from the forums is that Ogre modifies only the vertex positions and does not update the vertex normals as the mesh deforms. If that is the case, I would like to try to manually update the normals, I suppose by computing triangle normals, adding those to the incident vertices and renormalizing. I realize this is computationally expensive but accurate normals are essential for rendering these meshes.

So two questions:

1) Is there is a way for Ogre to update the normals automatically?
2) If there is no way for Ogre to do it automatically, can you recommend an optimal strategy for doing it manually? Should this be done as a shading program?

Many thanks,
Michael

Re: Vertex Color Morphing

Posted: Thu Apr 22, 2010 1:32 pm
by lordsme
1) Is there is a way for Ogre to update the normals automatically?
2) If there is no way for Ogre to do it automatically, can you recommend an optimal strategy for doing it manually? Should this be done as a shading program?
I have the same problem as Berger and the same questions... no idea?

Re: Vertex Color Morphing

Posted: Sat Apr 24, 2010 7:35 am
by xavier
The answer is #2. Sinbad already explained this all above.

How you deal with your normals is entirely up to you; regardless of the algorithm, doing this on the GPU is strongly recommended.

Re: Vertex Color Morphing

Posted: Sat Apr 24, 2010 1:34 pm
by berger
Then I guess I am looking for a way to update vertex normals using a shader. I'm not very experienced in shaders, so before I get into this I wanted to ask if what I want to do is feasible. My vertex shader would need access to the triangle list of the mesh, and refresh the triangle normals prior to updating the vertex normals. Is this possible or would I be wasting my time trying to figure out how to access triangles from a vertex program? Any suggestions or examples would be much appreciated.

If it is not feasible, I will have to recompute the normals in software and write the values to the hardware buffer.

On a further note, though I'm new to this forum, from what I've read I believe there *is* interest in having an option in Ogre to update vertex normals automatically during pose animation. I realize that blend shapes are not favored in games for performance reasons, but their use is on the rise (e.g. PS3's Heavenly Sword). And there are applications for Ogre other than games... such as the field of visual speech synthesis in which I work.

Thanks

Re: Vertex Color Morphing

Posted: Sat Apr 24, 2010 5:18 pm
by xavier
berger wrote: Is this possible or would I be wasting my time trying to figure out how to access triangles from a vertex program?
It depends on the shader model you are expecting to use. With SM3.0 you can access texture samplers in the vertex shader, and with SM4 and above you have more features available as well.
If it is not feasible, I will have to recompute the normals in software and write the values to the hardware buffer.
This certainly will have the broadest compatibility. You can easily multithread this task (TBB or OpenMP parallel-for is probably easiest) to take advantage of multicore hardware to help with this.

Re: Vertex Color Morphing

Posted: Sun Apr 25, 2010 3:08 pm
by berger
Thanks for that. I will try a software solution for now, and later try to do it faster on the GPU.

I am trying to do this using optimized Ogre methods such as EdgeData::updateFaceNormals(), which relies on OptimisedUtil::calculateFaceNormals(). Unfortunately this produces homogeneous Vector4 normals which are not normalized to unit length. I must then convert these to 3D vectors and normalize them before building the vertex normals out of them. Wish there was an easier (and faster) way to do this...

Re: Vertex Color Morphing

Posted: Mon Apr 26, 2010 7:10 pm
by berger
I am now finding that during vertex animation it is impossible to obtain current vertex positions from the hardware buffer. So in order to calculate vertex normals, I have to replicate the process of calculating vertex positions in software. This is totally redundant. Is there no other way??? I had no idea this would be such a problem.

What about VertexAnimationTrack::setAssociatedVertexData(). The documentation says this allows me to set the "target" of the vertex animation. I'm not sure what that means but could it be of use?

Thanks for your help.

Re: Vertex Color Morphing

Posted: Tue Apr 27, 2010 6:00 pm
by Praetor
The vertex animation itself stores its own separate buffers. The new vertex positions are not copied into the original buffer, which is why you don't see it changing. You need to grab the vertex buffer stored in the animation track.

Re: Vertex Color Morphing

Posted: Tue Apr 27, 2010 8:29 pm
by berger
Hmm, but how do I access that? When I call track->getAssociatedVertexData(), I get null.

Re: Vertex NORMAL Morphing

Posted: Sun Jun 27, 2010 9:00 am
by cin
Vertex normal Morphing.
Low resolution object space normal maps. Interpolate in shader. This can be realized anyone? :?:

Re: Vertex Color Morphing

Posted: Sat Jul 17, 2010 4:31 pm
by truckleasing
I'm attempting to do this using optimized Ogre methods like EdgeData::updateFaceNormals() which relies on OptimisedUtil::calculateFaceNormals(). The result is a homogeneous Vector4 normals which are not normalized to unit length. To fix it I have to convert these to 3D vectors and normalize them before building the vertex normals out of them. Can anyone tell me if there's an easier or faster way to do this? Thanks.