O'Reilly logo

PNG: The Definitive Guide by Greg Roelofs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Applications: VRML Browsers and Other 3D Apps

VRML, the Virtual Reality Modeling Language, is a file format and a language for defining three-dimensional virtual objects, their appearances and their behaviors. As of early 1999, it has seen two major versions, and the design of a third is currently underway. Version 1.0 included little more than static geometry and never saw wide use. Version 2.0, released in August 1996 and approved as an ISO/IEC international standard in December 1997, added animation, scripting, and a much more rigorous specification of all aspects of the format. It also mandated PNG as one of two image formats required for minimal conformance. (JPEG was the other.) No doubt due to PNG's rampant popularity, [39] VRML 2.0--or VRML97, as the ISO standard is known--achieved dramatically greater recognition and acceptance than VRML 1.0, with shipments of VRML97 browsers reaching levels of between 25 million and 75 million units by the autumn of 1998.

How is PNG actually used in a 3D, text-based file format? A complete answer would require considerable discussion of 3D rendering engines, CPU and memory performance, Moore's Law, and so forth. But in a nutshell, VRML is designed for interactive 3D--particularly Web-based, immersive, interactive 3D. A truly realistic animated object, such as the dinosaurs in the movie “Jurassic Park” or the flying cow in “Twister,” would require far more computational power to render in “real time” at reasonable frame rates (say, more than 15 frames per second) than even today's fastest processors can manage. And that's just one object; imagine every rock, tree, bug, cloud, and blade of grass rendered at the same level of realism, responding to dynamic effects like wind, sunlight, and other moving objects. Doing all of that is likely to remain out of reach of typical personal computers for a decade or more.

As a result, VRML is all about trickery, and one of the most efficient forms of 3D trickery is known as texture-mapping. Instead of creating a highly detailed 3D object out of many tiny polygons, it is often possible to create a very realistic approximation of it out of just a few polygons, with an appropriate image (or texture) drawn over them. Anyone who has studied a 3D game like Quake or Descent is probably familiar with the concept; the buildings and even the characters are actually quite crude, but with stone or metal textures and lighting effects applied, the world suddenly becomes a realistically gloomy dungeon or sewer system or a bright and shiny high-tech laboratory.[40]

PNG's role in this is as a format for the textures. VRML references PNG images in much the same way that HTML pages do, via a URL that points at the PNG file. A VRML viewer then fetches the PNG image, applies it to the polygons of the relevant object according to the rules in the VRML specification, and displays the result within the 3D scene.

Because both raw VRML objects and PNG textures support not only colors but also transparency and partial transparency (loosely, “translucency”), a number of interesting effects are possible. On the other hand, the potential number of interactions and combinations is immense, so the VRML97 spec defines some basic rules regarding VRML materials and how textures modify them:

  • A one-component texture--i.e., grayscale--absorbs and modulates the underlying polygon's color and transparency. For example, an opaque yellow triangle with a gray, gradient texture applied to it will turn into an opaque triangle with a yellow gradient. The orientation of the gradient depends on how the author specified the coordinates of the texture.
  • A two-component texture (grayscale plus an alpha channel) absorbs the underlying polygon's color, but any transparency in the base polygon is replaced by the transparency of the texture.
  • A three-component texture (RGB color) replaces the underlying polygon's color but inherits its transparency (if any); a blue texture applied to a red polygon with 50% transparency turn its into a 50% transparent blue polygon.
  • A four-component texture (RGB plus an alpha channel, or RGBA) completely overrides the color and transparency of the underlying polygon.

What about palette-based images? If every color in the palette is pure gray (that is, if the values for red, green, and blue are equal for each entry), then the image is treated as grayscale. If even one palette entry is not gray, the image is treated as RGB color. And if the image includes a transparency chunk (more on that in

Chapter 8, “PNG Basics”), it is treated as though it has a full alpha channel.[41]

These rules are worth keeping in mind because, alas, full support for PNG in VRML browsers is Not Quite There Yet. Just as there are two main web browsers, prior to August 1998 there were just three main VRML browsers: Cosmo Player, WorldView, and blaxxun CC3D.

