Skip to content

Draft: Texture Atlas

This MR is an attempt to introduce automatic texture atlas in OpenMW. The idea is quite simple:

  1. gather the list of the textures to build atlas
  2. build the atlas from the texture list and compute the positions texture which contains for each texture in the atlas its (x,y) position inside the atlas and its (w,h) size
  3. update the meshes when there are loaded: if a mesh reference a texture which was included in the atlas, then change the texture with the texture atlas.
  4. inform the shader that the mesh is using now the texture atlas (the shader will update the uv according to the position and size of the original texture inside the atlas)

This MR was not focused on the 1. : I simply iterate over the esm / esp to retrieve the exterior meshes and then extract from them the texture list.

For 2. the code comes mainly from the osg atlasbuilder implementation; I just simplified it a little and added support for compressed textures.

To enable texture atlas, you will have to add use texture atlas = true in [General] section of settings.cfg. You can customize the atlas size with texture atlas size = 8192 (in the same section)

Here is a screenshot which compare with and without texture atlas: https://imgsli.com/MTc1MDQ2

The number of drawables is drastically reduced (object paging can merge more meshes).

I need help to continue the development of this feature (if there is interest in it) or if someone wants to do it directly: I'm not a 3D developer and I have no knowledge in it.

Currently I do not take into account normal maps or specular maps and I have no idea of what to do

EDIT BY ANYOLDNAME3: Extra line breaks before images

Edited by Cédric Mocquillon

Merge request reports