Search Unity

What exactly does the mipmapbias do?

Discussion in 'Editor & General Support' started by imaginaryhuman, Apr 27, 2010.

  1. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    After reading every post here about mipmapbias I've learned that it can appear to sharpen an otherwise blurryish mipmap texture, but what nobody has ever mentioned, nor in the documentation, is what is happening behind the scenes when using this feature.

    My guess is that when you specify a mipmapbias of, say, -0.5, it sort of `pushes the mipmap level thresholds away from the camera`, so that a given mipmap level doesn't kick in/switch until further away, causing it to keep using a larger sized nearer texture scaled down more?

    And the reason to do this would be that any geometry which causes the texture to become smaller than its native size, even by a tiny bit, kicks in the next smaller level of mipmapping, which will be a half-size texture scaled up to the size of the geometry, which causes it to blur?

    Is that how it works?

    Wouldn't it be more sensible to use the native resolution texture all the way down to half its size and then kick in the next mimap level, which would not be scaled UP dynamically at all, only scaled down dynamically, down to the 1/4-size level before the next mimap kicks in? Is that what a mipmapbias of -0.5 would do?
     
    _eternal likes this.
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Mipmapping bias is almost always best left unchanged. The default behaviour should keep the source texture resolution as high as possible while avoiding Moiré patterns (undersampling). If you are finding your textures too blurry, your first step should be to increase the anisotropic filtering level of the texture. Also, transitions to lower resolutions can be softened by using trilinear filtering.
     
  3. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Yah I understand the trilinear and anisotropic settings.

    I just want a way to avoid mipmaps getting scaled UP if possible. I'm okay with using smaller textures and scaling them down in a set of levels but the up-scale is horrible for quality. If it were to only scale down the textures then trilinear and anisotropic (which at least half my framerate) would not be needed much.

    Since the bilinear filter samples 4 pixels, you should be able to scale a texture down to 50% of its size on the fly and the bilinear filter should produce a pretty good output pixel, right?. So once it gets down to half size it should switch to a texture which is half sized and continues to dynamically scale down from there. If it worked this way, surely there wouldn't be any real need for trilinear filtering? - I know trilinear blends between two mipmap levels but I will calculate perfect mipmaps so I don't think it'd be needed.

    Since this is only for flat 2D views not 3D, but where a texture might cover large or small objects, I might just do a manual texture swap based on the size of the object and avoid in-build mipmaps altogether.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I'm not sure how that follows. No matter how great your second mipmap level is, it's still 25% the size of the first one, and switching from one to the other is pretty noticeable. If you use trilinear filtering, then there isn't any swap, there's just a smooth transition.

    --Eric
     
  5. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    It does follow because if the smaller mipmap texture never scales UP, it won't be suddenly blurry when there is a transition between levels.
     
  6. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    THis might be a necro bump, but does anyone know how to blur using mipmapbias? i can't find anything on it...
     
  7. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    There's a mention that values less than -0.5 decrease performance. How bad is that decrease?
    Will it be noticable on the modern day PC?

    How does mipmapbias works? Does anyone have any extra info?

    What I want to achieve a rather sharp look of the mipmap texture, but not as sharp as initial image.
    Aniso levels are fine and dandy, but not what I actually want. And they do not produce as sharp result even at 16 level. Where as -1.5 mipmap bias does.

    Sorry for necroing this, but really need info.

    If the performance impact is on par of disabling mipmap, I can live with that.
     
    Last edited: Jun 19, 2019
  8. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    So if anyone wondering, less than -2 value has approximately same performance impact as not having mipmaps. (Although its still better than not having them at all, visual quality & performance wise)
     
    sqallpl likes this.
  9. JFLGD

    JFLGD

    Joined:
    Apr 16, 2022
    Posts:
    2
    Hi, to have a more exact idea of how much memory is used while loading texture you can use :

    Code (CSharp):
    1. Texture.desiredTextureMemory
    then ajust accordingly your mipmaps.