zhangjt93 / godot-imposter

imposter plugin for godot 4.x
MIT License
56 stars 6 forks source link

animation + emission baking #5

Open iojnekns opened 5 months ago

iojnekns commented 5 months ago

First, let me share heartfelt thanks for your efforts here. This is fantastic. The original plugin from wojtekpil got the job done and for that I'm deeply grateful but it certainly had some difficulties.

I've been using this for 4-5 days and it's a much smoother experience. Finding it was like Christmas came early.

A minor issue: I notice that the baking process can sometimes 'stick'. This can be mitigated by switching focus in and out of Godot (I think this causes the editor to check the file system for changes). Doing this while baking causes it to go much quicker than if left to its own devices (in my experience).

Since you specifically solicited suggestions in your description, I have a few that you might be willing to consider. These would really help me out:

  1. Support for animation baking: I use animated imposters. Doing this at the moment is a rather tedious process - one has to set the snap rate in the animation player for the target mesh (for example 15FPS) then manually bake each frame (processing the node, resetting the name each time), then pack the results into an array texture for use with a slightly modified version of the imposter shader. Adding support for this process would be a huge help to me. It would be ideal to select the AnimationPlayer node, determine a frame rate, tick which animations to bake, and have the addon batch process baking the frames. It is probably not a common use case, but I have come across at least one other developer using imposters in a similar way and the results are fantastic.

  2. Support for emission: I use imposters with emissive surfaces. Very attractive for things like distant headlights for cars. Producing this at the moment is tedious and manual - the only way I have been able to achieve it is to black out all surfaces that are not emissive, bake, then manually adjust the resulting albedo texture in an image editor in order to produce an emission texture for use with a slightly modified version of the imposter shader. The result is, for some reason, not 1:1 overlaid with the source albedo, but its convincing enough at a distance. I don't know if it's even possible to sample the emission property of a given pixel during the baking process. However, if it is possible, adding support for this process would be a huge help to me.

Thanks again.

zhangjt93 commented 5 months ago

Sorry for the delay in getting back to you, I've been busy with the move and couldn't respond in a timely manner.I really appreciate your suggestions.

If you're experiencing a "stick" feeling, is it because the Godot editor is lagging during the baking process? If your baking options require large frames, you currently need to choose a higher resolution to preserve as much detail as possible. However, as you may have noticed, this results in very large texture files, which can be taxing for the Godot editor to handle.

Based on the issue above, I'd like to respond to your suggestions:

Since imposters are primarily used for rendering distant objects, it's acceptable to sacrifice some details to improve performance. If an object is far away, do you really need animated rendering for it? If you need to render objects at closer distances (medium range), using imposters would require larger frames and larger resolutions. However, the larger the baked texture files, the more memory and processing power is needed to load and render them, which can increase performance overhead. In this case, I think using low-poly models might be more efficient for your program.

I'm also very interested in exploring this direction. I'm currently considering how to address the performance overhead of large texture files. If I can find a solution to speed up the processing of large baked files, I would definitely consider supporting animation as well.

Regarding the issue with light sources, I believe it depends on the usage scenario for imposters. For objects in the distance, do you really need to see the light sources? Or do you only need to see the light sources and ignore the models themselves (like car headlights at night, where you often only see two light spots in the distance)?

Based on the above, although I haven't conducted detailed tests yet, I believe that when rendering objects at medium distances and if you need to preserve more details, using low-poly models might result in lower performance overhead.

When using imposter techniques, you need to consider the trade-off between the size of the texture files and performance overhead.

iojnekns commented 5 months ago

Thanks for the reply - really appreciate it.

In reference to the 'sticking' during the baking process - it's not a huge problem, just one I felt worth mentioning. It's not simply that the editor is lagging, it is that, at least on my machine, I can significantly speed up the baking process by focus switching during the bake.

To your other points - "do you need it?" Understandable and I'd make the same point myself. I can speak only for the use case of my current project - imposters have allowed me to maintain good performance with high instance counts, in particular, for objects that might remain in view from the horizon to the camera

A video might help to illustrate better than words. In this scene, both vehicles and pedestrians are using imposters. Until around 00:30 the pedestrian LOD range is at 0 so that only the imposters show.

I believe the imposter animation is more than good enough at even at fairly short distances. I'm using the default texture size and see no particular need to increase it.

Imposter emission was not the subject of the recording, but you may see that although the effect is more subtle at a distance, without emissive imposters there is a conspicuous transition where the vehicle lights are no longer luminous which is jarring no matter the range.

At greater distances, you are correct, only the lights will be needed.