Disable mipmaps via python script for a texture?

I am workink on some experimental pixel lowfi stuff and I need to know if it is possible to disable mipmaps with python script for a texture (or the whole scene) to take affect after the game engine was lauched. Does anyone know the trick?

Thank’s in advance! :smiley:

You can disable mipmaps in the Game Engine, but I don’t think it’s possible to do it for individual objects.

Ok, I started scripting a bit and found the answer myself. :smiley:
This may be very useful for people who want to make pixel art games. It makes sure mipmaps are off when the game engine is started.

Go to the Text Editor window and add a new text. Call it (for example) “mipmaps_off” (without " ")
This is the very simple code you have to write:

import Blender
Blender.Set('mipmap', False)

You can execute this script and it will work! But what if you make a interactive scene or a game and you publish the blend. but you doubt everyone will turn off mipmaps in the User Preferences? They won’t see the pixel style but muddy looking textures.

To make sure this script is executed, when the game engine is, do the following:

Add an “empty object” to your scene (It could be any other object, i guess, but I’d prefer this and name the empty object properly). Select it and go to Logic in the Buttons Window panel. Add a sensor and set it to “always”. Add a conroller, set it to Python, set it to Script and in this panel you have to write in the name of your script (in this example: “mipmaps_off”). connect sensor and controller. Finished!

This will turn off mipmaps in your whole scene.
:wink:

If you turn off mipmaps and save the blend it should still be off when you load it again, but that is good to know

Oh, ok. It’s still good if you want to make 1000% sure mipmaps are off independent of this option in the user preferences, i guess.

I love you! :eek: Works brilliantly!

Unfortunately (or fortunately) this is not the case.

What you can also do is go user prefs (drag down top bar) > system & openGL > disable mipmaps.

To stop mipmaps being enabled when you load the blend just use the above code as a script link as onLoad!

I meant if you did it from the user preferences, not with the script.

Is user preferences the bar you drag down at the top? If so that doesn’t work for saved files.

Anyway, the script is blender code not BGE code. Because of this it only works for games running in blender, not for compiled run times. It’s a pity because I thought I had found the solution to an old problem here.

I really wish there was a disable mipmaps button in the scene buttons that saved the setting into the file and also saved it for runtimes. Lacking disabled mipmaps is one of the few things about the BGE that really annoys me

Oh, I suspected something like this. I just started scripting a little bit and got confused about the seperation of the BGE and Blender scripts. Is there really no solution for the GE? I will try…:smiley:

Looked trough the GE docs and I don’t see any possibilty here (im a complete scripting newb though).
What about a GLSL script? It would work in a compiled runtime, right?

One of the things that was talked about for improving the GE is control on how many mipmap passes are done. So I assume the GE doesn’t have control over it.

That would be a verry good improvement to the GE because the mipmaps “pop up” pretty obviously atm and you could set the amount to 0, i guess. That would be the solution to this problem. I hope this gets into 2.5
Do you have a link to where it was talked about?

I don’t know if it will. I would imagine that it wouldn’t be too difficult to have it so you can have them turned off from the begining since I know that the game engine does run without them. (It runs in the viewport this way). I’m not versed in how it’s coded but Would really love to see a way of switching it off permanently at least. Personally I don’t care about real time switching but for some this is desired so it’s obviously the best outcome. If someone knows the right person to tell about this then it would probably make it in since its a simple (sounding) enough request.

As I’m sure everyone here knows, Pixel graphics are incredibly popular in the indie gaming scene so this is more important than it’s whimsical nature may make it seem.

I agree. If Blender shall become more popular in the indie games szene, it must have this option.
Who could we ask to do this for us? Maybe Ideasman42 ? I know he has a lot other stuff to do (and he is doing an awsome job), but I guess this is not too much work.

You’re right, Ideasman42 is the right man to ask. If he cant/isn’t planning on doing it himself he’d at least know who to talk to about it. Maybe he could get the word out. Have you messaged him? I wouldn’t want to bug him with repeat messages!

I just sent him a PM. Let’s hope he has some time left to look into it.

Hi there, You can disable mipmaps but not per-texture (yet). Its a global setting that can be set when starting the BGE or as a user preference.

In 2.5 so this option can be set for different images was recently added (since texture paint needs to disable mipmaps in the 3D view). In 2.4x it would disable for every object in the view but now it displays per object.
So this could be made to respect the texture option or added as an image preference.

We really need some more BGE devs who focus on graphics more, since I’m afraid at the moment its enough for me to work on my BGE pledge and 2.5/BGE dev but eventually could look into better supporting this if nobody else does.

How do you put this setting into effect? I know how to turn off mipmaps in the 3D viewport before playing the game but is there a way to set up a runtime so it runs with mipmaps turned off? I don’t mean per texture. Turning them off for the whole scene would suit my purposes. I don’t mean to beat a dead horse but this is an issue I’ve had trouble with before.

from blenders --help


Game Engine specific options:
  -g fixedtime        Run on 50 hertz without dropping frames
  -g vertexarrays    Use Vertex Arrays for rendering (usually faster)
  -g nomipmap        No Texture Mipmapping
  -g linearmipmap    Linear Texture Mipmapping instead of Nearest (default)

Works with the player also IIRC