[SOLVED] J3MLoader always generates mips ignoring MinFilter [Bug]

Does it change the behavior if nothing is specified in the j3m file?

If i followed your flow trough the loader i assume prior to this patch BilinearNoMips was expected but the result was trilinear.
After your fix the result would be BilinearNoMips?

Yes, it is a breaking change rendering-wise.

Correct

Yes, if nothing is specified.

Then i suggest the specs should be changed and default to trilinear when nothing is specified and don’t generate the mips when explicitely specified

Do you mean to change the default min filter to Trilinear in Texture?

It depends if/how the other methods of loading a texture are affected.
I also do not know enough on how currently models/textures are exported, if they are impacted or not. My concern is that changing default behavior is potentially affecting lots of people.

It’s not my call in the end.

IMO it is affecting in a good way, not a bad way though! :slightly_smiling_face:

They expected to load with BilinearNoMipMaps and now it loads with BilinearNoMipMaps with this patch instead of Trilinear. Trying to keep the wrong behavior seems odd to me in this case and might need to add some hack, but yeah it’s not either my call in the end as well, I would like to hear @pspeed and @sgold ideas as well.

That depends, not using mips creates problems too. there is a reason usually they are used.

If i had to make a bet i suspect you have issues with alpha discard by not using a correctly processed texture in the first place. In my opinion bilinearNoMips saves a little bit of vram at the cost of higher bandwith, more cache misses, worse aliasing. So i dont see the upgrade when used on regular models.

Yes, of course. Note that, if someone previously exported a J3M file with any min filter using mipmapping (like Trilinear, NearestLinearMipMap, BilinearNearestMipMap, NearestNearestMipMap) they would be pretty much unaffected by this change.

Right, using a higher alpha discard on transparent objects like tree leaves was causing them to dissolve/disappear when looking from far.

then i am less concerned. Even more if the other model importers set trilinear by default.

https://asawicki.info/articles/alpha_test.php5

might intrest you.

1 Like

Yes, for example, the materials I have exported from converting Gltf models are all set to use Trilinear by default.

Thanks

Ok, sorry, I was wrong about Trilinear.

If I export a j3m while using a Trilinear min filter and textureKey.setGenerateMips(true) then the min filter name won’t be written into the j3m file.

That’s because of this line of code in J3MOutputCapsule:

Both BilinearNoMipMaps and Trilinear can be the default, and thus non of them would be exported. That is stupid!

But it works in the case of Gltf models. This means if you export material from a model loaded with GltfLoader and it is using Trilinear min filter, then it will be exported to J3M file. I can confirm this as I can see MinTrilinear in all of my materials exported from gltf models.

The reason is GltfLoader never sets generateMips flag on TextureKey. So it would be false by default.

it sets the min filter here:
(The blender exported Gltf models by default using Bilinear for the mag filter and Trilinear for the min filter)

That causes to bypass this check inside J3MOutputCapsule
and so exports the filter name.

As you suggested I will default it to Trilinear then when the min filter is not specified.

Edit:

Fixed