• Stars
    star
    154
  • Rank 241,192 (Top 5 %)
  • Language POV-Ray SDL
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ray tracing 25 scenes in 25 days with POV-Ray

Ray Tracing with POV-Ray

Four years ago, I wrote a simple ray tracer in Java to render a scene hard-coded in the source code. After writing this ray tracer, I came to know about sophisticated ray tracing engines available for free on the internet. POV-Ray seemed to be one of the most popular engines and I decided to learn to use it. However, I never managed to devote time to learning it in the last four years. Finally, in May 2013, I decided to teach myself to do ray tracing with POV-Ray. This activity consisted of learning the concepts required to write scene descriptions for POV-Ray, and writing a new scene each day for 25 days in the month of May 2013.

Contents

A scene a day

  1. Balls and boxes

    Balls and boxes

    This scene consists of three spheres and three boxes. The scene is illuminated by three point light sources.

    One light source is shining from the top right corner of the scene. This light source is behind the camera. This casts the shadow of the green box on the blue ball and that of the blue ball on the yellow one.

    Another one is shining from the left side of the scene. This light source is also behind the camera. This casts the smaller shadow of the red box on the blue ball, that of the green box on the orange ball and that of the blue ball on the pale pink box.

    There is a third light source at the bottom right corner of the scene. This light source is present slightly in front of the camera. This casts the longer shadow of the red box on the blue ball.

  2. Transformed Boxes

    Transformed Boxes

    The white box is centred at the origin. The camera is placed 10 units behind the origin. One light source is placed 10 units behind the origin, i.e. at the same place where the camera is. There is another light source shining from the top left corner of the scene.

    All boxes except the three boxes in the bottom-right quadrant of this image have the same dimensions as that of the white box.

    The red box is translated to <2, 2, 2>, i.e. 2 units left from the origin, 2 units above the origin and 2 units further away from the origin in the direction perpendicular to the image.

    The green box is translated to <5, 5, 2>, i.e. it has been shifted further way towards the top right corner. As a result we can see more of its left and bottom faces.

    The blue box is translated to <5, 5, 5>, i.e. it is placed 3 units behind the green box. As a result it appears smaller than the green box.

    The yellow box is first rotated around z axis by 45° and then shifted left by 5 units

    The cyan box is first shifted left by 5 units and then the box is rotated around z axis by 45°. In the rendered image, it can be seen that the whole box as a whole orbits around the z axis due to the rotation and occupies a new place 45° away from the yellow box in this orbit.

    The length of the brown box is first doubled along x axis, then it is rotated 45° around y axis. As a result, the elongated face is rotated towards left. Then it is translated to a new position below the origin, a little further away towards the right.

    The pink box is first rotated 45° around y axis. Then it is scaled by a factor of 2 along x axis. As a result, the diagonal of the box running along x axis seems to be elongated. Finally, this box is translated and placed right below the brown box.

    The maroon box is first rotated along y axis by 45°. Then it is translated to a new position right below the pink box. Finally, it is scaled by a factor of 2 along the x axis. As a result, the box appears to have moved further along the x axis. Also, its diagonal along the x axis appears to be stretched.

  3. Marble Sphere in Rubber Torus

    Marble Sphere in Rubber Torus

    There are two light sources in this scene: one where the camera is situated, and another on the left side of the scene.

    The sphere and the torus appear to be specular due to Phong highlighting. As a result, two bright shiny spots can be seen on the sphere as well. One spot is closer to the camera while the other one is on the left side of the sphere. These spots are due to the two light sources. Similar but fainter shiny spots can be seen on the torus as well. The specular highlights on the torus appear fainter because a less saturation value was used for the Phong highlighting was used for the torus.

    In addition to making the sphere specular, it has also been made slightly reflective. As a result, a faint reflection of the torus can be seen in the bottom hemisphere of the sphere.

  4. Crystal Ball

    Crystal Ball

    There are two light sources in this scene: one at the centre of the ceiling and another at the top of the wall opposite to the camera. The walls are glossy, and thus reflect the scene slightly.

    There is a mirror on the wall opposite to the camera. The mirror has a wooden frame. The reflection of a door in the wall behind the camera can be seen in the wall opposite to the camera.

    There is a crystal ball placed on a wooden block. There are two other coloured balls lying on the floor.

  5. Prisms

    Prisms

    The room in this scene is similar to the room in the previous scene. However, in this scene the floor is reflective instead of the walls. The balls are missing from this scene and there are two prisms instead on the wooden block. The reflection of the door behind the camera can be seen in the mirror on the wall opposite to the camera.

  6. Ripples

    Ripples

    This scene contains a rubber tube floating on water. There are ripples on the surface of water. The ripples have been made slightly turbulent in order to make it look a little natural.

  7. Textures

    Textures

    This scene contains a wooden block and spheres with various textures placed on the floor of a room. The block is made of pine wood. There is a ruby glass sphere placed on the block. There is a pink granite sphere placed between the mirror and the wooden block. The leftmost sphere is made of white marble. The one to its right is made of brown agate. The next sphere that looks dark is made of blue agate. The reflective sphere on the floor is made of aluminium. The rightmost sphere is made of red marble. The mirror at the back shows a reflection of the scene.

  8. Window

    Window

    This scene shows light entering a room through a window. Isotropic scattering makes the light beam coming through the window visible.

  9. Sky and Water

    Sky and Water

    This scene contains water and sky. The sky contains clouds and the water contains irregular ripples. The water reflects the sky.

  10. Soft Shadows

    Soft Shadows

    This scene contains a few marble balls and metal rods placed on a wooden plank. The scene is illuminated by three area light sources. The area light sources cast soft shadows. The light sources fade away with distance. As a result, the scene at the top left corner of the image appears to be darker than the rest of the scene. The soft shadows and the fading light sources make this image seem quite photorealistic.

  11. Focal Blur

    Focal Blur

    This scene contains six coloured balls lying on a tiled floor. The camera is focussed on the white ball at the centre. The shallow depth of field causes other balls to blurred.

  12. Pawns

    Pawns

    This scene contains a white pawn and a black pawn placed on a chessboard. There are two light sources shining on the chessboard: one from the left side and one behind the chessboard.

  13. Glass Pawns

    Glass Pawns

    This scene contains glass pawns placed on a glass chessboard.

  14. Globe

    Globe

    This scene contains a globe placed on a glossy surface. The globe was created by wrapping a map of the earth around a sphere. The map used to create this globe can be found in the maps directory.

  15. Saturn

    Saturn

    This scene is an attempt to model Saturn along with its five prominent rings. The planet and the rings are drawn to scale.

    The innermost ring is the D ring. The next ring that appears to be translucent is the C ring. The next opaque ring is called the B ring. Then there is a gap called the Cassini Division. After this division, lies the A ring. The A ring contains a thin gap called the Encke Gap. The outermost thin ring is the F ring. The region between the A ring and the F ring is called the Roche Division.

    The shadow of the gas giant on the rings can be seen in the right side of this image.

  16. Planets

    Planets

    This scene represents the models of the eight planets of our solar system. The sizes of the planets are to scale in this scene. Names of the planets from left to right: Jupiter, Saturn, Uranus, Neptune, Earth, Venus, Mars and Mercury.

  17. Moon

    Moon

    This scene contains a waxing half moon. This scene was created by wrapping a map of the moon around a sphere and rotating the sphere in order to show the side of the moon that is visible from the Earth.

  18. Canoe

    Canoe

    This scene contains a white canoe floating on water. The hull of the canoe has been modelled using ellipsoids. The hollow section of the hull has been modelled by removing smaller ellipsoids from a large ellipsoid that forms the outer surface of the hull of the canoe. The canoe contains three wooden seats. The water is slightly reflective. The water reflects the sky, and thus appears blue in colour. A distorted reflection of the canoe can be seen in the water.

  19. Eggs

    Eggs

    This scene contains half a dozen eggs lying on a tiled surface. Each egg is modelled by combining halves of a prolate ellipsoid and a sphere. The ellipsoid is cut into two halves at the equator. One half is used to model the little end of each egg. The big end of each egg is formed using a hemisphere cut off from the sphere. The length of the semi-major axis of the prolate ellipsoid is 1.6 times that of its semi-minor axis. The tiled surface on which the eggs are kept are slightly glossy and reflective. Two fading area light sources have been used to illuminate the scene. One light source shines from the left side of the scene. The other light source shines from the camera.

  20. Glass of Water

    Glass of Water

    This scene contains a glass of water. There is only one point light source in this scene shining from the left side. The water has been modelled as a material with refractive index of 1.33. The reflection of light by the water has been modelled using Fresnel reflection.

  21. Glass Grid

    Glass Grid

    This scene contains a grid made of glass nodes and edges. Each node in the grid is spherical. Each edge is cylindrical. The edges connect adjacent nodes.

  22. Earth and Sky

    Earth and Sky

    This scene shows the earth and sky meeting at the horizon. A faint fog can be seen near the horizon. The shadows of the clouds can be seen on the ground. A viewing angle of 90° has been used to model the camera.

  23. Glasses

    Glasses

    This scene contains two glasses kept in a kitchen corner. The kitchen has tiled walls. A faint reflection of the window in the kitchen can be seen on the wall behind the wine glass. Light entering from this window illuminates the kitchen. There is another yellow light source attached to the top of the wall behind the glasses.

  24. Kaleidoscope

    Kaleidoscope

    This scene shows the inside view of a kaleidoscope. The kaleidoscope is constructed using three rectangular mirrors placed at 60° angle to one another so that they form an equilateral triangle shaped empty space between them. The triangular empty space between the mirrors can be spotted by looking for the orange disc at the centre of this image. The pink, green and purple discs around this orange disc are placed at three corners of this triangle.

    There are a few more objects, such as coloured grains, little pyramids and pearls placed in this empty space. Multiple reflections of these objects can be seen in the three mirrors surrounding the empty space. The reflection of the empty space can be seen as faint dark triangles throughout this scene.

  25. Dice

    Dice

    This scene contains three glass dice placed on a wooden surface. The scene is illuminated by three fading area light sources.

