Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texture animation with rotation no is good #10

Open
CurlyWave opened this issue Jan 18, 2021 · 5 comments
Open

Texture animation with rotation no is good #10

CurlyWave opened this issue Jan 18, 2021 · 5 comments

Comments

@CurlyWave
Copy link

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?

@Ph0t0nX
Copy link
Contributor

Ph0t0nX commented Jan 18, 2021

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.

@CurlyWave
Copy link
Author

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.

@Ph0t0nX
Copy link
Contributor

Ph0t0nX commented Jan 19, 2021

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?

@CurlyWave
Copy link
Author

CurlyWave commented Jan 19, 2021

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

@Ph0t0nX
Copy link
Contributor

Ph0t0nX commented Jan 21, 2021

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants