NVIDIA TEXTURE TOOLS EXPORTER - Scaling alpha for mipmaps (grass)

Hey there,

Having some issues with alpha scaling on a grass asset (DDS texture).

If I select the option to scale the alpha threshold for mipmapping then mip 0’s alpha threshold seems to change, so the grass that’s up close looks incorrect, but the grass that’s far away looks good, extending far into the distance as intended.

Is there a way to make it so that only mips 2-11, for example, see the scaling, and the up-close version retains its alpha threshold?

I’ve searched everywhere but I can’t see any functionality to edit individual mipmaps. Is there any way round this at all

Hi smgard101!

This sounds like it could potentially be a bug. Looking at the code and the app, though, Scale Alpha for Mipmap Coverage shouldn’t affect mip level 0. Just to clarify, is the problem (in some sense) artifacts with mip level 1 (i.e. mips 0 and 2-11 are OK, but mip 1 has artifacts)? Alternatively, is there a way that I could reproduce the problem locally?


Hey nbickford,

Thanks for your reply! I realize I might be reaching a bit far on this one

I can see changes to the geometry after exporting with alpha scaling when zoomed right up close to the grass (presumably this would be mip 0?) To better illustrate this, I’ve gathered a series of image comparisons, as well as the dds file itself (post export).

These can be downloaded here: https://mega.nz/file/7LJxxSzS#0JpinQ21vgREuqx-ENydLqQ1VZJj82v6P1aQB6Wj-Y4

It’s quite hard to see, but flick back and forth between the pictures and you can see lining appearing, and becoming more obvious at distance.

I guess being able to manually turn off scaling for certain mip levels would solve this problem, but not sure why change seems to be occurring at very close.

Other things I’ve tried

  • Cutout alpha

  • Zero alpha border

  • Lower threshold for the scaled alpha for mipmap coverage

All best !

Hi smgard,

I don’t have a solution yet, but I think I have an idea of what might be going on here!

Here’s a version of Grass_MXGrass.dds, where I’ve enabled Scale Alpha for Mipmap Coverage, and also given each mip a different color. (Mip 0 is the original texture, while mips 1 - 11 cycle in hue from cyan, to blue, to purple, then to orange and chartreuse): https://drive.google.com/file/d/1fzJS_uiK8OfPlERseN2w_xbxK_P6trN8/view?usp=sharing

Could you load it in, then look at the grass up close, but from above (i.e. reproducing the vertical lines in the images), and see if it’s rendering from a higher mip level?

Here’s what I think might be going on: When using mipmapping, looking at a textured surface from a glancing angle will usually still sample from higher mips, because each pixel still covers multiple texels (in a highly anisotropic line - unless looking at the texture from very up close). In the screenshots, the grass cards that are causing these artifacts are being viewed from glancing angles that might sample from higher mips.

Additionally, as you know, Scale Alpha for Mipmap Coverage tries to scale the alpha channel of higher mips, so that approximately the same percentage of texels have an alpha value that is greater than the threshold. For these thin grass blades, Scale Alpha for Mipmap Coverage has an especially strong impact - and in particular, for higher mips, makes a line at the bottom of the image significantly more opaque. Here’s a screenshot of the alpha channel of mip 7 to show the difference:

Could it be the case that previously, these grass blades would be almost invisible when viewed from the top (as almost no texels would pass the alpha test), but with Scale Alpha for Mipmap Coverage enabled, more texels pass the alpha test, and so the form of the geometry (a plane, which looks like a line from above) shows up more?

If this turns out to be what’s going on, I’m not totally sure what the best solution would be. Maybe since one might want to preserve opacity when viewed from far away, but remove opacity when viewed from above, it might be possible to modify the grass shader to detect when a fragment’s viewed at a glancing angle, and to scale down the alpha before the alpha test if so? (Or maybe one could add noise to the alpha channel in those glancing-angle cases to make the grass look more natural?)

Hope this helps!

Hey Niel,

Thanks so much for your time investigating this issue

You were correct about the mipmaps displaying even when up close, based on angle. In the screenshots here you can even see mips 8-9 (pinky orange), and they remain even when zoomed all the way in.

I was surprised to see this.

Unfortunately an in-engine solution, shader or otherwise, is probably not applicable due to the age of the game. So for the moment I think I am stumped!

All best