[42] Although PNG support in each of them was better than that in either of the Big Two web browsers, VRML applications are necessarily subject to quite a few more variables: different rendering engines, a myriad of third-party hardware and even more versions of device drivers, various browser performance options, and, of course, the list presented earlier of ways in which a PNG texture can interact with the objects to which it is applied. And texture support is just one small part of a VRML browser! In other words, because so many things can go wrong, quite a few things do go wrong...at least in some situations.

Despite that somewhat bleak disclaimer, PNG support in older VRML browsers has improved with each new release, and several new browsers are under development as this is being written. Most of the major ones are listed in the following sections, with known problems indicated. Unless otherwise noted, all are plug-ins to web browsers, which they typically use not only to enable the downloading of files over the Web but also to provide support for Java, and JavaScript (the standardized variant of which is known ECMAscript).

6.1. Cosmo Player

Cosmo Player, at least the completely rewritten 2.x version, was designed with conformance and rendering accuracy as the primary goals and performance second. Currently, the latest release is version 2.1, only available for Windows 9x/NT. (An early beta is available for the PowerMac, but it is reported to be somewhat unstable; a more mature beta is available for IRIX 6.5.) With Nice Transparency turned off, Cosmo's PNG support is exemplary--aside from the fact that all partial transparency is achieved by dithering fully transparent and fully opaque pixels, an approach known as screendoor transparency or stippled alpha, which is great for performance but cannot be considered true alpha support. With Nice Transparency turned on, and regardless of whether the rendering engine is OpenGL software, OpenGL hardware, or Direct3D hardware, Cosmo 2.x displays an odd “popping” behavior with respect to opaque textures on translucent materials. That is, from some viewing angles, the textures will be translucent, as they are supposed to be; but from other angles, they will be completely opaque. In addition, gray textures with transparency sometimes also inherit the underlying material's transparency.

On the SGI/IRIX platform, Cosmo Player 1.0.3 is the latest official release as of March 1999.

[43] Like the PC version, it has a Nice Transparency mode that incorrectly allows two-component textures (grayscale with transparency) to absorb material transparency. In addition, if two polygons with partly transparent textures intersect, it can render parts of the polygons that should be opaque as transparent instead. This latter problem can be avoided by designing the VRML world without intersecting polygons (which are often a performance problem anyway).

Further information about the Windows and Macintosh versions of Cosmo Player is available from http://www.cosmosoftware.com/products/player/brief.html. The web page for the IRIX version is at http://www.sgi.com/software/cosmo/player.html.

6.2. WorldView/MSVRML

WorldView is available not only as an Internet Explorer and Navigator plug-in from Intervista, but also as a slightly modified Internet Explorer component from Microsoft. The latter is known as Microsoft's MSVRML browser, and up through the June 1998 end-user release of Windows 98, it corresponded to WorldView 2.0. Subsequent versions of Win98, at least on some new PCs, and Internet Explorer 5.0 included a VRML browser corresponding to WorldView 2.1, which was Intervista's final release.[44] (Intervista never released version 2.1 as a Navigator plug-in version, however, for either Windows or PowerMac.)

