Lagging reflection

It’s about water again… sorry :mrgreen:

The reflections lag behind a bit, when the camera moves the reflected image updates to slow, you can see it happening in this video (at about 7 minutes int the film):

I tried setting the sort value for the reflection buffer really low (and really high just to make sure), and the same with tasks updating the camera, I’ve only managed to make it worse.

I have two tasks for the camera - one moves it the other updates all the shader inputs, I did try to move all the code to one task but that also didn’t make things better.

All the code is (somewhere) in here:

Any tips?

So there are two things to worry about: the buffer’s sort value, and the task to update the reflection camera.

Now, if you print taskMgr, you should see something like this:

>>> print base.taskMgr
AsyncTaskManager TaskManager

  Task chain "default"
   Task                             sleep(s)   dt(ms)      avg      max   sort
   resetPrevTransform                                                      -51
   dataLoop                                                                -50
   eventManager                                                              0
   ivalLoop                                                                 20
   collisionLoop                                                            30
   garbageCollectStates                                                     46
   igLoop                                                                   50
   audioLoop                                                                60

“igLoop” refers to the rendering task. So you need to make sure your task to update the camera and shader inputs are run after any tasks that might update the camera, but before igLoop. So try giving it a sort value of, say, 45.

As for the buffer, you need to make sure it is rendered before the main window. So, any negative sort value will probably do the trick.

I’ve set the sort of the task updating the camera pos to 45 and set 46 for the task setting the reflection matrix, the buffer got a -1 sort value. Still lagging a bit :confused:

I’ll try to limit the camera move speed, maybe that will hide the effect a bit.

Well, break the problem down to try and isolate where the problem lies.

If you enable the buffer viewer using base.bufferViewer.toggleEnable(), does that show lagged as well? If you use showFrustum() with base.oobe() or something like that (or you could try attaching it to a separate display region in the same window), do you see the reflection camera being physically delayed?

The water camera frustum moves perfectly in-sync with the, it’s hard to tell if the buffer is updated at the right time - I’ve got a total of 12 buffers and the bufferViewer wants to show me all of them and they end up being post-stamp sized, even if they’d be larger I could only see the lag when the view from the buffer is over on the view from the main cam.