Jump to content

MipMaps levels in non-dds textrures


photo

Recommended Posts

Is it possible to use mip-maps with .PNG/.JPG/.TGA textures? For example, I got 512x512 texture that weights about 44kb in .PNG format and converting it to DXT1-DXT5 ruins the quality while RGBA8 texture with mipmaps weights about 1.4Mb..

Link to comment

Is it possible to use mip-maps with .PNG/.JPG/.TGA textures? For example, I got 512x512 texture that weights about 44kb in .PNG format and converting it to DXT1-DXT5 ruins the quality while RGBA8 texture with mipmaps weights about 1.4Mb..

 

Yes, it's possible. But time of png decompression will produce stalls in render.

There is another solution: DDS file in rgba8 format with mipmaps.

 

Unigine editor and imagedds.py support following postfixes for automatic texture conversion:

 

"d" : FORMAT_DIFFUSE,

"dr" : FORMAT_DIFFUSE_RAW,

"d1" : FORMAT_DIFFUSE_DXT1,

"d3" : FORMAT_DIFFUSE_DXT3,

"d5" : FORMAT_DIFFUSE_DXT5,

"s" : FORMAT_SPECULAR,

"sr" : FORMAT_SPECULAR_RAW,

"s1" : FORMAT_SPECULAR_DXT1,

"s3" : FORMAT_SPECULAR_DXT3,

"s5" : FORMAT_SPECULAR_DXT5,

"n" : FORMAT_NORMAL,

"nr" : FORMAT_NORMAL_RAW,

"p" : FORMAT_PARALLAX,

"pr" : FORMAT_PARALLAX_RAW,

"h" : FORMAT_HEIGHT,

"hr" : FORMAT_HEIGHT_RAW,

"t" : FORMAT_TESSELLATION,

"tr" : FORMAT_TESSELLATION_RAW,

"a" : FORMAT_AMBIENT,

"ar" : FORMAT_AMBIENT_RAW,

"e" : FORMAT_EMISSION,

"er" : FORMAT_EMISSION_RAW,

"l" : FORMAT_LIGHTMAP,

"lr" : FORMAT_LIGHTMAP_RAW,

 

RAW format is an unmodified format of source image.

Link to comment

You said it is possible, but how?

In Image.cpp/load_png() I see only calls to create2D(...,...,...,1,0) meaning that only one mipmap is loaded from PNG image. Do you mean that mip-maps could be created on scripts side by using Image class? That not sounds as a solution for me.. It would be even better to re-compress PNGs to RGBA8 DDS in installer or on the first run.

Link to comment

You said it is possible, but how?

In Image.cpp/load_png() I see only calls to create2D(...,...,...,1,0) meaning that only one mipmap is loaded from PNG image. Do you mean that mip-maps could be created on scripts side by using Image class? That not sounds as a solution for me.. It would be even better to re-compress PNGs to RGBA8 DDS in installer or on the first run.

 

source/engine/render/RenderManager.cpp 410 line:

if(image.getNumMipmaps() == 1 && (flags & (Texture::FILTER_BILINEAR | Texture::FILTER_TRILINEAR))) {

flags = (flags & ~Texture::FILTER_MASK) | Texture::FILTER_LINEAR;

}

 

Mipmaps will be generated automatically by texture class if you comment this code.

Link to comment
×
×
  • Create New...