Installation of POV-Ray

The scenes above were rendered using POV-Ray 3.6 on a Debian system. The steps below describe how POV-Ray 3.6 was installed.

  1. Download POV-Ray 3.6 for Linux from http://www.povray.org/ftp/pub/povray/Official/Linux/povlinux-3.6.tgz. In case, the above URL becomes unavailable in future, a copy of the tarball can be obtained from tgz/povlinux-3.6.tgz.

  2. Enter the following commands to begin installation.

     tar -xvzf povlinux-3.6.tgz
     cd povray-3.6
     bash install -no-arch-check
    
  3. Enter U to make a user level installation at a custom location.

  4. Enter ~/povray as the custom location to install POV-Ray.

  5. Enter the following commands to view the version and help message of povray and its man page.

     ~/povray/bin/povray
     man -M ~/povray/man/ povray
    
  6. Add the following line to ~/.bashrc.

     export PATH=$PATH:~/povray/bin
    

    Now povray can be executed and its man page can be seen from any directory simply by entering the following commands.

     povray
     man povray
    

The following errors were faced during installation:

  1. On trying to install by executing ./install, the following error was displayed:

     This machine does not seem to be a Linux PC.
    

    This error occurred because the script looks for i?86* or athlon* in the output of uname -m, but the output on my system was: x86_64.

  2. On executing ./install -no-arch-check, the following error was displayed:

     ./install: 1094: read: Illegal option -n
    

    This error occurred because the script is executed by /bin/sh by default. This was resolved by executing the script with bash.

