Is it possible to override the texture filtering behavior?


I’m working on a game with a lot of gui and 2d things going on. So we have many texture cards, directFrames, etc. parented under aspect2d.

I want them to look as crisp as possible, so when the window size is at the target resolution of 104x768 I want no filtering to occur on the 2d objects.
When the screen is larger than 1024x768 I want linear filtering and when smaller I want trilinear mipmapping.

Is there a way to specify a texture filtering override on, say, aspect2d? Or would I need to iterate over all textures and change the texture attributes directly?



The filter is a property of the texture, not the scene, so you would need to change all textures that you want to have this property.

Depending on how you loaded the texture, you might be able to specify it at a higher level. For instance, if you used egg-texture-cards to create the texture, you can put the filter settings in the egg file (there could be an option to egg-texture-cards to do this, but there isn’t right now).

If you load the texture via loadTexture(), you have to set the filter settings via explicit calls.


hi erik :slight_smile:
das wird dir ein biserl helfen! ich schraub grad an einem EDITOR/modelviewer rum. mach einfach ein zusätzlich routine dazu in der du die texturen lädst. die models kannst ganz einfach angreifen im array (objlist). python is genial :smiley: ich komm gar nimmer davon weg.

der tanz zwischen schlange und dem bären ist umwerfend :smiley:

für die crispy textures = texture.setMagfilter(0) mehr hab ich leider nicht rausgefunden.

best greetz
dirk :slight_smile:

hoffentlich sehen wir uns bald wieder!

#parallel loading models
#dirk hochegger 2008
import direct.directbase.DirectStart
from direct.showbase import DirectObject
from threading import Thread
from direct.showbase.Loader import Loader
import os
from os.path import join, getsize
from pandac.PandaModules import Point3
#import buttonsGRID
#import gridFIELD

class callingTHREAD (Thread):
    def __init__(self):

        dir = str("modelCONTAINER/")
        global objLIST 
        objLIST = []
        files = []
        countLIST = []
        global inputLIST
        inputLIST = []
        for root, dirs, files in os.walk('modelCONTAINER'):
            print "files in directory","../",dir,"->", len(files)
            XX = len(files)
            files = os.listdir('modelCONTAINER') 
        d = -1
        for x in range(XX):
#            clearMODEL=open("metaINFOS/clearMODEL.dat","w") 
#            clearMODEL.write("0")
#            reloadMODEL=open("metaINFOS/reloadMODEL.dat","w") 
#            reloadMODEL.write("0")
#            hideMODEL=open("metaINFOS/hideMODEL.dat","w") 
#            hideMODEL.write("0")
            d += 1 
            fileOPEN = dir + files [d]
            c = len(zeilen)
#            counter = str(d)
#            source = str(file1)
#            renameMODEL = str("modelX")
#            renameEXT = str(".egg")
#            renameX = str(renameMODEL + counter + renameEXT)
#            renamed =str(renameX)
#            print "renamed ->",renameX
#            os.rename(file1,renamed)
            #print "count file1 ->",c
            print "FILE ->",files [d],"ENTRY ->", d,"COUNT ->",c
            allMODELS = str(files)

        dx = -1
        for x in range(XX):
            dx += 1
            fileOPEN = dir + files [dx] 
            input =

        ml = -1 
        for x in range(XX):
            obj1 = []
            ml += 1
            file = files[ml]
            fileX = file 
            fileNAME = dir + file
            print fileNAME
            global obj1 
            obj1 = loader.loadModel(fileNAME)            

        def moveMODEL(task):
            DD = -1
            for x in range(XX):
                DD += 1
#                #take model
#                ID = gridFIELD.outputKM
#                #MODEL translation
#                movX = gridFIELD.outputX
#                movY = gridFIELD.outputY
#                movZ = gridFIELD.outputZ
#                print "MODEL ID ->",ID
#                print "MOVE MODEL in X->",movX
#                print "MOVE MODEL in Y->",movY
#                print "MOVE MODEL in Z->",movZ
#                print objLIST[DD]
#                hideMODEL=open("metaINFOS/hideMODEL.dat")
#                info =
#                clearMODEL=open("metaINFOS/clearMODEL.dat")
#                info1 =
#                reloadMODEL=open("metaINFOS/reloadMODEL.dat")
#                info2 =
#                infoTOint = int(info)
#                info1TOint = int(info1)
#                info2TOint = int(info2)
#                print "info->",info,"info1->",info1,"info2",info2
#                if infoTOint >= 1:
#                    objLIST[DD].hide()
#                    print "MODELS SHOULD BE HIDDET"
#                else:
#                    objLIST[DD].show()                
#                if info1TOint == 1:
#                    obj1.detachNode()
#                    objLIST[DD].detachNode()
#                    print "MODELS SHOULD BE kicked"
#                if info2TOint >= 1:
#                    ml = -1 
#                    for x in range(XX):
#                        ml += 1
#                        file = files[ml]
#                        fileX = file 
#                        fileNAME = dir + file
#                        print "XXXXX"
#                        global obj1 
#                        obj1 = loader.loadModel(fileNAME)            
#                        obj1.reparentTo(render)            
#                        obj1.setPos(-3+ml,-4+ml,-3+ml)
#                        objLIST.append(obj1)
#                    reloadMODEL=open("metaINFOS/reloadMODEL.dat","w") 
#                    reloadMODEL.write("0")
#                    print "MODELS SHOULD BE reloaded"
            return task.cont
d = callingTHREAD()

setMinfilter and setMagfilter

Right. Note that when the texture is mapped one-to-one in texels to pixels onscreen, no filtering occurs regardless of the filter settings. When the texture is reduced, the minfilter is used, and when the texture is enlarged, the magfilter is used. So you just need to set the minfilter to mippmapping and the magfilter to linear, and you’ve got exactly the behavior you describe, automatically.