Shadowed lighting texmap applet

Introduction

This applet demonstrates a reasonably fast algorithm for generating shadows for a terrain map. My intended use for the algorithm is to make texture maps of detailed features of a planet for viewing by a distant viewer, to go with my terrain generator. When the viewpoint is far away from the surface compared to the height of surface features, shadows are among the dominant features. The surface can be adequately represented by texture maps pasted on to a relative small number of polygons.

The terrain seen here is generated with a simple hierarchical function seeded off the system clock, so reloading the page will produce different terrain. In addition, four small towers are scattered around the area randomly (to cast some long shadows.)

How to Use It

The controls are as follows:

This applet will probably work best under Netscape with a recent version of the Java plugin. However, I carefully used only JDK1.1 calls with no Swing, so it should in theory work on almost any Java-capable brower. If you don't see some shaded terrain when the applet loads, and feel like pursuing the issue, you can mail me

The applet is disappointingly slow under netscape on linux. (I haven't tried any other operating systems or browsers.) I think this is because the MemoryImageSource is slow. It runs many (about 10) times faster under a recent version of appletviewer on the same hardware.

The Algorithm

The shadowing algorithm is quite straightforward. If you are interested, here's the source. Please don't mock me for the wacky implementation of Bresenham's line-drawing algorithm - I didn't have it handy and had to derive it. I also am suspicious of the way I'm computing the surface lighting other than the shadows. The shadow code of interest is in the method updateShadows(). If you need further explanation or have any other comments, please send me mail at jasonmod@texas.net.