Clip Mapping
Level: Intermediate
Clip mapping is the term used to describe using photographs or drawings as
maps onto objects with an alpha channel. This creates the illusion of a detailed
3D object when in computer terms, all we have in the scene is one simple polygon.

On the left is our original image, on the right is the alpha channel that
we use to "cut out" the horse.
The advantage is obvious - having a realistic looking render with a minimum
of complexity in our scene. Clip mapping is particularly useful with objects
such as people, trees, cars or animals. Any object that would have a high "polygon
count" and does not need to be animated could become a good clip map instead.
Creating Clip maps
There are three primary methods to assign a clip map in Realsoft 3D -
1. Use an alpha channel from a Targa file - this allows one to get various levels
of subtle transparency. Targas have the advantage of being able to store the
alpha channel in the same image file (32 bit = transparency channel, 24 bit = color
only.)
2. Use a certain color as a clip channel. e.g. the solid BLACK background
would be transparent in this tree:

3. Use two separate images - one for color and one for the alpha channel.
Color clipped Tree
Let's start with the most basic method first - color clip maps.
1. Create a new scene.
2. Create an analytical rectangle - any size.
3. Create a new material, use a template. Select "clipmap" from the
"Image maps" directory. Select
the image "Tree.jpg" from the
tutorprojects\material\clipmap\textures directory.
4. Render the image. At this point you can see that the default color range
has used the black color to grey to define the transparency. This is probably
too much, so let's select a darker color grey (just above black). Note that we
have no color information on our object yet either - we have only the "clip"
component.
5. Add a "texture map" wizard to our current "clipmap"
texture. Select the "Tree.jpg" as the color image and render. You
should now see a tree that has been clipped out and will cast detailed shadows.

Fade mapping
Realsoft 3D uses the term "Fade" in VSL to describe the transparency component
that is cut out from an object. Just as we use the "color" channel
to put an image or color onto an object, whatever is mapped to the fade channel
will be cut out from the object. It is an advanced form of "trim curve"
if you like - allowing you to cut out detailed or arbitrary edges to an object,
and even give it levels of "transparency" where only half a cut is
achieved.
The advantages of using fade mapping is we can get a soft edge - or antialiased
edges to the cut, giving it that added level of realism.
1. Create a new scene.
2. Create an analytical rectangle - any size. (Keep in mind the aspect ratio
of the original image being mapped)
3. Create a new material, use a template. Select "fade map". Select
the image "Horse_alpha.jpg" from the
tutorprojects\material\clipmap\textures directory. Drag this
material onto the rectangle. Render the image.

Note how our horse is "back to front". we have mapped the image on
the right to achieve the image on the left. Standard alpha uses white for solid
and black for transparent. Realsoft 3D uses the opposite. Black is solid and White
is transparent. Instead of going into photoshop and inverting the image, we
can do this inside Realsoft 3D. In the materials "advanced" tab :
4. Add a "constant" above the fade texture. Change the "output"
of the constant (default color) to "surface : fade". Assign a value
of 1 to the constant. On the fade texture map below our constant, change the
operator to "subtract" instead of "assign". This now takes
the image alpha away from a constant of 1 or solid. This basically flips our
alpha channel.
5. Render the image - our horse should be cut out correctly. But we still
need to add the color information. Use the "add texture map" wizard
and select "horse.jpg". Render. You have just created a horse!

Targa clip maps
Targa image formats are the standard method for storing alpha information into
one image. The procedure is exactly the same as the method outlined above. Only
the same image is used for both color and alpha. When a Targa is selected as
a Fade map, the "Bindings" tab must be set to use the alpha channel
as the output to use for the fade channel. This is done by checking the "edit
bindings" button in our advanced VSL settings., Removing the "colorR
-> Fade" binding, then selecting Alpha and Fade and Adding. This may
not always be necessary - just check that the alpha is being used for the fade
first. Often adding the texture first to a color map then changing the output
to fade will set "alpha -> Fade" automatically. Inverting the alpha
may depend on the source of the targa. If it is already inverted - you will
not need to use the constant=1 value.
Scope mapping
Scope refers to how much of the current mapping will be mapped onto an object.
We could map only text onto an object for example, by essentially "clipping"
the background with our alpha and only the text will be mapped onto the object.
But rather than actually CUTTING the object, we are cutting only the texture.
This has powerful possibilities - especially for adding textures over already
assigned textures! (e.g. adding windows over a brick wall.)
1. Create a new scene.
2. Create an analytical sphere - any size.
3. Create a new material, use a template. Select "color". Assign
this material to the sphere by dragging it onto the object.
4. Create another new material, use a template. Select "scope map".
Assign the texture "scope_alpha.jpg" to the scope field. The texture
can be found in the tutorprojects\material\clipmap\textures directory. The image
below shows white text on a black background. This will give the white areas
a scope of 1 and black areas a scope of 0.

5. Add a color gradient to our texture - add "texture map" wizard
and select "scope_coloring.jpg" from the
tutorprojects\material\clipmap\textures directory.
.

6. Map this new texture onto our sphere using parallel mapping - make it roughly
in the proportions to the image below.

7. Render the image. We should have achieved a blue sphere (default color
material) with the writing "scope mapping" written in color on the
side of the sphere. Note how our color gradient was simply clipped by the scope
mapping scope texture. We can also select "finite XYZ" under the mappings
"Spec" tab to restrict our texture from penetrating both sides of
the sphere.
We can keep adding materials in this manner to get windows on walls, rust into
crevices, writing on signs, etc.
Refer to "Adding Dirt" tutorial for further explanations in scope
mapping.
Flat Image Vs 3D Object
One of the biggest challenges with any clip map is to have the image facing
toward the camera at all times. We can tolerate a certain degree of movement
- up to a point the illusion is ruined and the clip map is exposed for what
it is - a single plane. We have certain "hacks" that we can utilize
to give clip mapping an added degree of realism. One such example is to place
the two planes at right angles to each other to form a "cross" in
plane. Providing that the object (such as a tree) is roughly symmetrical, the
illusion can be maintained from a 360 degree rotation.

There are various mapping methods such as the "look at" controller
that can be used to make clip mapped objects follow the camera if needed.
But one need not be restricted to simple rectangular forms either - we can
just as easily map a cylindrical map and clip out a 3D object.
