Change texture filtering for all .egg models

Hello. I woul like to change models texture filtering (on the init). Setting

loadPrcFileData('','texture-minfilter  nearest')
loadPrcFileData('','texture-magfilter  nearest')

does not help. These settings don’t override egg models own “minfilter” and “magfilter” properties.
“egg-ignore-filters” configuration variable also does nothing.

I can achieve the effect either by

  1. changing texture filter for each model explicitly (I haven’t found the constants anywhere, so I assume 0 is “nearest”):
tx = my_model.findTexture('*')
tx.set_minfilter(0)
tx.set_magfilter(0)
  1. Or completely disabling the filters by setting “gl-ignore-filters” to “true”.

Is there any other way to achieve this? Thanks.

Setting texture-minfilter and texture-magfilter only changes the default setting. If you remove the minfilter and magfilter lines from your .egg file, you’ll notice that it is loaded as having the default setting.

The constant is called Texture.FT_nearest in 1.8, and SamplerState.FT_nearest in 1.9 (though the old syntax is also still accepted in 1.9). FT_nearest is indeed 0.

There’s no built-in way to override the filter type for all textures, besides something like:

for tex in model.find_all_textures():
    tex.set_minfilter(SamplerState.FT_nearest)
    tex.set_magfilter(SamplerState.FT_nearest)

Or, to make it affect all textures ever loaded from disk:

for tex in TexturePool.find_all_textures():
    tex.set_minfilter(SamplerState.FT_nearest)
    tex.set_magfilter(SamplerState.FT_nearest)

Thank you for the explanation. Could you please also tell how “egg-ignore-filters” variable is supposed to work?

From what I can see in the source code, it changes the egg loader to set the minfilter and magfilter to “nearest” whenever it encounters a minfilter or magfilter instruction, besides printing a warning saying “Ignoring minfilter request” or something like that.

Strange, but it does nothing, even no warning. My Panda3D version is 1.9.0.

Hmm, works fine for me. I took a textured model, added in minfilter and magfilter definitions (set to “linear”), set egg-ignore-filters to “true” in Config.prc, and loaded the model in pview. Sure enough, I saw the warning messages, and the texture showed up with nearest filtering.

This is what the section in my .egg looks like:

<Texture> noise {
  "maps/noise.rgb"
  <Scalar> minfilter { LINEAR }
  <Scalar> magfilter { LINEAR }
}

I’m using the latest master version of Panda3D, but I don’t think anything has changed between 1.9.0 and the latest master version.