The order was prepareShadowTextures(), then updateSceneGraph().
Here is a sort of pseudocode of the flow to illustrate the bug (each level of indention is a deeper level of the call stack):
Code: Select all
SceneManager::_renderScene( main camera ) ->prepareShadowTextures() ->set up shadow cameras (shadow space projection matrices are pushed into GPU params) ->render shadow maps ->_renderScene( shadow camera ) (recursive call to render the first shadow map) ->updateSceneGraph() (main camera is moved here because it is attached to a sceneNode, and this is the first time in the frame updateSceneGraph has been called) ->render shadow map ->updateSceneGraph() ->render main camera view (using stale matrices from the previous camera state)
I believe the only reason this bug hasn't been noticed before is that the recursive calls to _renderScene() tend mask the problem in many cases. In my case, this bug was only apparent when camera-relative-rendering mode was on (and the camera had to be parented to a scene node).
I would expect that if there was a weird and obscure reason why updating the scenegraph should come after preparing shadow textures, that there would be a comment in the code explaining it. But there isn't.
So barring any objections, I'll submit a patch for this to v1-8 branch.