Objects with opacity maps are becoming gray when they are far away from camera!

Example

In this example we will be using a flat leaf model textured with a PNG diffuse map which contains alpha channel, and a black and white opacity map.

 

The objects which are close to the camera appear with small outlines:

 

close.jpg

 

After moving the objects farther away from the camera, the material becomes brighter, or washed out:

 

away.jpg

 

Explanation

Although this issue might suggest some problems with the opacity map, it is actually related to the diffuse map. If you are using a bitmap which contains alpha channel information (.png, .tif,...) in diffuse slot, filtering will slightly blur its borders so that the Corona material's solid diffuse color will be visible. Diffuse color is set to gray by default, and this is the reason why in most cases the textures become washed-out or brighter than expected.

Note: this issue is not Corona-related, the same problem would occur in any other renderer.

 

This is what the diffuse texture map looks like in a graphics viewer. Note the transparent background:

 

viewer.jpg

 

The effect is barely visible in the material editor if diffuse color is set to default 128 gray:

 

gray.jpg

 

However, after changing the color to red, it becomes more obvious:

 

bg.jpg

 

And after disabling transparency for the material, you can see that the solid diffuse color is used in alpha-mapped areas of the texture:

 

opaque.jpg

 

Solution

To fix this behavior:

Either:

  • If the diffuse bitmap contains alpha channel, set the material's diffuse color to correspond to the texture (example: green if it's a leaf texture)

Or:

  • If the diffuse bitmap does not contain alpha channel, edit it and paint its "background" (the area which is transparent in this picture) with the color corresponding to the main texture

 

Wrong diffuse bitmap:

 

Leaf_4_Wrong.jpg

 

Corrected diffuse bitmap:

 

Leaf_4_Right.jpg

[ textures by Ludvík Koutný - feel free to download and use them in commercial projects ]

 

Fixed material seen from a distance (compare with the example at the top of the page):

 

fixed.jpg

 

There are other solutions, but they are not guaranteed to work, and may produce unwanted results like flickering or aliasing, especially in animations:

Note: this will disable filtering for ALL textures in the scene and thus may cause significant amount of artifacts in the rendering (flickering, aliasing, jagged edges...)

 

Related forum thread: https://corona-renderer.com/forum/index.php/topic,9130.msg59044/topicseen.html#new

 

Was this article helpful?
0 out of 0 found this helpful