BGE proposal: Object-individual Mipmapping

Issues:
Mip-mapping is a pretty good method to avoid ugly moire effects on textures and allows faster texture handling.
On the other hand automatic Mip-mapping does not always create the best solution.
Unfortunately the BGE supports automatic mip-mapping only. It belongs to all objects or none.

Use cases:

  • high contrast textures like shapes, fonts
  • GUIs.
  • 2D-style games
  • Cartoonish games etc.

My suggestion:
A) allow to enable/disable mip-mapping at object level
B) allow to use custom mip-maps beside automatic mip-mapping

Benefits:
A)

  • Allows sharp and high contrast textures on selected objects
    B)
  • Better control over the texture appearance by the game designer.

Drawbacks:
A)

  • I can’t see any drawbacks
    B)
  • more complexity on setup

Workaround:
The only workaround I know is to scale up the texture with an image processor (without filtering).

Remarks:
I have no idea how complex such an implementation would be. I just know that OpenGL supports that.
A)

  • The GUI needs a flag to disable Mip-Mapping on Object
  • The Python API needs an attribute to read and write this flag on the fly
    B)
  • The GUI needs some options to set mip-maps maybe with texture panel?

You can already enable / disable mipmapping on texture level under “image sampling”:
test_mipmap.blend (450 KB)


This file does not make a difference for me. Both cubes are smoothed out even when I disable interpolation and mip-map on the texture of the red one.

In-game (and preview) it is blurred.

what version did you use?

DDS textures give you manual control of mip-mapping.

In general, getting the texture option to work shouldn’t be difficult, it’s just that no one has done it.

I’m guessing that Wendigo is using the Candy build (I thought mokazon added image sampling)…? Anyway, I’m not sure of the need to have it exposed to Python, as it’s not often that you would want to change the interpolation of an image in-game. However, I am all for this, since it’d mean no more need to use the “No Mipmaps” command in Blender and the BlenderPlayer (for my 2D / pixelly games).

Strange, I used the Windows Version 2.65.0 r52859
Will check it under Ubuntu when I get home.

Enable/Disable with Python is not really needed.

The Mip-Map setting in Texture seems to be a good switch. As I said it did not work for me (2.65.0 r53189) and I manually had to switch off interpolation to see the sharp texture in texture preview (still blured in 3D Window). Maybe something else needs to be chekced/unchecked?

In blender itself I can only see the scene without Mipmapping when I disable MM in the user preferences (though this only works for all or none).
But on export as runtime the result is as shown in the screenshot.

I just unchecked “Mipmap” under “Image Sampling” that was all.

hmmm, no difference with blenderplayer :(.

So I guess this something to look at.

I am having the same trouble as Monster with the mip-mapping options in “image sampling”. What graphics cards are you guys rocking? I have an AMD HD 7750, so ATI vs nVidia could be the problem.

ATI Radeon HD 3400 Windows XP 32bit

Edit:
I exported the file as runtime under Ubuntu 64bit with the same version of blender and it worked too.
(ATI Radeon HD 6850)

Ok everyone.
Did everyone here including (@Monster :wink:) not realize that @Wendigo’s per-object mipmapping script worked (???)
It even works in Vanilla (Legacy) BGE (!)

I vote that this should be a thread pin in #game-engine:game-engine-resources.

1 Like

nope.
It doesn’t works for me either.

script???

there is not a script in the file.

1 Like

@Murilo_Hilas You can edit per-object mipmaps without python but it is not user-friendly. -_-
I doubt many people know that this works for the game engine. (sometimes?? weird)
Outliner > data-blocks > the texture you want to remove mipmaps > uncheck mipmaps/interpolation. It works.


image

2 Likes

@Murilo_Hilas
This link?

The logic won’t work properly until the Shading to Multitexture or GLSL (Blend file was made in a non-official BGE version thus corrupting the blend file)
Logic-Bricks are needed to work with the script as shown in the blend file.

Script that was in the blend-file.

import bge
from bgl import *

cont = bge.logic.getCurrentController()
own = cont.owner

bindcode = own.meshes[0].materials[0].getTextureBindcode(0)

space = cont.sensors["space"]
escape = cont.sensors["escape"]
own["i"] = 0

glEnable(GL_TEXTURE_2D)

def enableMipmap():
    glBindTexture(GL_TEXTURE_2D, bindcode)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
    glBindTexture(GL_TEXTURE_2D, 0)

def disableMipmap():
    glBindTexture(GL_TEXTURE_2D, bindcode)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
    glBindTexture(GL_TEXTURE_2D, 0)

def switchMipmap():
    own["i"] += 1
    if own["i"] % 2 == 0:
        enableMipmap()
    else:
        disableMipmap()
        
def main():
    
    if space.status == 1:
        switchMipmap()
    if escape.status == 1:
        enableMipmap()
        bge.logic.endGame()

@festive_enthusiast
I don’t know if your using Vanilla BGE.
But the data-block texture mipmap options are for Blender Render, not Blender Game.

1 Like

It does work in the regular BGE but only in windowed multitextured mode.


mipmap_bge.blend (479.2 KB)

1 Like

thanks people.

there is no logic bricks in the objects.
but i realized it works in stand alone mode.

Here, I whittled down the script and attached it to one of the cubes so it removed mipmaps. It should work for whatever object it is attached to in GLSL mode.
mipmap_bge1.blend (488.0 KB)

1 Like

Your method works in Multitexture surprisingly - Thanks for sharing.
Also, for me, it worked not only in Windowed but also Full Screen.

1 Like

I was gonna say thank you as well for the code above. I’ve been looking for a method for disabling mipmaps on video textures for ages and the one you posted seemed to do the trick for me.

1 Like