Transparency2Pass

Synopsis

Three macros that demonstrate the effects of transparency within AVS/Express and how acceptable image quality and performance can be achieved.

Input Ports

Name Type Description

in_fld Field Data that should be displayed.
transparency float Amount of transparency to use.

Output Ports

Name Type Description

out_obj GDobject Directly renderable object output.

Description

The rendering of transparent objects can be useful in a number of visualization situations. For instance within a medical visualization it can be very useful to have the surface of the body visible as a transparent object. This can help give context to the rest of the visualization. However due to the way that AVS/Express currently deals with transparent polygons the use of this technique is limited to very simple situations. This project provides a simple technique for rendering transparent objects which overcomes this limitation.

The underlying 3D graphics system that Express uses represents the results of a visualization as a large number of triangles. To generate the image that is seen on screen these triangles are rendered in the order that they were generated. Rendering a triangle involves transforming it from the 3D space of the visualization to the 2D space of the computer screen and then determining if it overlaps any existing triangles. If it does then the graphics system determines if the triangle is in front of or behind the existing triangle. If the triangle does not overlap or if it is in front the triangle is rendered, overwriting what was behind it. If it is behind then it is discarded.

The important things to take from this discussion is that triangles can be rendered in any arbitrary order and that depth sorting is done as the image is rendered. If we consider the case of transparent triangles the situation becomes rather more complex. When a transparent triangle is rendered the colour of the triangle is blended with whatever is behind it to give the illusion that the triangle is partially transparent. This works correctly if the background has already been rendered. However it is possible for the background to be rendered after the foreground. In this case the depth sorting discards the background triangle and does not change the image. This can lead to artifacts in the image where it is possible to see through some triangles but not through others. By default Express suffers from this problem. This can be seen in the Transparency1Pass macro.

To solve this problem we would ideally like to sort the triangles by how far they are from the viewer/camera and then render the most distant triangles first. This is the method normally used when the quality of transparency is vital to the application. Unfortunately implementing this would require changing the core of Express, which is not possible. The Transparency2Pass macro provides an alternative to full depth sorting which does not require internal alterations to Express.

If we consider a simple convex object such as a sphere or a cube we can see that all the nearest surfaces face towards the viewer and all the farthest surfaces face away from the viewer. Express does provide a way to render only those surfaces facing towards or away from the viewer. Originally this was intended as a simple way of reducing the number or triangles that had to be processed. However it can be used as a simple form of depth sorting by making two passes over the object. For a convex object if we first render all the triangles facing away from the viewer and then render all the triangles facing towards the viewer we can be sure that all the background triangles have been drawn first. This is what the Transparency2Pass macro does.

This technique does have 2 major limitations. For more complex concave objects the quality of the results obtained are variable. In a concave object there can be several obscuring surfaces. Hence we cannot state that all surfaces that face towards the viewer are nearer than all surfaces that away from the viewer. Therefore this simple form of depth sorting will not work. However in practical situations we find that many concave objects do appear correct when rendered using this technique. The image quality is certainly much higher then it is when no depth sorting is performed. The TransparencyEg application illustrates this by rendering a transparent teapot object.

The second major limitation is that this technique does not deal with multiple transparent objects. AVS/Express does always render non-transparent objects before transparent objects. Hence non-transparent objects will always be visible through transparent objects. However the order in which transparent objects are rendered is important. In some situations it is possible to know which order objects should be rendered in. For instance if one object is completely enclosed by another the inner object should be rendered first. This is shown in the TransparencyOrderingEg example application. However in general it does not appear to be possible to sort transparent objects with making changes to the core of AVS/Express.

User Macros

Three user macros are provided with this project:

Input Ports

in_fld

Field data that should be be rendered as a transparent object. The input data can be any standard field data.

transparency

Amount of transparency that should be applied to the object. A value of 0 implies that the object should be completely transparent and a value of 1 implies that the object should be completely opaque.

Output Ports

out_obj

Directly renderable output object that can be displayed in a 3D viewer. In the Transparency1Pass macro this output is a link to a single DataObject. In the other 2 pass macros this output is a link to a GroupObject that contains a back DataObject and a front DataObject.

Utility Macros

Two utility macros are provided that generate user interfaces for the TransparencyEg and TransparencyOrderingEg example applications.

Files

iac_proj/t_2_pass/t_2pmacs.v contains the V definitions of the TransparencyEgUI and TransparencyOrderingEgUI user interface macros, and the Transparency1Pass, Transparency2Pass and ReverseTransparency2Pass user macros.

iac_proj/t_2_pass/t_2papps.v contains the V definitions of the TransparencyEg and TransparencyOrderingEg example applications.

Example

Two example applications are provided with this project. The TransparencyEg application demonstrates the use of the 3 user macros and the difference between each rendering technique. It does this by loading and rendering a transparent teapot. The TransparencyOrderingEg demonstrates the effect of changing the order of 2 transparent objects.

Other Notes

This project does not contain any procedural code and hence does not require compiling.

Author

Ian Curington, AVS Inc.

Modifications

Andrew Dodd, IAC

Contact

International AVS Centre
Manchester Visualization Centre
Manchester Computing
University of Manchester
Oxford Road
Manchester
United Kingdom
M13 9PL