Why is anisotropic filtering doing this?

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.

Now I know anisotropic filtering is causing this because if remove it everything is fine, I have included the link to a blend file
https://drive.google.com/file/d/0B_AU4X5su9P_RmZReEljWlRpblE/view

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.

In internal player:

In standalone player I get something like this:

Attachments



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).

/uploads/default/original/4X/b/4/5/b4589d80db91773a696b5bbd27b5ab8aac041eda.jpgstc=1

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).

Attachments


THANKS !!! It works properly now, also I wasn’t aware of the startup script method so thanks for that too!!