Graphics Muse Issue #15

#### "Linux Gazette...making Linux just a little more fun!"

Set your browser to the width of the line below for best viewing. © 1996 by mjh

| muse: v; to become absorbed in thought n; [ fr. Any of the nine sister goddesses of learning and the arts in Greek Mythology ]: a source of inspiration elcome to the Graphics Muse! Why a "muse"? Well, except for the sisters aspect, the above definitions are pretty much the way I'd describe my own interest in computer graphics: it keeps me deep in thought and it is a daily source of inspiration. [Graphics Mews] [Musings] [Resources]

his column is dedicated to the use, creation, distribution, and dissussion of computer graphics tools for Linux systems. After much delay I've finally started learning about the Blue Moon Rendering Tools (BMRT). It seemed only natural that I take what I learned and pass it on to my readers. So, starting this month, I'm going to do a three part series on BMRT and RenderMan® shaders. I've gotten help, of course. My thanks go out to Paul Sargent for providing example code and a place to bounce ideas off and to Larry Gritz, author of BMRT, for general support and technical assistance. The first in this 3 part series is an introduction to the tools and some relatively simple examples on how to use them. Although the BMRT articles are a big project in themselves, I don't want to devote 3 entire issues of the Muse to just BMRT. In this months column I'll also be covering a few other topics. A review of Mark Kilgard's OpenGL Programming for the X Window System. Information on scanner support for Linux. Both of these are go into some detail. Along with the usual set of Mews offerings, this should be enough to hold you until next month. I was going to do a bit on John Beale's wonderful tool, HF-Lab, this month but decided to wait until next month. I happened to run across a few other POV-Ray tips recently and thought that the set of tips along with the HF-Lab review would fit well together. Look for them next month. An update on my crashed system woes: my little network at home uses a 386 16Mhz Dell computer as a server for doing backups. I had set it up but had not implemented the backups when my main system bit the bucket. After getting my main system running again I ended up with some extra drives that I wanted to put in my server. I first tried to make backups of my main system, across the network, using a version of taper that I had installed on my main system and just copied over to the server. That sort of worked, but for some reason taper wouldn't see some of my target directories. I figured it was incompatible with the installation I had on the 386, so I upgraded to Linux Pro (which is what I installed on my main system). Mistake. The server stopped working. The problem is a secondary IDE that I added to make use of the extra hard disks. I mucked with it for a week, got fed up and now have a new Cyrix 166, motherboard, and mini tower on order. The motherboard and 166 are going in the main box, and the old 486 and motherboard are going in the mini tower. I'm retiring the 386. It will take its rightful place next to my retired Wyse286 PC with its 20M hard drive. I never wanted to be a system administrator. I just want to use my systems. sigh At least with Linux I have more control over what I use. So, one month after disaster hit I still don't have reliable backups running. There is money to be made in making backups easy for Linux users. I guarantee it.

