Chris McCole

View Original

Mips in Unreal Engine 4 (UE4)/UE5 - Create Custom Texture Groups

Index:

See this content in the original post

Mips (Mipmaps)

Mips, for those unaware, are a collection of textures at varied resolutions. These are generated automatically by Unreal Engine 4, so long as your texture import settings, or texture group is set to generate the mips. The purpose of mipmaps, is to reduce effort rendering objects that are farther away, you don’t need to be rendering the texture data for that object it’s full 4k (or whatever resolution is your full texture resolution, be it 2k, 1k, etc.) texture size. Since the object is farther away, you can optimize your rendering process by using a lower-resolution texture.

Mip-mapping example provided by : https://www.3dgep.com/learning-directx-12-4/

Inside of Unreal, you can view the mip-levels on each texture within the texture viewer window. At the top, you can check the Mip Level checkbox, and then select the mip-level desired.

See this content in the original post

Enabling/Disabling Mips

Never Stream

One way to disable using Mip Levels, which is particularly useful if you have an asset that is loading in at a lower mip level than desired. The typical solution you will find is in the texture import settings, under the LOD section, you can tick the “Never Stream” toggle. This will ensure that mip levels are never streamed, and thus will always use the max level.

Mip Gen Settings

The typical setting for this is set to “From Texture Group”, however, if you ever want to override this, simply select the dropdown box and select “NoMipmaps”.

See this content in the original post

Mipmap Generation Settings

Most of the generation settings for your mip-maps are handled within the Texture Group for that asset. You can see these settings, and modify them, within your Config\DefaultDeviceProfiles.ini file under the [/Script/Engine.TextureLODSettings] header.

You can see the Group name, as well as the following possible properties:

  • MinLODSize

    • This is the minimum mip size that will be rendered (in power of 2, from 1 - 8192)

  • MaxLODSize

    • This is the max mip size that will be rendered (in power of 2, from 1-8192)

  • LODBias

    • Number of mip levels to offset prior to uploading for render ( negative or positive)

  • MinMagFilter

    • Texture filter type when minified or magnified

  • MipFilter

    • Whether two mip levels should be blended together when from distance or angle.

  • NumStreamedMips

    • Number of mips that can be streamed from highest res to low. If -1, will be all mips.

  • MipGenSettings

    • The generation settings for how the mips are computed, these can all be seen under the Mip Gen Settings in the import settings, and can be set via the enums on this page here.

See this content in the original post

Making Your Own Texture Group

You may have noticed, if you are looking in the DefaultDeviceProfiles.ini file or looking under the Texture Group dropdown menu on your import settings, that there are 15 custom texture groups for you to make and use however you want! The way that you define how these work is quite simple.

First you must open your DefaultDeviceProfiles.ini file found in your Config folder. Next, you must navigate to the section with the header

[/Script/Engine.TextureLODSettings]

And find the line :

+TextureLODGroups=(Group=TEXTUREGROUP_Project01,LODBias=0,LODBias_Smaller=-1,LODBias_Smallest=-1,NumStreamedMips=-1,MipGenSettings=TMGS_SimpleAverage,MinLODSize=1,MaxLODSize=4096,MaxLODSize_Smaller=-1,MaxLODSize_Smallest=-1,OptionalLODBias=0,OptionalMaxLODSize=4096,MinMagFilter="Aniso",MipFilter="Point",MipLoadOptions=AllMips,HighPriorityLoad=False,DuplicateNonOptionalMips=False,Downscale=1.000000,DownscaleOptions=SimpleAverage,VirtualTextureTileCountBias=0,VirtualTextureTileSizeBias=0,LossyCompressionAmount=TLCA_Default)

On this line, you can see all of the options are already filled in for you, and there are many options extra than provided in the default texture groups defined above. You can change any of these settings however you wish, the primary points of interest being those marked above in my section titled: Mipmap Generation Settings.

Once you have it setup how you like, you will want to give your group a name so you can more easily refer to your texture group. To do so, you will have to navigate to your DefaultEngine.ini file, also found in your Config folder. Once inside, find the [EnumRemap] section, and if you can’t find it, just simply create one! Once created, you can remap your TEXTUREGROUP_Project01.DisplayName to whatever name you prefer as such:

[EnumRemap]
TEXTUREGROUP_Project01.DisplayName=World Props

Now, when I restart the engine, and dropdown the Texture Group settings, I can select World Props as a texture group now, and when I make changes to the group in the DefaultDeviceProfiles.ini, it reflects those changes to all my textures in that group!

See this content in the original post

Force Object To Load at Maximum Mip Levels

Once in a while, you will have a shot in a sequence, or in our case a selection screen, where the mip levels just aren’t working with you. You could set the asset to use no mips, or not stream their mips, however, you want the benefits of mips for the majority of the game. What do you do? Well, Unreal actually has a blueprint node that you can call with a reference to a material instance, and you can manually force Unreal to forget about that asset’s mip levels temporarily. This blueprint node is called: Set Force Mip Levels to be Resident.

Force high-level mips.

This node has a few parameters, however, to force load the highest-level mips, you will need to check the two booleans that I have selected to ensure that Unreal doesn’t consider any other factors for whether to load the mips. Also, you may want a higher or lower duration depending on your use case. The main thing I don’t reccomend, is using the “Fast Response” boolean. And I don’t reccomend using this, because Unreal tells you not to! If you hover over this parameter, they mention that it’s dangerous, can cause crashes, and makes streaming caclulations hard, I’d rather look low-res than crash.


If you found this tutorial helpful and want to help support me in creating this content that I host and publish for free, please consider contributing to my Patreon or Ko-fi!

See this form in the original post