POV-Ray commands

The following is a list of commands that were executed to render various scenes.

povray -W960 -H720 scene01.pov
povray -W960 -H720 scene02.pov
povray -W960 -H720 scene03.pov
povray -W960 -H720 +A0.0 scene04.pov
povray -W960 -H720 +Q9 +A0.0 +AM2 +R5 -J scene05.pov
povray -W960 -H720 +A0.0 +AM2 scene06.pov
povray -W960 -H720 +A0.0 +AM2 scene07.pov
povray -W960 -H720 +A0.0 scene08.pov
povray -W960 -H720 +A0.0 +AM2 scene09.pov
povray -W960 -H720 +A0.0 scene10.pov
povray -W960 -H720 scene11.pov
povray -W960 -H720 +A0.0 +AM2 scene12.pov
povray -W960 -H720 +A0.0 scene13.pov
povray -W960 -H720 +A0.0 +AM2 scene14.pov
povray -W960 -H720 +A0.0 +AM2 scene15.pov
povray -W960 -H720 +A0.0 +AM2 scene16.pov
povray -W960 -H720 +A0.0 +AM2 scene17.pov
povray -W960 -H720 +A0.0 +AM2 scene18.pov
povray -W960 -H720 +A0.0 scene19.pov
povray -W960 -H720 +A0.0 +AM2 +R5 -J scene20.pov
povray -W960 -H720 +A0.0 +AM2 -J scene21.pov
povray -W960 -H720 +A0.0 +AM2 scene22.pov
povray -W960 -H720 +A0.0 +AM2 -J scene23.pov
povray -W960 -H720 +A0.0 +AM2 scene24.pov
povray -W960 -H720 +A0.1 +AM2 scene25.pov

Study URLs

The following is a list of tutorials and articles I studied to teach myself some elementary ray tracing with POV-Ray.

  1. The Online POV-Ray Tutorial: Introduction to POV-Ray and Ray-tracing
  2. The Online POV-Ray Tutorial: POV-Ray Basics
  3. The Online POV-Ray Tutorial: Creating Simple Scenes
  4. The Online POV-Ray Tutorial: Advanced POV-Ray Features
  5. 4 tips to improve a simple POV-Ray scene
  6. Slope map tutorial
  7. How to Render Planets

Conclusion

