VideoTexture Refresh Lag

Hi! I’m having some trouble with using VideoTextures for a mirror in the BGE. There’s an attached file if you want to see how I have it set up.

The VideoTexture itself is fine. It works like a mirror should, except that the reflection lags. This is probably either because the reflection is rendered before the new object positions are calculated, because the reflection is rendered after the rasterizer renders everything else (including the previously rendered reflection), or because the rasterizer is rendering frames faster than the script can refresh the reflection. Or something. Trying to sort everything out in my head makes my brain hurt.

Does anyone know of a way to make sure the mirror is showing the current frame’s reflection? It’s ok if the FPS has to be reduced to make the logic, or whatever. I was just wondering if anyone had any ideas.

And just in case it helps to know, I’m averaging about 40 FPS. I suspect the problem will be harder to detect on computers with higher framerates. I ran the current game as a runtime, and the problem was present, but generally less noticeable.

Thanks!

EDIT: Does anyone know what order the Game Engine processes stuff in? I assume it’s logic, then physics, and then rendering, but I could be wrong. If figure it might help to know when in the pipeline the reflection gets rendered.

Attachments

6508.blend (347 KB)

Couple of things about reflections -

  1. Running the script every frame should make it update exactly in time with the game view (to my knowledge). Are you sure that your Always sensor running the script is firing every frame?
  2. Reflections are CPU-intensive, so try setting the texture’s size lower. There was a thread dealing with this info here somewhere… Do a search for it.

Thanks for the fast response!

  1. As far as I am aware, it’s running every frame. There’s no delay on the always sensor, anyway, and the texture refreshes every frame. The problem is that it’s showing the reflections a frame late. There is a noticeable change in the texture for one frame after things stop moving.
  2. Actually, I was wondering if there’s a way to make the resolution match the screen resolution. At the moment, it’s lower. I was hoping that the mirror wouldn’t look like a texture. But that’s a different problem entirely. Well, mostly, but I’m pretty sure the problem would be there as long as I use videotextures.