I am loading some models asynchronously and it works splendidly. I need to have shadows in my scene and so I’m using Panda3d’s shadowCaster system. This means that I have to use the auto shader: render.setShaderAuto, which also means that even though the model is loaded asynchronously, there will be a noticeable chug when a model is first added into the scene as explained by David:
My question is, is there any way to circumvent this, while still using the auto-shader, since the time David said this? Or is it for the time being something unavoidable?
@Thaumaturge specifically the first encounter with a Mechanoid rocketship, just before the shields come up for the first time on that level. I added these lines (with “common.base.render” not just base.render) to Section2.py . I could be fooling myself, but I do believe it worked.
I believe that I know the chug that you mean–it was a bit of a burr in the experience, I fear!
Well, I’m glad that this solution has been found and works, then!
Remind me, please: are you in a position to make a new build? If so, by all means feel free to make such a build and update the project-page on Itch and the thread here! If not, let me know and I can likely incorporate these lines and produce a build myself.
Ah, I believe I discovered how I was fooling myself.
If the enemy fighter causes the player’s shields to come up first, as in the Mechanoid hits the player’s shields first, the subsequent Mechanoid shields coming up is already in cache so has no visible chug due to, I imagine, them sharing the same effect.
I apologize for getting ahead of myself there, I should have done more thorough testing before claiming victory. I do tend to get overexcited about this kind of thing. I would very much like a way to eliminate these chugs / hitches / delays for a variety of games.
Ok, just to be clear, the models in question are loaded in as the player is already walking around in the world. The idea is to have them loaded in seamlessly. If I don’t add render.setShaderAuto(), these models are loaded in with zero chugs. However, if I add it, there is a noticeable, brief chug. Adding these 2 commands in the loading screen doesn’t seem to solve this:
There’s still a chug. I used PSTATS and indeed, the culprit is the shader being created at run time for the newly added model:
Spike in draw
Caused by spike in prepare
Caused by spike in making a new shader
So is this because a new shader has to be made each time a new model is loaded into the scene? Is there a way to have this shader made in another thread? It seems that David even admitted this, at the time:
I apologize, upon further investigation, that indeed does work, but with one apparent caveat: if you use the cardmaker class to create something like a health bar and put it atop your model, unless you explicitly set off the shaders for it like this:
it will still cause the chug even with those 2 commands you mentioned. Other than that, it works well, thank you.
However, when dynamically adding light sources, the shader must be supplemented by repeating the cycle over them. At the moment, this is rigidly performed by indexes, which, I think, will not be updated in this case. But this is just a theory.