Okay so I have two scripts running, one is basically render to texture script to render reflection and the other is bge.render.setAnisotropicFiltering…now I have an always sensor to the render to texture script, but if I set its frequency to anything other than 0, the texture gets messed up.
download it and hit P to play, it works fine, then run it with standalone player, it might work fine again, but run it again and you’ll see, I don’t get the floor texture just the distorted reflection, now set the frequency of first always sensor to 0 and play again, it works fine.
Why is this happening, I don’t want the frequency to be zero as it is heavy on logic.Here are some pics.
I’m not sure if it’s exactly a bug, but you need to run the Anistotropic filtering line just once, before you do anything else.
Running it after you bind the textures causes them to be reloaded which can make them go really strange.
You can put this code at the beginning of your camera script:
if "ini" not in own:
bge.render.setAnisotropicFiltering(2)
own['ini'] = True
Another way to do this is to mark your script as an startup script, this will ensure it gets run before others (if you like keeping your scripts more modular).
If you get slow performance you could try binding your texture just once, using the above initiation technique.
scene = bge.logic.getCurrentScene()
own = scene.objects["Plane"]
if "reflection" not in own:
cam = scene.objects["Camera.001"]
texture = bge.texture.Texture(own, 0, 0)
texture.source = bge.texture.ImageRender(scene, cam)
texture.source.capsize = [128,128]
own["reflection"] = texture
own.visible = False
own["reflection"].refresh(True)
own.visible = True
I’m not sure if this makes it much faster, it did a little bit in my tests (91 fps vs 85 fps at 1024x1024 mirror resolution).