jMonkeyEngine / jmonkeyengine

A complete 3-D game development suite written in Java.
http://jmonkeyengine.org
BSD 3-Clause "New" or "Revised" License
3.84k stars 1.13k forks source link

Animation state gets only updated when inside main camera #1875

Open zzuegg opened 1 year ago

zzuegg commented 1 year ago

As the title says the animation state gets only updated when a geometry is inside the main camera. When animation is combined with shadow mapping it should also be updated in case any shadow cam is rendering the object. Here is a gist to test.

https://gist.github.com/zzuegg/a1b10121bb49d983d36beb749e7f1dd0

Ali-RS commented 1 year ago

Not directly related to this, but we had a similar issue reported about shadow disappearing with instancing (https://hub.jmonkeyengine.org/t/shadow-disapeared-on-instanced-objects-away-from-camera/46174) in which I ended up adding InstanceCullingFunction (https://github.com/jMonkeyEngine/jmonkeyengine/pull/1865) but I never provided a proper implementation for shadow because of my knowledge limit.

in case any shadow cam is rendering the object.

I do not know how shadow works but still I am interested to know how this can be done in code so I can possibly implement an InstanceCullingFunction that supports shadow.

zzuegg commented 1 year ago

I dont think it is culling related but that the control does not get updated. but i habe to investigate. that part of the engine is new to me

Ali-RS commented 1 year ago

Just a note, afaik controlUpdate method is called always even if not inside the camera view, it is the controlRender method that is not called when outside of the camera. But need to re-check it to get sure.

zzuegg commented 1 year ago

The shadow casting meshes are drawn, so it should not be a culling issue. However the animations stops when outside of the main camera. I dig deeper when i have time and motivation

zzuegg commented 1 year ago

Ok: ControlRender is only called when RenderManager.renderScene /renderSubScene is used. When using any other rendering commands control render will not get called. This method is only used when jme renders a viewport, which is not the case when rendering the shadow queue

zzuegg commented 1 year ago

In my shadow casters collection method i tried to call runControlRender if a spatial has AnimComposerControl and that fixes stuff. I guess this is the same root problem as with the instancing shadow problem.

Regarding fixing this in jme there are a few issues. Inside the renderSubScene is the last time Nodes gets processed.

Not sure how to fix this