When rendering with alpha the final image is a blending of two or more objects. Depending on the combination of alpha objects and their placement, issues can arise with the final blended image.

A common problem of transparent rendering is having objects disappear behind transparent objects. This usually occurs when transparent objects intersect or when a single transparent object contains layers of polygons that appear behind one another. Since transparent objects are sorted at the mesh level, individual polygons within the mesh might not be rendered in the correct order.

One workaround is to break up the transparent objects into smaller individual objects within your 3D modeling tool. This gives the rendering engine more fine-grained control with the order in which transparent objects are rendered.

Breaking up the objects can work to an extent, but for complex self-intersecting meshes (e.g., vegetation models) this solution is not very practical or efficient. Another workaround is to use alpha-to-coverage, which is supported by most modern graphics cards. Instead of blending each pixel with the scene behind it, alpha-to-coverage uses the alpha value to automatically create a screen-door transparency effect. In order to use the alpha-to-coverage feature, multi-sampling must be enabled (i.e., viz.setMultiSample). This feature can be enabled by simply using the viz.SAMPLE_ALPHA_TO_COVERAGE flag with the node3D.enable command. It is also suggested to disable blending when using alpha-to-coverage:

viz.setMultiSample(8)
viz.go()

model = viz.addChild(‘model.osgb’)
model.enable(viz.SAMPLE_ALPHA_TO_COVERAGE)
model.disable(viz.BLEND)

The image below demonstrates the effect of using alpha-to-coverage. In the left half of the image you can clearly see missing pixels in the vegetation. After enabling alpha-to-coverage, all the pixels are properly rendered, as seen in the right half:

 

 

 

 

 

 

 

Visit the WorldViz Knowledge Base for our collection of articles, scripts, and tutorials that make our products work better for you.

You can also visit the Vizard Users Guide for additional information and assistance.