Jump to content
  • entries
    943
  • comments
    5,899
  • views
    924,707

Texture Import Features


Josh

4,846 views

 Share

blog-0940183001399675559.jpgSince I am working with the Blender import pipeline and also getting artists onboard the Steam Workshop, it makes sense to work out any little details in the art pipeline that can be improved. One of these is the texture import process.

 

Leadwerks 3.0 was designed to function across PC and mobile, and one of the compromises that had to be made was texture compression. There is no universally supported texture compression format on mobile, while the PC has several variations of DXT compression to choose from. It is possible to save textures with DXT compression and then uncompress them on mobile devices, but then you end up increasing your load times. OpenGL 4.4 finally has a universal compression format, but none of the hardware out today supports it. So there's not really a good solution here and this is an example of how mobile was holding back what we could do with the engine.

 

I've just added controls in the texture editor to select the DXT compression level used. The default is DXT1. The Leadwerks 2 DXT1 compressor had some errors in it that would cause visual artifacts, and the format gets a bad rap overall, but where else can you get 80% of the quality in 12% the video memory? Nowhere, that's where! I fixed the compression errors in my code and I can't tell a difference between most uncompressed textures and the DXT1 version in Leadwerks 3.1. You can also select the compression format, save the texture and see for yourself what you want to use. DXT3, DXT5, and DXT5n are also available.

 

DXT5n is an interesting format, because it's just DXT5 with the red and alpha channels swapped. In DXT5 compression, the alpha channel has a higher resolution than the red channel, so using this format for normal maps can compress your normal maps while avoiding the visual artifacts texture compression can cause when used with normal maps. If your texture is checked as a normal map and any compressed format is selected, the texture converter will automatically override that selection with DXT6n, in order to prevent mistakes. OpenGL 4 allows a texture swizzle setting so I can set it so a shader will automatically swap and red and alpha channels during a texture lookup. This is another reason I want to focus on modern OpenGL; a fallback renderer would not be able to read these textures correctly, which means normal maps could never use compression.

 

blogentry-1-0-95742000-1399674938.png

 

Finally, an unsharp mask filter has been added. Textures work by storing many downsampled copies of the texture all the way down to a 1x1 image. This is why textures ideally need to be power-of-two sized. However, that downsampling process can make images appear blurry at a distance. The new unsharp mask filter will perform a sharpen operation on each level of the mipmap chain. As you can see in the image below, this can retain details that would otherwise be lost. In the shots below I am zooming out of the texture so you can see the lower-resolution mipmaps.

 

Here is the image without sharpening:

blogentry-1-0-79119000-1399674948_thumb.png

 

And with:

blogentry-1-0-85054200-1399674956_thumb.png

 

These additions can be gotten first by opting into the beta branch on Steam. Once a stable build is reached, a full update will be performed on the standalone build and on the default branch on Steam.

  • Upvote 15
 Share

7 Comments


Recommended Comments

DXT5nm typically also clears out the R and B channels of the texture and reconstructs the Z component of the normal in the shader from the X and Y (A and G) components.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...