How do I use different texture resolutions?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DimitriyPS

I use 2048*2048 textures for 3D objects. I would like to implement a texture resolution switch (512/1024/2048) in the game settings. How can this be done in Godot?

:bust_in_silhouette: Reply From: Zylann

I’m afraid you will have to swap all textures of all 3D objects with a manual script, I’m not aware of any easy engine switch to change which textures get loaded at runtime for now.

It may be just a script running on every instanced scene which replaces materials or textures in those materials by their lower res counterpart. The problem is, that won’t prevent the initial high-res texture from loading first.

You may want to ask for this in the issue tracker (i.e a “quality setting” option to make the engine switch between materials). But doing so will often involve scripting on your end regardless.

:bust_in_silhouette: Reply From: MysteryGM

If you are still fine with loading the large textures, and only want the smaller ones for performance then there is a way.

In the import settings, turn on Mipmaps. Then use the size limit to define what texture you want.
So you will import a 2048 texture, turn on mipmaps fot it and limit it to a 512 size. This is the same as using the shader LOD system.
The 2048 is still loaded but a smaller version is rendered.

No, that’s not the right thing. I want to enable the end user of the game to be able to customize this. All this for the sake of achieving sufficient performance on weak PCs. It makes no sense to load a large one - display a small one.

DimitriyPS | 2018-11-16 07:29

That is how most AAA games do things. First the texture is loaded into ram, a mip is selected and passed into the graphics memory.
On PC RAM is considered cheap, it is the one thing any gaming PC has in abundance.

One trick you could try, is making new textures from existing one at real-time. That way it loads the large texture, makes a small one and removes the large one from memory.

MysteryGM | 2018-11-16 11:40

One trick you could try, is making new textures from existing one at real-time. That way it loads the large texture, makes a small one and removes the large one from memory.

Yeah, it’s probably the only thing I can do right now. But this is very inconvenient both in implementation and in future changes. I was just asking if there was any automated solution.

I opened the offer: Use different texture resolutions · Issue #23739 · godotengine/godot · GitHub

While the project I’ll leave it as is.

DimitriyPS | 2018-11-16 12:36