Disclaimer: Before I get too far into this I should note that any of the news items I post in this section are just that - news. Either I happened to run across them via some mailing list I was on, via some Usenet newsgroup, or via email from someone. I'm not necessarily endorsing these products (some of which may be commercial), I'm just letting you know I'd heard about them in the past month.
#### GIFWizard If you'd like to reduce the size of your GIF images but don't really know how to do it on your own, there is a free online service you can try. The GIF Wizard (http://www.raspberryhill.com/gifwizard.html) will work with images already on the Net (you provide a URL for the image) or on images on your hard drive. Note: Definitely don't ask me about this service - I haven't used it and only offer the info here because it looked like it might be of interest to some of my readers. |  |  | #### Tnpic - GIF/JPEG indexer Tnpic, from Russell Marks (who doesn't have email access anymore), is a GIF/JPEG indexer that used to be bundled with zgv up until version 2.3. The index is output as a JPEG. Tnpic is available from sunsite.unc.edu /pub/Linux/apps/graphics/tnpic-2.4.tar.gz
#### Ra-vec Ra-vec is a new free application for Linux, SGi and Sun's from Rob Aspin that converts X Bitmaps, such as 2D plan drawings (architect's drawings), into a vector format which can be read by the 3D modeling package AC3D (see the January 1997 issue). Using Ra-vec, complex 3D models and environments may be rapidly prototyped, reducing overall development time. To download a free copy of the software got to: http://www.comp.lancs.ac.uk/computing/users/aspinr/ra-vec.html.
#### VARKON for Linux VARKON is a high level development tool for CAD and Product Modelling appliactions from Microform AB, SWEDEN. The system includes a very powerful modelling language called MBS and an interactive environment for traditional modelling and developing MBS-applications. Keywords are: 2D, 3D, Wireframe models, Surface models, Parametric, Structured Object Oriented Database, Easy to integrate with other systems, Commersially available on most platforms at a very low price. At the Web site - http://www.microform.se - you will find A lot of technical information about VARKON Links to download the latest version of Linux-VARKON (version 1.14E) Links to download the full documentation in text or MS-Word-format Links to download demo-applications with source MBS-code, documentation, etc. You can also download a restricted but free demo-version of the system for Windows95.
#### QuickCam Resources Interested in doing some work with the Connectix QuickCam? Thats the little round camera that has become very popular with Windows and Mac users. Russ Nelson (of the old Packet Drivers fame, for those of you who remember that software) maintains a very good resource page for the QuickCam at www.crynwr.com/qcpc. It contains links to drivers and applications for many operating systems, including Linux and other PC based Unices. Connectix also maintains a page for developers. They offer lots of information and require only that you register for their developers program, which costs nothing. You can find them at www.connectix.com/connect/developer.html If you're looking for a Linux driver for the Color QuickCam, check The SANE Project, a project to develop a generic interface to various types of media devices, such as scanners and the QuickCam. This package also contains a frontend to the Color QuickCam driver. For those of you in the US wondering what these little gadgets cost, CompUSA sells the Color QuickCams for about $249.
#### Did You Know? There are many places to find information about OpenGL on the Internet. The following is only a small list: The OpenGL Utility Toolkit (GLUT) Programming Interface API Version 3 http://reality.sgi.com/mjk_asd/spec3/spec3.html Mark J. Kilgard Silicon Graphics, Inc. Frequently Asked GLUT Questions http://reality.sgi.com/mjk_asd/glut3/glut-faq.html An Introduction to OpenGL http://www.dgp.toronto.edu/people/van/courses/csc418/opengl1.html The OpenGL WWW Pages http://www.digital.com/pub/doc/opengl/ Course 22: OpenGL and Window System Integration OpenGL Portability Notes SIGGRAPH '96 http://www.ssec.wisc.edu/~brianp/sig96/portable.htm OpenGL WWW Center from Silicon Graphics http://www.sgi.com/Technology/openGL/ There are also a few sites with RenderMan information: The RenderMan Repository - (http://pete.cs.caltech.edu/RMR/index.html) A storehouse for all things related to RenderMan. RManNotes - (http://www.cgrg.ohio-state.edu/~smay/RManNotes/index.html) General information about writing shaders in the RenderMan Shading Language and using the two most commonly available RenderMan renderers Q and A Q: Is displacment mapping the same thing as reaction-diffusion? A: No. Reaction-diffusion simulates the mixing of chemicals, which is theorized to have something to do with certain organic texture patterns, like leopard skin. Bump mapping is perturbing the normal of an object to simulate bumps, but without actually moving points on the surface. Displacement mapping does what bump mapping merely simulates - it actually distorts the surface points of the object which is being mapped. This avoids artifacts you get from the bump mapping approximation (like actually making the silhouettes rough). You can think of it as a height field over an arbitrary surface. Q: What is a stochastic raytracer and are there any freely available? A: "Stochastic sampling" or "distribution ray tracing" (it's not called distributed these days) refers to placing samples at irregular intervals, rather than regularly spacing them. It doesn't have anything to do with the number of rays per pixel -- 1 sample per pixel can easily be jittered, and 100 samples per pixel can be regularly spaced. Also, it's not dependent on ray tracing -- PRMan uses stochastic sampling and it uses a scanline method. Technically, stochastic sampling transfers high frequency signal energy above the Nyquist limit into noise, rather than having that energy alias as lower frequencies. It's just trading one artifact for another, but by coincidence the human visual system appears to find noise less objectionable than aliasing. BMRT is a stochastic raytracers. POV-Ray is reported to be (but no official word if it is or not). Others include (not all are raytracers): PRMan, Mental Ray, and Alias. Thanks to Larry Gritz for these definitions. Q: What is tessellation? A: Mark Kilgard writes the following in his OpenGL Programming for the X Window System: In computer graphics, tessellation is the process of breaking a complex geometric surface into simple convex polygons. The use of convex polygons allow for better performance in OpenGL.

####

