diff --git a/import_textures.md b/import_textures.md index a01cba5..348e6dd 100644 --- a/import_textures.md +++ b/import_textures.md @@ -1,4 +1,106 @@ -| Uncompressed | Compress Lossless (PNG) | Compress Lossy (WebP) | Compress VRAM | +# Importing Textures + +### Do NOT to import them in most cases. + +In most cases you **don't** want images imported when dealing with 2D and GUI. Just copy them to the filesystem. Read the tutorial on [exporting textures](export_textures) before continuing! +For 3D, textures are always imported by the 3D scene importer. The flags and options are the same as here, so reading the rest of the document might help too. + +### OK you _might_ want to import them. + +So, if you have read the previous tutorial on the texture exporter, the texture importer gives you more finer grained control on how textures are imported. If you want to change flags such as repeat, filter, mip-maps, fix edges, etc _**PER texture**_, importing them is the best way to accomplish this (since you can't save such flags in a standard image file). + +### Lack of MipMaps + +Images in 3D hardware are scaled with a (bi)linear filter, but this method has limitations. When images are shrunk too much, two problems arise: +* __Aliasing__: Pixels are skipped too much, and the image shows discontinuities. This decrases quality. +* __Cache Misses__: Pixels being read are too far apart, so texture cache reads a lot more data than it should. This decreases performance. + +(Todo, find image sample of why it looks bad) + +To solve this, mipmaps are created. Mipmaps are versions of the image shrunk by half in both axis, recursively, until the image is 1 pixel of size. When the 3D hardware needs to shrink the image, it finds the largest mipmap it can scale from, and scales from there. This improves performance and image quality. +
+Godot automatically creates mipmaps upon load for standard image files. This process is time consuming (although not much) and makes load times a little worse. Pre-importing the textures allows the automatic generation of mipmaps.
+
+### Unwanted MipMaps
+
+Remember the previous point about mipmaps? Yes, they are cool, but mobile GPUs only support them if the textures are in power of 2 dimensions (ie 256x256 or 512x128). In these platforms, Godot will stretch and enlarge the texture to the closest power of 2 size and then generate the mipmaps. This process takes more of a performance hit and it might degrade the quality a little more.
+
+Because of this, there are some scenarios when it may be desirable to not use them, and just use a linear filter. One of them is when working with graphical user interfaces (GUIs). Usually they are made of large images and don't stretch much. Even if the screen resolution is in a larger or smaller value than original art, the amount of stretch is not as much and the art can retain the quality. Pre-importing the textures also allows the disabling of mipmap generation.
+
+### Blending Artifacts
+
+The [blending equation](http://en.wikipedia.org/wiki/Alpha_compositing) used by applications like Photoshop is too complex for real-time. There are better approximations such as [pre-multiplied alpha](http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx?Redirected=true), but they impose more stress in the asset pipeline. In the end, we are left with textures that have artifacts in the edges, because apps such as Photoshop store white pixels in completely transparent areas. Such white pixels end up showing thanks to the texture filter.
+
+Godot has an option to fix the edges of the image (by painting invisible pixels the same color as the visible neighbours):
+
+






Large |
Small |
Very Small |
Small |
@@ -6,3 +108,39 @@
| Performance |
Normal |
Normal |
Normal |
Fast |
| Quality Loss |
None |
None |
Slight |
Moderate |
| Load Time |
Normal |
Slow |
Slow |
Fast |
+
+
+### Texture Options:
+
+Provided are a small amount of options for fine grained import control:
+
+#### Streaming Format
+
+This does nothing as of yet, but a texture format for streaming different mipmap levels is planned. Big engines have support for this.
+
+#### Fix Border Alpha
+
+This will fix texture borders to avoid the white auras created by white invisible pixels (see the rant above).
+
+#### Alpha Bit Hint
+
+Godot auto-detects if the texture needs alpha bit support for transparency (instead of full range), which is useful for compressed formats such as BC. This forces alpha to be 0 or 1.
+
+#### Compress Extra
+
+Some VRAM compressions have alternate formats that compress more at the expense of quality (PVRTC2 for example). If this is ticked, texture will be smaller but look worse.
+
+#### No MipMaps
+
+Force imported texture to NOT use mipmaps. This may be desirable in some cases for 2D (as explained in the rant above), though it's NEVER desirable for 3D.
+
+#### Repeat
+
+Texture will repeat when UV coordinates go beyond 1 and below 0. This is often desirable in 3D, but may generate artifacts in 2D.
+
+#### Filter
+
+Enables linear filtering when a texture texel is larger than a screen pixel. This is usually turned on, unless it's required for artistic purposes (minecraft look, for example).
+
+
+ --- //[Juan Linietsky](reduzio@gmail.com) 2013/11/10 18:11//