Some prior knowledge of coordinate geometry was helpful in describing some of the scenes. I found the POV-Ray scene description language pretty simple and easy to learn. In these 25 days, I managed to learn a number of useful features and concepts from online tutorials, articles, available source code of POV-Ray scenes described by other POV-Ray users, and managed to describe and render many simple scenes. However, there were a lot of options, features, language directives, effects, etc. that I could not find time for in these 25 days. These things can be learnt in future by studying the official POV-Ray documentation.

License

This is free and open source software. You can use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of it, under the terms of the MIT License. See LICENSE.md for details.

This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, express or implied. See LICENSE.md for details.

More Repositories

1

texme

Self-rendering Markdown + LaTeX documents
JavaScript
2,276
star
2

mintotp

Minimal TOTP generator in 20 lines of Python
Python
1,299
star
3

uncap

Map Caps Lock to Escape or any key to any key
C
1,048
star
4

gitpr

Quick reference guide on fork and pull request workflow
Makefile
957
star
5

spcss

A simple, minimal, classless stylesheet for simple HTML pages
CSS
939
star
6

emfy

A dark and sleek Emacs setup for general purpose editing and programming
Emacs Lisp
932
star
7

muboard

Self-rendering and distributable mathematics chalkboards
JavaScript
560
star
8

emacs4cl

A tiny DIY kit to set up vanilla Emacs for Common Lisp programming
Emacs Lisp
368
star
9

tucl

The first-ever paper on the Unix shell written by Ken Thompson in 1976 scanned, transcribed, and redistributed with permission
Makefile
355
star
10

mathb

Share mathematics on the web with LaTeX and Markdown
Common Lisp
308
star
11

cfrs

An extremely minimal drawing language consisting of only 6 simple commands: C, F, R, S, [, and ].
HTML
240
star
12

invaders

A 1980s-arcade-style game written using HTML5, Canvas, and Web Audio
HTML
166
star
13

devil

Emacs minor mode that intercepts and translates keystrokes to provide a modifier-free non-modal editing experience
Emacs Lisp
156
star
14

hello

A 23-byte “hello, world” program assembled with DEBUG.EXE in MS-DOS
Assembly
156
star
15

fxyt

Tiny, esoteric, stack-based, postfix, canvas colouring language with only 36 simple commands
HTML
114
star
16

pcface

Bitmap arrays for rendering CP437 glyphs using IBM PC OEM fonts
Python
86
star
17

lab

Random experiments, exploration, and learning
Shell
80
star
18

vimer

Declutter your desktop by opening files in existing instance of GVim/MacVim
Shell
70
star
19

myrgb

A simple RGB color guessing game
HTML
67
star
20

quickqwerty

Touch typing tutor that runs in your web browser
JavaScript
61
star
21

ice

Ice - WSGI on the rocks
Python
58
star
22

aes.vbs

AES-256-CBC Encrypt and Decrypt Functions in VBScript
VBScript
52
star
23

heart

Hearts drawn with Python Matplotlib and C
Python
43
star
24

timebox

A timer script for Windows/Linux/Unix/macOS to practice timeboxing (the time management technique)
Shell
43
star
25

may4

Celebrating Star Wars Day with some Forth code! May the Forth be with you!
Forth
38
star
26

susam.net

Source code of https://susam.net/
Common Lisp
35
star
27

inwee

Conveniently send text and commands from file or standard input to WeeChat with this wrapper around WeeChat's FIFO pipe
Shell
25
star
28

bfc

Brainfuck compiler and interpreter
C
17
star
29

reboot

A 5-byte reboot program assembled with DEBUG.EXE in MS-DOS
Assembly
16
star
30

nimb

NIMB IRC Matrix Bridge (NIMB) is a simple client tool that bridges IRC and Matrix channels and forwards messages from one to others
Python
16
star
31

dotfiles

Mostly ~/.* files to configure emacs, vim, sh, tmux, etc. on Debian, macOS, and Windows
Shell
13
star
32

userscripts

Very tiny userscripts to customise the apperance of Hacker News
JavaScript
10
star
33

mano-cpu

My bachelor's degree final year project: A CPLD implementation of a 16-bit microprocessor I learnt from Computer System Architecture by M. Morris Mano
VHDL
8
star
34

susam.github.io

Mirror of https://susam.net/ generated from https://github.com/susam/susam.net
HTML
6
star
35

talks

Talks and presentations
TeX
6
star
36

maze

Susam's Maze • Main website: https://susam.in/maze/ • Mirror: https://susam.github.io/maze/
Common Lisp
5
star
37

licenses

Reusable copies of open source licenses
HTML
3
star
38

blob

Binary files generated from or used by other repositories
HTML
3
star
39

sunaina-and-susam

Sunaina & Susam's wedding website
HTML
2
star
40

.github

1
star
41

emacskeys

Screencasts of Emacs keys and commands
HTML
1
star