OpenGL Programming for the X Windows System Mark Kilgard Addison-Wesley Developers Press There are a growing number of Application Programming Interfaces (API's) available for Linux that enable software developers to create programs that render 3D graphics. Some of these are designed to allow programs to output data files that can be used by rendering engines to create a 3D image either to a display or to a file. The libribout.a static library in the BMRT package is an example of this kind of interface. It allows the software developer to write a program to output a RIB formatted file which can then be used by a RenderMan® compliant renderer. Other tools are designed for interactive 3D display. One such developer tool is OpenGL. OpenGL is, if not the grandfather, the God Father of all interactive 3D development tools. OpenGL is an API designed by Silicon Graphics and now managed by the OpenGL Architecture Review Board. It is defined by the OpenGL Programming Guide as follows: The OpenGL graphics system is a software interface to graphics hardware. (The GL stands for Graphics Library.) It allows you to create interactive programs that produce color images of moving three-dimensional objects. The interface is a window system independent interface to graphics hardware. In order to use OpenGL with a particular windowing system it must be used with a supplemental API. This supplemental API allows OpenGL to create its graphics contexts and windows in which OpenGL will do its rendering. Linux uses as its windowing system the X Windowing system, as do most, if not all, other Unices. To use OpenGL with X Windows the software developer must become familiar with GLX, the X Extension for OpenGL, along with one or more toolkits such as the X Toolkit (Xt) and a widget set like Motif (Xm). This is not a simple task. Just learning Xm can be a full time occupation (I know, its what I do now). Fortunately, Mark Kilgard has provided a very thorough text on integrating OpenGL with the X environment: OpenGL Programming for the X Windows System. This text contains 6 detailed chapters, 1 chapter devoted to an example application, and a number of very useful appendices. The first two chapters introduce the reader to OpenGL and the two libraries that generally accompany it: GLU, the GL Utility library that is used for certain operations that are hardware inspecific such as polygon tesselation, and GLX. The introduction is quite good except for explaining the use of GLU. All OpenGL functions are prefixed with "gl" except for the GLU functions which are prefixed with "glu". I can understand why they did this, but it is confusing to remember that OpenGL is actually two sets of functions with different prefixes (as if the X Windows system didn't provide enough of these already). -Top of next column- |  |  |  |
More Musings... Scanner Report - whats supported and where to get the software. BMRT Part 1: Getting Started - Creating, Previewing, and Final Rendering of Simple Images (>45K text + numerous images)
Chapter 3 is a detailed explanation of how to use OpenGL with Motif. The basic premise is that you need to combine OpenGL (gl and glu routines) with the X Extension for OpenGL (GLX) and the widget set of choice (Xm along with Xt to manage the widget set). That seems like a lot of work. Not to mention that writing an OpenGL application this way, with the X calls embedded in the source, removes the portability that a developer originally had with just OpenGL. It would be nice if there were a way to remove the X calls and have a truly portable OpenGL application. There is. Mark introduces the GLUT library in Chapter 4 which hides most (not all) of the window system specific API calls from the developer. This toolkit, although not necessarily appropriate for full-featured OpenGL applications, provides an example of a toolkit which can handle window system API's for the developer and allow the developer to write a single source code base portable to any platform. The toolkit itself can be implemented in X, Windows NT or any other windowing system. The application developer only needs access to the toolkit. Chapter 4 is an introduction to the more basic features of GLUT. It covers such topics as window managment, callbacks, and font rendering. Chapter 5 goes into significantly more depth. Its 90+ pages cover topics ranging from lighting and texture mapping to using images and bitmaps to curves and surfaces. This chapter will be the one most readers will refer to repeatedly when they've gotten past their first sample OpenGL programs using GLUT. Chapter 6 covers advanced topics such as the X Input Extension, Overlays, and peformance issues. There are 3 appendices, the most interesting of which is the "Functional Description of the GLUT API". This is a reference section for the most part although it is not formatted with one page per function. This makes it a little hard to find what you're looking for since more than one function can be on a page. Other than that its a fairly complete description of the GLUT API. There is also a glossary that follows the appendices. Mark includes extensive sample code right from the start of the text. All the code is available for download from the Internet. The code is easy to follow and the accompanying text is well written. Although Mark does not spend time explaining how to program with the X Windows System (knowledge of which is a prerequisite for this text) he does thoroughly cover how to integrate OpenGL with the X environment. After explaining how this would work he then provides detailed information about how to remove the windowing system specific calls by using GLUT. I find OpenGL Programming for the X Windows System a very well written, thoroughly descriptive explanation on how software developers can integrate OpenGL with their X Windows applications.

The following links are just starting points for finding more information about computer graphics and multimedia in general for Linux systems. If you have some application specific information for me, I'll add them to my other pages or you can contact the maintainer of some other web site. I'll consider adding other general references here, but application or site specific information needs to go into one of the following general references and not listed here.

Linux Graphics mini-Howto
Unix Graphics Utilities
Linux Multimedia Page

Some of the Mailing Lists and Newsgroups I keep an eye on and where I get much of the information in this column:

The Gimp User and Gimp Developer Mailing Lists.
The IRTC-L discussion list
comp.graphics.rendering.raytracing
comp.graphics.rendering.renderman
comp.os.linux.announce

## Future Directions

Next month:

- Height Fields with HF-Lab
- POV-Ray Tips
- BMRT Part 2: Shaders

Let me know what you'd like to hear about!

##### Copyright © 1997, Michael J. Hammel
Published in Issue 15 of the Linux Gazette, March 1997