Unlike Cosmo Software's approach, Intervista's design philosophy for WorldView appears to have emphasized performance, particularly hardware-assisted performance. This is not necessarily a bad thing--with Direct3D acceleration under Windows 95, WorldView was usually faster than Cosmo Player in my tests, sometimes much faster--but it does mean that some design decisions adversely affect PNG rendering. For example, WorldView apparently does not support texture sizes greater than 256 x 256 pixels; instead, it automatically scales down large images. It also supports screendoor transparency rather than true alpha blending (similar to Cosmo Player's behavior with Nice Transparency disabled), and it defaults to a palette-like, limited-color rendering mode, although this can be overridden by choosing Full Color graphics mode from the Options pop-up.

Beyond the intentional limitations in PNG support, WorldView suffers from some transparency bugs similar to Cosmo's. For example, grayscale PNGs with transparency also inherit the underlying material's transparency, just as in Cosmo Player 1.x for IRIX. Opaque textures, on the other hand, fail to absorb the underlying material transparency.

In addition, WorldView with hardware acceleration enabled is at the mercy of the user's graphics hardware, the quality of the video drivers supplied with the hardware, and Microsoft's DirectX (of which at least three major versions are available). Observed hardware-specific bugs include a lack of support for material transparency (3Dfx Voodoo Rush-based card) and a lack of support for material or texture transparency or for non-palette-based textures (ATI Rage Pro card). Many of these problems are likely to disappear as hardware manufacturers release more mature versions of their video drivers, but some of the limitations may simply be due to an overly aggressive use of DirectX in WorldView itself.

Note that the older WorldView 2.0 also had problems with so-called “RGBA-palette” PNGs, and with hardware acceleration enabled under Windows, it failed to display RGBA PNG textures at all (observed on a Rendition Vérité-based card).

WorldView is currently still available from http://www.intervista.com/worldview/, but as with cosmosoftware.com, the site may disappear when Computer Associates completes its acquisition of Platinum.

6.3. blaxxun Contact

blaxxun's Contact browser (the unified, version 4.0 name for the older CC3D and CCpro browsers) is available only for the Windows 9x/NT platform and is optimized primarily for performance, like WorldView. Unlike WorldView, however, CC3D also comes in an OpenGL version, and both that and the Direct3D version can support full alpha blending of PNG textures, at least in some modes. The Direct3D modes that support only screendoor transparency also support only 8-bit, palette-based rendering, however.

Because the selection of PC video cards with good, hardware-assisted OpenGL support was still fairly sparse in 1998, only the Direct3D version of Contact 4.002 was tested. It did not support transparency in RGBA-palette PNGs at all, regardless of the material transparency, and gray palette-based PNG textures with transparency failed to inherit the underlying material color. On the other hand, palette and grayscale textures with binary (or single-shade) transparency additionally inherited the underlying material transparency. Implementation problems were also probably to blame for the incorrect rendering of overlapping transparent textures.

Unlike older versions of the browser, which failed to render large textures at all, Contact 4.0 appeared to resample them to smaller sizes if the hardware had insufficient texture memory. In High Quality software-rendering mode, the newer release appeared not to have any size limitations--indeed, its rendering of large, opaque textures was distinctly better than that of Cosmo Player, which is otherwise considered to have a very high quality renderer. On the other hand, transparent textures reverted to stippled transparency in this mode. Contact 4.0 is available for download from http://www.blaxxun.com/products/contact/.

6.4. Viscape Universal

Superscape has been in the 3D business since before VRML existed, but the release of Viscape Universal 5.60 late in 1998 was its first nonbeta attempt at a VRML97 browser. As with Cosmo Player and CCpro, it supports both OpenGL and Direct3D rendering engines.

Version 5.60 comes reasonably close to achieving Superscape's claims of “full VRML97 compliance,” at least with regard to textures. Alpha transparency is supported, but single-shade PNG transparency in grayscale or RGB textures is not, and palette-alpha PNGs are rendered mostly opaque. Material transparency has varying effects: with the OpenGL renderer, all textures are composed with the underlying transparency; with Direct3D, none of them are. Both behaviors are incorrect. Grayscale textures also fail to absorb the underlying material's color.

On a more amusing note, Viscape Universal has no support for GIF textures--which is allowed by the VRML specification--but it fails to render the underlying material correctly in the absence of the textures. The browser may be downloaded from http://www.superscape.com/download/ViscapeUniversal/.

6.5. LibVRML97/Lookat

LibVRML97 is Chris Morley's free VRML97 library, written in C++; Lookat is a simple browser based on the library. As of version 0.7.9, the library was known to compile under Linux, Solaris, and Windows 95; it should be portable to most platforms with a reasonably up-to-date C++ compiler. The Lookat sample browser (and its Motif- and GTK-based variants, xmLookat and gtkLookat) was originally specific to Unix and the X Window System, but a 32-bit Windows port was progressing quite rapidly as of January 1999.

Earlier versions had various minor texture problems, but version 0.7.9 earned a distinction shared by no other VRML browser: perfect texture-rendering compliance with the VRML97 specification for all combinations of texture types and material properties, as far as our tests can determine. The browser may have other limitations, but its PNG support is without parallel. [45]

LibVRML97 is freely available as C++ source code from http://www.vermontel.net/~cmorley/vrml.html under a BSD-like license. The Motif and GTK front ends are available under the GNU General Public License.

6.6. FreeWRL

Another Open Source VRML97 browser is Tuomas Lukka's FreeWRL, a Perl-based effort that uses OpenGL for 3D rendering and FreeType for font support. As such, it is one of the few VRML97 browsers that runs under Linux, but because of its dependence on a host of secondary Perl packages and external libraries,[46] it is not for the meek. Version 0.13 supported PNG, but just barely: only on primitive shapes (Box, Cylinder, and Sphere, not IndexedFaceSet, Extrusion, or ElevationGrid nodes), and in a test world with both PNGs and JPEGs, the two JPEG textures appeared to be used on every textured surface, replacing all of the PNG textures. It also did not support material transparency, had problems with nonconvex, textured polygons, and, as a script-based browser, was rather slow.

Version 0.17 was Tuomas's final release (December 1998); as of January 1999, John Stewart was the maintainer, and the new web site was http://debra.dgbt.crc.ca/~luigi/FreeWRL/. Version 0.19 was the current release as of early April 1999.

6.7. VRMLView

VRMLView, from the Norwegian company Systems in Motion, is available for Windows 9x/NT, IRIX, Linux/Intel, and BeOS, with an HP-UX port underway. As of early 1999, two betas of version 2.0 had been released: “2.0b1” in January 1998 and “2.0beta1” in August, available for Linux, Windows, and BeOS. The first had a fatal PNG bug, but support in the second was reasonably good and included full alpha blending.

Nevertheless, VRMLView 2.0beta1 had several problems with PNG textures, many similar to those seen in other browsers. Among them were the following:

  • Gray palette-based textures do not inherit underlying material colors.
  • Gray PNGs with transparency also inherit underlying material transparency.
  • Gray non-palette-based PNG textures with transparency are rendered opaque.
  • Opaque palette-based and RGB textures on partially transparent materials are rendered completely transparent.
  • In some places, background polygons are rendered on top of foreground polygons.

The VRMLView 2.0 beta shipped with all texture support turned off, but textures could be enabled by selecting the Textures item in the View menu. Subsequently, textures were enabled from the outset. Also note that the Linux version required the 3.0 beta version of the Mesa OpenGL clone (subsequently released), which was not immediately obvious from the README file. Finally, keep in mind that the browser still lacked support for some basic VRML nodes, such as Background and Anchor. VRMLView's web page is at http://www.sim.no/vrmlview.html.

6.8. Other VRML Browsers

Other VRML97 browsers that included some level of PNG support were Dimension X's Liquid Reality, Netscape's Live3D, and Newfire's Torch. Dimension X was acquired by Microsoft in 1997, and its 3D technology was absorbed into the Liquid Motion animation tool. The Java-based Liquid Reality browser itself was discontinued, but since its PNG support was fairly buggy and usually crashed the browser (under both Solaris and Windows 95), it was never a truly usable PNG-supporting VRML browser.

Netscape's Live3D browser, based on a VRML 1.0 browser (WebFX) acquired from Paper Software, had good PNG support, aside from reversing all red and blue color values and supporting only screendoor transparency. The rights to version 2.0 were acquired by SGI early in 1997, and it was renamed and released as Cosmo Player 1.0 for the PC. With the Cosmo Player 2.0 rewrite, most traces of Live3D vanished, although it was still bundled with Netscape Communicator versions up through 4.04.

Newfire's Torch browser was a special-purpose, games-oriented VRML engine. It was designed purely for speed and interactive performance, but it nevertheless supported PNG, including a dithered form of screendoor transparency that looked better than the usual flavor. Aside from using an 8-bit color model regardless of display depth, its only known bug was a failure to compose grayscale textures with the underlying material color. Unfortunately, it disappeared when Newfire went bankrupt early in 1998.

In addition to the dead PNG-supporting browsers (let us hope there's no connection to PNG support there!), two other VRML97 browsers were still under active development in 1998: Sony's Community Place 2.0 (http://www.community-place.com/) and VRwave 0.9 (http://www.iicm.edu/vrwave/) from the Graz (Austria) University of Technology. Neither supported PNG as of early 1999, but PNG support was promised for both in upcoming releases.

6.9. Other 3D Applications

Quite a few other 3D applications support PNG, too. These range from VRML editors and high-end modeling programs to artificial terrain generators and font-extrusion utilities. In the next few pages, I list a number of these applications, together with the version number of the latest release and the current web site as of this writing.

3D Studio MAX

Version R2.5, Kinetix/Autodesk. Available for 32-bit Windows; read/write support for PNGs. This is the reference software for high-end 3D modeling, much like Adobe Photoshop is the reference for high-end image editing; release 2.0 (and later) supports export of VRML 2.0.



Cosmo Worlds

Version 1.1 (IRIX) and 2.0 (Win32), SGI Cosmo Software, Platinum Technology, Computer Associates, and/or Web3D Consortium. Available for SGI IRIX and 32-bit Windows; read/write support for PNGs; full alpha support. This was Cosmo's flagship VRML 2.0 editing program. SGI retained the rights to the IRIX version; as of early April 1999, the fate of the Windows version was up in the air. Platinum's plans to release it to the Web3D Consortium (as open source code, free for noncommercial use) may go forward, or it may remain proprietary software under Computer Associates' control.





Version 2.0, Macromedia. Available for 32-bit Windows and Mac PPC; read/write support for PNGs as textures and backgrounds; write-only support for PNGs as output format for rendered scenes, including interlacing and (32-bit) alpha support. This is a 3D modeling and animation tool.


Font F/X

Version 2.0, DCSi/Electric Rain. Available for 32-bit Windows; write-only support for PNGs. This is a 3D font-rendering program.



Version 1.3a, John Beale. Available for Unix and DOS; write-only support for PNGs. This is a terrain generator that uses “random fractal forgery” to produce realistic mathematical representations of hills, mountains, and craters; its output must be fed into the POV-Ray ray tracer for rendering. The included Tcl/Tk interface is called Xforge.


LightWave 3D

Version 5.6, NewTek. Available for 32-bit Windows, Mac PPC, IRIX, and Solaris. Read/write support for PNGs and full (32-bit) alpha support if James G. Jones's PNG loader/saver is installed as a plug-in. This is another 3D modeling and animation tool, with particular emphasis on film and video output.




Version 3.0.2, Wolfram Research. Available for 32-bit Windows, Mac 68k/PPC, and most flavors of Unix; version 2.2.3 is also available for 16-bit Windows, OS/2, and OpenVMS. Read/write support for PNGs, read-only support for 32-bit RGBA, and full 16-bit support if Jens-Peer Kuska's PNGBitmap package is installed. Mathematica is a graphical environment for interactive mathematics and technical computing; the add-on allows it to use PNGs for textures on surfaces and to save rendered output and other graphics elements in PNG format.




Version 2.0, Jens-Peer Kuska. Available for 32-bit Windows, Linux, and Solaris; read/write support for PNGs. This is a standalone, interactive viewer for Mathematica 3D elements; it supports PNGs as textures on input and as an output format for rendered images. It can also produce POV-Ray or VRML 2.0 models with PNG textures.



Nichimen Graphics. Available for 32-bit Windows and Solaris; read/write support for PNGs. This is a 3D modeling and 2D painting application with support for PNGs as textures and VRML 2.0 as both an input and output format. PNG images can be edited in the paint portion of the program.



Version 1.4, WareOnEarth. Available for SGI IRIX; write-only support for PNGs. This is a simple (and free) command-line utility to convert IRIS Performer 3D files into VRML 2.0 format; it will optionally convert the SGI-specific texture formats into PNG and JPEG.



Version 3.1a, Persistence of Vision Development Team. Available for 16- and 32-bit Windows, Unix, Mac 68k/PPC, DOS, and Amiga; read/write support for PNGs; full (32-bit) alpha support; full gamma support; full 16-bit-per-sample support. This is probably the most well known ray-tracing program; its file format has become an unofficial 3D standard.


Rational Reducer

Version 2.2, Systems in Motion. Available for 32-bit Windows, Linux, and SGI IRIX; readonly support for PNGs. This is a polygon-reduction tool for 3D models in VRML 1.0, VRML 2.0, AutoCAD (DXF), and 3D Studio MAX (3DS) formats. It supports PNGs for textures.



Version 4.1, Caligari. Available for 32-bit Windows; read/write support for PNGs. This is a 3D modeling and rendering program with support for radiosity, NURBS, and so on. It supports PNGs for textures and can write VRML 2.0 files.



Version 3.0, Xara. Available for 32-bit Windows; write support for PNGs (may also support reading PNGs as textures); full (32-bit) alpha support. This is a 3D font-rendering program.


One other application is worth mentioning here. VermelGen, an all-Java VRML editor written by Justin Couch and Cameron Gillies, relies on Java's built-in image-handling support for textures. The most recent version of the app, beta 2, was released in mid-1997 when Java did not support PNG. But with native PNG support in the new Java Advanced Imaging API and in Justin's own Java Image Content Handlers (see Chapter 16, “Other Libraries and Concluding Remarks” for both), it is possible that VermelGen will inherit PNG support as well. (Of course, it's also quite possible that some modifications would have to be made in order to work with the updated Java code.) VermelGen is available from http://www.vlc.com.au/VermelGen/; it requires the JVerge VRML classes, available from http://www.vlc.com.au/JVerge/.

As with the other application categories, new VRML browsers and 3D applications with PNG support will be listed on the following two pages at the PNG home site:

As of 2003, the second page lists all known 3D applications with PNG support, including VRML browsers and editors; the first is reserved for detailed test results for various VRML browsers. Note also that the follow-on to the VRML97 specification is an XML-based format called X3D. It includes several profiles of varying complexity, one of which is VRML97-compatible.

[39] Well, in part, anyway...

[40] In the case of characters, animation and sound effects also aid the illusion tremendously.

[41] The transparency chunk rule also applies to true RGB or grayscale PNGs, in which such a chunk indicates that a single color or shade of gray is to be considered fully transparent.

[42] Platinum Technology bought Intervista (maker of WorldView) in June 1998 and most of Cosmo Software (maker of Cosmo Player) in August. In September, they publicly announced their intention to merge the two browsers within a relatively short period, so for a brief period the VRML world appeared to be heading toward an even greater similarity to the world of HTML. Alas, the best-laid plans sometimes go awry; in February 1999, Platinum restructured and, among other things, shed its entire 3D team. As of mid-March, it appeared that Platinum was well on it way to releasing the source code to Cosmo Player under a completely open license (with somewhat more restrictive licenses for other 3D tools, such as WorldView for Developers and Cosmo Worlds). But in yet another unexpected twist, Computer Associates announced in late March that it was acquiring Platinum. As of early April 1999, no one yet knew the fate of any of the WorldView/Cosmo suite.

[43] SGI retained rights to the IRIX version of Cosmo Player and was to release at least one more version, corresponding to Cosmo Player 2.1 for Windows, early in 1999. Indeed, the first 2.1 beta for IRIX was released at the end of February.

[44] WorldView 2.1 was preinstalled on new machines that shipped with Intel's i740 3D accelerator.

[45] There was actually a tiny glitch: one pixel in the corner of one GIF texture was the wrong color. Oops.

[46] Perl 5.0; Perl modules libwww, libnet, MIME-Base64, MD5, HTML-Parser, and Data-Dumper; Mesa or a commercial OpenGL library; FreeType; libjpeg, libpng, and zlib; and optionally XSwallow, to enable its use in Netscape Navigator as an inline VRML plug-in.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required