Table of Contents
Description
of Subject
Requirements
Tutorial
Overview
List
of Supported Functions
Isosurface
Statement Syntax
Using
x, y and z
Using
Abs
Making
Cylinders, Spheres and Superellipsoids (Using Sqr)
New
- Additional (Important) Information for Making Spheres
Isosurfaces are three-dimensional representations of mathematical functions. A wide variety of objects can be created with isosurfaces, from simple spheres and boxes, to more complex shapes such as octahedrons, torii, various crystal shapes, and even spherical height_fields. Best of all, they render at a good speed (depending on their complexity).
You must have MegaPov installed onto your computer in order to use the isosurface object. MegaPov can be found here. Of course you'll have to have the original POV-Ray to use it, which can be found here.
This page will describe how to get started in making your own isosurfaces. It will assume you have experience using POV-Ray. It will not assume, however, that you know anything about isosurfaces. Furthermore, this tutorial will not cover all, or even most areas of making isosurfaces. It is merely here to help you get started.
You will notice that some functions are in red. Red indicates that the function has been altered from the last one, but is the same function.
By merely reading the tutorial you may get confused and frustrated. However, by actually rendering the code here yourself, you will understand it a lot more.
Experiment! After learning what you can here, try experimenting with the different functions listed below. Try all kinds of things, as this is the best way to learn how to use the isosurface. By the way, you don't have to know a whole lot of math to experiment.
![]() |
This will be the position of the camera and location of the x, y and z axes used throughout this tutorial. Remember this if you get confused about what the heck is going on. |
x y z
abs( ) sqr( ) sqrt( ) cub( ) exp( )
sin( ) asin( ) sinh( ) asinh( )
cos( ) acos( ) cosh( ) acosh( )
tan( ) atan( ) tanh( ) atanh( )
min( , ) max( , ) noise3d( , , )
floor( ) ceil( ) pi
+ - * / ^ & | %
Note that spaces inside the parenthesis and in-between commas are where you put the functions. Adherance to the structure of the above functions will result in less errors down the road.
isosurface{
function{ function items }
threshold float value
sign -1 or 1
contained_by{ sphere or box statement }
}
To simplify things, I have only added the items that are needed. If it isn't in the above syntax, don't worry about it. The other items can lead to bad isosurfaces if used, and aren't needed for most things. I will get into the other keywords in later tutorials.
function - This is where all the mathematical functions that describe the surface are placed.
threshold - This is how much strength, or substance to give the isosurface. A value of 1 is good for most things, and is what we will be using throughout this tutorial.
sign - Sign makes the function's surface either inside or out. Sign 1 is good for most things.
contained_by - Must be included if you are using MegaPov version .4. Version .3 and lower will give you an error if it encounters a contained_by statement. Contained_by gives the isosurface a limit. For instance, if you make an isosurface sphere that has a radius larger than 1 unit, and you put:
contained_by{ box{ <-1,-1,-1>,<1,1,1> } }
in the isosurface statement, what do you think will happen? The box will cut into the sphere, giving you an intersected box and sphere, the sphere having 6 flat sides.
You can contain an isosurface with either a sphere or a box, both of which use the standard POV-Ray syntax.
Let's get going to the fun stuff. Open MegaPov and create a new file.
Situate your camera and light_source as you desire.
Type:
isosurface{
function{ x }
threshold 1
sign 1
contained_by{ box{ -1, 1 } }
pigment{rgb 1}
}
You should have gotten a cube when you rendered it. Not much happened, since our contained_by object is a cube. But now try this function:
function{ x+1 }
| The true nature of x is revealed! The cube is now seemingly cut in half. x is actually a plane which is bound by the 'containted_by' box. By adding +1 to x, we have moved the plane 1 unit to the left on the x-axis, or more specifically, 'shrunk' the isosurface, which had nowhere to go but left. Note: if threshold equaled zero, the plane would have been in the middle already. |
Now for the function put:
function{ x+y }
![]() |
Did you see what happened? By adding x+y, we have created a plane that is diagonal. It is now a plane on both x and y axes. Try adding a - (minus) before the x and see what happens. It should give you a diagonal plane facing opposite of what it was before. |
Now try:
function{ x+y+z }
![]() |
By adding x, y and z together, we have created a plane which uses all three of those axes. The plane is hard to see, however. Try putting x+y-z as the function and it will reverse itself on the z-axis, appearing on our side of the object. |
abs is commonly used in isosurfaces. What is does, essentially, is make a mirror of whatever you use it with. For this example we will use x+y as our function, but add a twist:
function{ abs(x)+y }
![]() |
We come up with a shape that resembles a house. We arrived at this shape because abs made a mirror of x. What do you think will happen if you use abs(x)+abs(y) as the function? |
Let's modify the 'house' function and type:
function{ abs(x)+abs(z)+y }
![]() |
By adding abs(z) to the function, we've:
1. made a plane that uses all three axes, as shown earlier
Try replacing y with abs(y) and see what happens. |
Making Cylinders, Spheres and Superellipsoids (Using ^, Sqr, and Sqrt)
Let's remember what x, y and z does. Any one used by itself will make a plane on that axis, right? And any two or three added together will make a plane using those axes. Let's add x and y together again, but encapsulate each in sqr functions:
function{ sqr(x)+sqr(y) }
![]() |
We came out with a cylinder. That is because sqr is a lot like abs, but instead of making a sharp mirror, it makes a perfectly rounded one. |
Now let's try this:
function{ sqr(x)+sqr(y)+sqr(z) }
![]() |
That is one way to make a sphere! |
There's an even shorter way to make a sphere:
function{ x^2+y^2+z^2 }
You should have gotten a sphere that looks exactly like the last one.
Now, since we've made a sphere using that method, we can easily make a superellipsoid out of it. Type:
function{ x^4+y^4+z^4 }
![]() |
It seems x, y and z are showing themselves again. If you use even higher numbers than 4, the edges of the superellipsoid will appear sharper. If you use odd numbers, such as 3 and 7, the object will turn out asymmetrical. Try adding a different even number for each x, y and z. |
We can even make a superellipsoid cylinder:
function{ x^4+y^4 }
![]() |
The good thing about isosurface superellipsoids is that they, for the most part, tend to render faster than pov's superellipsoids. You can increase the bounding box inside the isosurface statement to make this longer, or you can scale it. |
You may have guessed that there are even more ways to make spheres, cylinders and superellipsoids. Try all kinds of things!
New -Additional (Important) Information for Making Spheres and Cylinders
To make a sphere or cylinder that can be scaled perfectly, encase the function in sqrt like this:
function{ sqrt( x^2+y^2+z^2 ) }
You can now introduce a small number to shrink or increase it's size, like so:
function{ sqrt( x^2+y^2+z^2 ) +.5 } //makes sphere .5 units in diamenter
function{ sqrt( x^2+y^2+z^2 ) -.5 } //makes sphere 1.5 units in diameter