Jump to content

[SOLVED] Alpha channel problem


photo

Recommended Posts

Hello! I have some problems with alpha channel. There is a cube in my test scene, and i need to set gradient texture with alpha channel. If i use "alpha test" option, I see both side of cube with alpha channel, as I need, but gradient is not displayed. (alpha_test.PNG) . If i disable "alpha test" and use blending (src: src alpha dest: one minus src alpha) , there is a gradient with alpha, but material work incorrectly again, back side of cube partially invisible, and material becoming partially translucent, also I can see edges of cube. (alpha_gradient.PNG).

What settings I need to use to achieve the desired result ?

post-668-0-78713800-1346675163_thumb.png

post-668-0-44311300-1346675184_thumb.png

Link to comment

Alpha testing just skips texels below specific alpha threshold, but colors visible pixel based on RGB texel value only (so no A-blending). So for achieving a transparency effect you have to use alpha blending as you already did.

 

The problem is that individual cube planes have to be rendered in depth-first order (relative to view point) for correct blending results which is not happening as you render only one cube mesh with one single surface (the engine does not sort individual triangles of a surface, but renderes all triangles in their defined order).

 

You should therefore try to build your cube by 6 individual (rotated) plane meshes or maybe one mesh with 6 individual surfaces each with the same material assigned, so the engine can sort the individual cube faces correctly by their depth.

Link to comment

I divided cube in 3ds max for individual faces and imported into the engine. Facets are visible from all directions, but against the background of sky boundaries of the cube are visible (if post deferred enabled, if disabled faces are transparent), also drop shadow is incorrect (alpha_blending_separate_surfaces.PNG). Solution with separate faces can be used with cubic objects, but what about the complex curved shapes, such as clothing or characters hair? When I tried to use blending to make torn clothing for character, model became transparent.

I tried different options, enable of alpha test+blending and post deferred yielded acceptable results (and it work with single surface of cube), but the shadows in this variant are displayed from 1 bit alpha channel, without gradient, and only on 3 sides of cube gradient are visible. (alpha_blending+alphatest.PNG)

post-668-0-49815700-1346742574_thumb.png

post-668-0-23141800-1346743141_thumb.png

Link to comment

Now I have enabled HDR and from normal result (alpha test + blending) nothing left, so my solution is not suitable in any case

 

At the moment correctly works with HDR only 1 bit alpha channel in alpha test mode.

post-668-0-40307600-1346744060_thumb.png

Link to comment

Now I tested alpha channel on the curved surface, the situation with the disappearance of the back side remained the same. Accompanying screenshots shows the settings and bug with displaying back side of surface.

post-668-0-53780800-1346754103_thumb.png

post-668-0-31457200-1346754123_thumb.png

Link to comment

Strange, I use same model with same material on night scene, and model become transparent. And there is no textures on models, that visible through transparent model.

post-668-0-15015300-1346757964_thumb.png

Link to comment
  • 2 weeks later...

Andrey,

 

For the cube you can use a mesh with 2 identical surfaces:

  • The first to be rendered with alpha blending for soft edges. This surfaces should not cast shadows. (BTW, try unchecking Depth mask option for correct sky color behind the cube).
  • The second one with alpha testing is made invisible and only used for casting a shadow.

BTW, there's no problem with HDR no matter if alpha blending or testing option is chosen for a material.

 

 

post-13-0-30112700-1347532380_thumb.jpg

 

As for the carpet, it's a depth sorting issue. As Ulf recommended, you need to divide your mesh into multiple surfaces so that the engine can sort them in a proper order. (You can also uncheck Depth mask, but this solution is not as good as the first one).

Link to comment
×
×
  • Create New...