Skip to main content


Here you will find a complete, worked, end-to-end tutorial for building your own transparent (with alpha channel) animated ray-traced graphics on your web site. The intention is to use a process without any manual steps so that the animation build is completely automated.

For the impatient, download and unpack the supplied TGZ file and run make then view torus-150x120.html in your web browser.


  • POV-Ray to create the anti-aliased ray-traced graphic frame images.
  • ImageMagick to append and compose image frames.
  • GIMP (the GNU Image Manipulation Program) to transform the shadow images into a partially transparent state.
  • Bourne Shell to call a GIMP Scheme script.
  • Make to build everything automatically


Firstly create your POV-Ray scene. I used KPovModeler to simplify this task. Surround your objects with white planes. Set the ambient light to white if you don't want shadows, or grey if you do. Later we will replace the varying degrees of whiteness with a respective degree of transparency.

Save your POV file. Obviously you will be using clock to enable animation. Create a copy of the POV file. I named this torus-obj.pov. Remove the background white planes from this file. Create another copy of the POV file. I named this copy torus-shadow.pov Add no_image 1 to your scene objects in this copy. This will render the shadows without the actual objects that cast those shadows.

Next, render all the object and shadow frames of the animation, e.g. povray +W150 +H150 +QR +UA +A0.1 +R9 +UL +KC +KFI1 +KFF120 torus-obj.pov. This will create 120 invidual PNG files named torus-obj000.png to torus-obj120.png.

Now append all the images into one large, tall, single film-like image. Use ImageMagick for this, e.g. convert -append -define png:color-type=6 torus-shadow???.png torus-shadow-150x120.png. Note that we must retain the RGB colour map as ImageMagick can sometimes change this to monochrome which impacts our ability to add an alpha channel later.

Use GIMP in batch mode to make the shadow image strip partially transparent (i.e. replace varying levels of white with varying levels of transparency), e.g. sh ./ torus-shadow-150x120.png torus-shadow-alpha-150x120.png. Here is the content of

# Usage: mkalphashadow src.png dest.png

gimp -d -f -i -b -<<PMIG
    (image (car(file-png-load RUN-NONINTERACTIVE "$1" "$1")))
    (drawable (car(gimp-image-get-active-drawable image)))
  (plug-in-colortoalpha RUN-NONINTERACTIVE image drawable '(255 255 255))
  (file-png-save RUN-NONINTERACTIVE image drawable "$2" "$2" FALSE 9 FALSE FALSE FALSE FALSE FALSE)
(gimp-quit 0)

Finally, merge the transparent shadow and transparent object images into a single file, e.g. convert -composite torus-shadow-alpha-150x120.png torus-obj-150x120.png torus-150x120.png.

Some HTML, CSS and JavaScript is required to display and animate the graphics. Firstly some CSS to paint the image into the background of a DIV.

  body { background-color: lightgray }
  #anim {
    width: 150px; height: 150px;
    background-image: url(torus-150x120.png);
    background-repeat: no-repeat; 

Paint the DIV somewhere in the HTML code, i.e. <div id="anim">&nbsp;</div>. Following this, some JavaScript to slide the image up and kick off the process.

  var scrollUp = (function () {
    var timerId; // stored timer in case you want to use clearInterval later
     return function (height, times, element) {
      var i = 0; // a simple counter
      timerId = setInterval(function () {
        if (i >= times) // if the last frame is reached, set counter to zero
          i = 0; = "0px -" + i * height + 'px'; //scroll up
      }, 33); // every 33 milliseconds (1/30s)

  // start animation:
  scrollUp(150, 120, document.getElementById('anim'));




Attachment Size
torus-150x120.png (587.75 KB) 587.75 KB
torus-anim.tar.gz (3.38 KB) 3.38 KB