Hello,
I'm looking for a way to use different textures/datablock for objects further away from the camera. For the meshes themselves lods are working but how could I set the datablock to use depending on the lod level displayed please? The sample block allows to display a minimal/maximal mipmap level but that doesn't improve memory consumption.
Also i'd like to add a quality settings and possibly reduce all textures' resolution at loading (like auto generate mipmap but auto downscale?) I saw a post about this but it dated back from 2.1, is there a way to do it now?
Datablock per Lod level / texture quality
-
- Gnoblar
- Posts: 11
- Joined: Sun Nov 22, 2020 3:29 pm
- x 1
Datablock per Lod level / texture quality
-
- Gnome
- Posts: 388
- Joined: Sat Jun 23, 2007 5:16 pm
- x 99
Re: Datablock per Lod level / texture quality
I'm not an expert. Just noticed that there is something like a texture array now in shaders, perhaps this can be used, IDK if this needs same size though. Or maybe one can just tell which mipmap to use when sampling, or that's automatic.
Switching datablocks hmm I don't think that's possible, or would be CPU/GPU costly.
I think I'd rather create few LOD sets and make only 1 visible at each time. Just like I do for Stunt Rally road. I still go each frame for each (merged) road segment (from all 4 LODs) and set 1 visible depending on how far it is from camera (less geometry further). I'd say those could have different datablocks too, why not.
-
- Gnoblar
- Posts: 11
- Joined: Sun Nov 22, 2020 3:29 pm
- x 1
Re: Datablock per Lod level / texture quality
Thank you, without a solution from Ogre I was thinking about doing something similar and manually pick which Item (with it's own datablock) to display.
Do you manage different texture resolutions in Stunt Rally and if yes did you prepare them before hand or do you downsample them dynamicaly?
-
- Gnome
- Posts: 388
- Joined: Sat Jun 23, 2007 5:16 pm
- x 99
Re: Datablock per Lod level / texture quality
I don't have different texture resolutions now. I had them in old SR 2.x, and it was done just once at start, simply by resource manager, it was loading few different folders when low resolution was chosen.
But it was some more trouble to keep them in sync and also more space used.
It would be cool if this was done dynamically by Ogre/OgreNext already. So e.g. I'd specify size up to which all textures will be loaded, if they are bigger then would auto resize.
But it's not, and too much trouble to code this for me. I generally don't really support laptops where it would matter anyway, and I don't really have that big textures in game either. Most terrain textures are still 1k x 1k or 2k x 2k. And skies are 8k x 2k now but only 1 sky is visible and it needs quality.
-
- OGRE Team Member
- Posts: 5433
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1341
Re: Datablock per Lod level / texture quality
Hi!
We tried to support datablock changing per LOD but it was too difficult to design (without either making it too complicated or very high overhead).
Please still note that the goal for such approach would be to disable features (e.g. disable normal maps or shadow maps). If you're worried about texture resolution; that's what mipmapping does naturally: As objects become further away (thus, smaller), the GPU will automatically pick a higher mip level (i.e. lower resolution).
If you're worried about total memory consumption and setting a "texture quality" slider (i.e. make all textures half the size for lower end HW); we don't support one out of the box.
Slightly modifying OgreNext it should be possible to implement something by inserting your own listener and overriding TextureGpuManagerListener::getFiltersFor (no need to modify OgreNext); and implementing a TextureFilter (see OgreTextureFilters.h) that reduces the resolution (would need OgreNext modifications to add the filter).
Since you're worried about memory consumption make sure to read Tunning memory consumption and resources & see Watching out for memory consumption. That section talks about HlmsTextureManager::dumpMemoryUsage
which has been replaced by TextureGpuManager::dumpStats
which works the same way.
Cheers
-
- Gnoblar
- Posts: 11
- Joined: Sun Nov 22, 2020 3:29 pm
- x 1
Re: Datablock per Lod level / texture quality
Thank you for your inputs, as always!