sugi-cho/Animation-Texture-Baker

Texture animation with rotation no is good

CurlyWave opened this issue · 5 comments

Hi all, when I have a mesh with an animation that has displacements and rotations, it doesn't bake the texture well and sometimes you see a plane.
My example is a bird turning 360 degrees in animation.
Am I doing something wrong or does not support rotations for this?

It's difficult to determine where the issue lies from your brief description. The core of the baking boils down to "SampleAnimation()" and "BakeMesh()", which are UnityEngine functions that take the vertex positions at a specified time and bake them into a new mesh. I don't see any reason why it wouldn't work.

Maybe your mesh has offsets or rotations on the root bone? If that's the case, you can remove those offsets/rotations manually. Also there are other repos that are derived from this one (sugi-cho) that do that transform during the bake process. sugi-cho was one of the pioneers of this technique, so a lot of repos are derivatives of his work.

Another possibility - does your animation have bone meshes (as in child objects that have meshes)? Those are not supported in this repo.

hello again, thank you so much for taking the time to reply to me.
I have attached a video so you can visualize my problem.
https://vimeo.com/502107510
I'm trying to create a particle from a mesh with animation, this animation has bone rotations and displacements.
I have based on this post:
https://forum.unity.com/threads/share-knowledge-how-to-make-3d-animate-particle-effect.564994/
I do not know if my problem is with the shader or the bake with animations that have rotations in the bones.

It looks to me like the problem is in the GTA/SimplePfx shader, not the TextureAnimPlayer.shader. I'm not really familiar with that GTA shader, but it appears to be reading the texture and playing back the animation while throwing in some rotations during the process. If sugi-cho made even a tiny change to the texture's format it could easily break NathanJSmith's shader and it looks like NathanJSmith wrote that tutorial on March 23 2020. The last change to the baking code that sugo-cho's made was about 5 months later. In that commit he added support for a tangent texture.... I don't think would affect things - you can just ignore the tangent texture. I'm not exactly sure what tangents are used for.

Unfortunately, I think the only way to figure out what's going on would require debugging the GTA/SimplePfx shader with RenderDoc or something and trying to follow the math. Maybe you could show that video to NathanJSmith and he might have some ideas?

Hello, I appreciate your answer once again.
Could you leave me a link who should I contact? I sent a private message to NathanJSmith's from the unit's forum but I don't get a reply
Or where can I turn to this problem? I'm honestly not very familiar with shaders and as you say the problem is probably the SimplePfx shader.
I've been searching the internet for several days for a solution I can find but so far I haven't found anything, thanks for everything

Have you tried it with different animated models to see if the issue is specific to your flying bat model or maybe it happens with all models? If it doesn't happen with all models+animations, perhaps you could compare yours with a working one - the differences would tell you a lot about where to look.

Maybe you could post a reply in NathanJSmith's thread ( https://forum.unity.com/threads/share-knowledge-how-to-make-3d-animate-particle-effect.564994/ ) and see if someone else there who's used his shader knows.

I would try to fix it, but I'm really busy right now. If you have the time, you could try to learn enough about shaders to fix it yourself. For debugging shaders I use RenderDoc. It would probably take you a couple of weeks though. I was in a similar situation myself about a month ago. I wanted to modify sugi-cho's shader so I ended up spending two weeks learning HLSL and by the end I had pretty much written a whole new shader. I'm still far from an expert, but at least now when I look at HLSL I have a general idea of what's going on.

Ideally someone else online has either taken that SimplePfx shader and worked with it enough to understand the issue. That would be the shortest fix. Another approach would be to ditch the idea of using a baked texture for particle effects... maybe there are other methods that would work just as well (like a compute shader or something)?