Model rendering with Milkshape and POV-Ray 3.5

Copyright (C)2003 Neil Jedrzejewski
(Email)

More tips and tricks

The previous tutorial showed you the basics on how to get your model rendered with POV-Ray. POV-Ray is very powerful so if you would like to make your scene more complex or add more effects, check out the documentation on the POV-Ray web site.

However, there are some useful little tricks you can do with your models to make your renders more interesting.

Creating a "posed" model

If your modelling characters, rendering the reference pose is all well and good but it doesnt look very dynamic and interesting. If your model has a skeleton and an animation, you can export your model from Milkshape's animation mode.

To do this, press the "Anim" button in the bottom right corner of Milkshape and move the animation slider along until your model is in the pose you would like to export.

Next, select File -> Export and "POV-RAY 3.5 Include File..." and export your model as you would normally. You generated include file now contains your model in your chosen pose and can be rendered as normal.

Texture filtering options

To quote from the POV-Ray documentation:

"When POV-Ray checks a color for an image map or a bump amount for a bump map, it often checks a point that is not directly on top of one pixel but sort of between several differently colored pixels. Interpolations return an in-between value so that the steps between the pixels in the map will look smoother."

By default, the plug-in will tell POV-Ray to render any texture bitmaps on your model with bi-linear filtering, although you can change this if you like. To do so, open the include file the plug-in generated and for each material, look for the following line of code:

// Begin Textures Definitions

// Material: "Material04"
#declare uvtexture_0 = texture{
    uv_mapping pigment{
        image_map{
            jpeg ".\lilies.jpg"
            map_type 0
            interpolate 2
            transmit all 0.000000
        }
    }
    finish{
        ambient rgb <0.200000 0.200000 0.200000>
        specular 0.000000
        roughness 0.000000
    }
}

The interpolation value defines what kind of filtering is applied to your bitmaps. Valid values are:

You can adjust the interpolation for each bitmap texture individually by finding its material definition in your include file.

Using transparent textures

The POV-Ray plug-in doesnt export the transparency or alpha map for materials. this is because POV-Ray uses either the bitmaps internal alpha channel or in the case of indexed colour images, set references to which colours are transparent.

For example, above is a model from the Half-Life mod "Day of Defeat". In the game, the blue parts of the textures would be transparent. To make them render as transparent in POV-Ray we have two options:

Save them as RGB images with an alpha channel

In this example I'm editing my image in photoshop on a non-background layer. All of the parts I want transparent have been deleted so that the transparent background checkers show through. When I have my transparency set, I simply choose "Save for Web" and save my image as a 24-bin PNG image and preserve the transparency.

Now I just need to edit the material entry in my include file to tell POV-Ray that I'm using a PNG format file (see "Using non BMP textures" on the previous page) and I can render my image.

As you can see, now the blue parts are transparent and even shadown take on the shape of the transparent texture.

Setting which parts of an indexed texture image are transparent

The other alternative when using indexed colour images (those with up to 256 colours in them) is to specify which colours in the image are transparent and by how much. This may be your best bet if you dont want to have to edit the original textures.

In the case of "Day of Defeat", the textures are 256 colour indexed BMP files where the last colour in the image can be set to be transparent. To get POV-Ray to render these textures with transparency, we need to make small change to the code in the include file.

// Begin Textures Definitions

// Material: "Material04"
#declare uvtexture_0 = texture{
    uv_mapping pigment{
        image_map{
            sys ".\bush_test.bmp"
            map_type 0
            interpolate 2
            transmit all 0.000000

        }
    }
    finish{
        ambient rgb <0.200000 0.200000 0.200000>
        specular 0.000000
        roughness 0.000000
    }
}

The two lines above are what we need to change slightly. First of all we need to set the interpolation to 0. Why? Well because we are using an index colour image and with interpolation, even though the blue parts will be transparent, the filtering will leave a nasty blue edge to everything. Turning interpolation off solves this.

The next stage is to add an extra line which tells us what colour in the image in transparent and by how much. In our case we're using a 256 colour image and its the last colour in the palette that we want transparent.

Now, in colour terms, the palette starts at colour 0 and ends at 255, not 256. Also, POV-Ray uses values from 0 (opaque) to 1 (transparent) to set transparency. So, out edited material in our include file would look like:

// Begin Textures Definitions

// Material: "Material04"
#declare uvtexture_0 = texture{
    uv_mapping pigment{
        image_map{
            sys ".\bush_test.bmp"
            map_type 0
            interpolate 0
            transmit all 0.000000
            transmit 255 1

        }
    }
    finish{
        ambient rgb <0.200000 0.200000 0.200000>
        specular 0.000000
        roughness 0.000000
    }
}

The reason we leave the first transmit line alone is because this controls the overall transparency of the section of our model.

Hopefully if everything went well, your render should now have all the right transparency:

Conclusion

Well there you go, thats a simple tutorial on how to use my Milkshape plug-in and POV-Ray to make reasonable renders of your models. Theres lots more you can do with POV-Ray so dont be afraid to experiment. If you find any other cool settings or tricks please feel free to pass them on to me. Happy rendering! :)

- Jed

>>Index