Repository navigation
Tutorial%3AMapWithPOVRay(Tinnut)
Development < Map Development <
Create a map's texture using Povray to generate the texture
!! This is currently a work in progress and make take some time to complete. !!
This guide will take you through creating a texture for a Spring map using the freeware Povray program. Povray is an excellent raytracing application that generates "scene" images using a scene definition language in a text file. We can use it to create a map's texture by creating a heightfield object, putting our "camera" directly over the object, setting the camera to orthographic, and rendering a bitmap at our map's dimension. The steps below will give you an easy enough to follow process to generate a nice map, but if you want to create different maps you'll need to learn Povray's scene definition language. This language is easy enough to follow, but depending on your tastes you could be better off using a tool that specialises in maps and map textures, such as the excellent L3DT.
The guide does not cover other aspects of map creation (heighmaps, features, metal, compiling, etc), but there are a few excellent guides within the Wiki that already cover those steps.
Povray is available for both Windows and Linux. I have only tested these steps under Windows, but they should work under Linux.
Please note that a lot of the maths used in the scene definition file has only been tested on a 16x16 map (8192x8192 pixels).
Warning: The base textures I use in this example are all mostly rubbish that I created in a couple of minutes. I would suggest that you do not use them in your own maps :)
1) Download and install Povray: Povray Site
2) Create a working folder for your map, for this example, we'll make C:\PovMap
3) Create a heightmap using whatever program (I like The GIMP, which is good, and it's free). Here is the one we'll use for our map (I created this in a hurry and it was quite a mistake that it ended up so similar to Altered Divide):
http://img441.imageshack.us/img441/8862/povmapheightbp9.th.png
Your map will need to be named povmap_height.png, but if you want to use another name, just update the pov script below to use your heightmap's actual name.
4) For our example, we'll be defining three different elevation levels for which there are different terrain textures, these will be (each at 512x512):
4.1) Lowest elevation (low lying areas):
http://img176.imageshack.us/img176/953/level1zd7.th.png
4.2) Middle elevation (main map surface):
http://img170.imageshack.us/img170/6473/level2pf6.th.png
4.3) Highest elevation (mountains):
http://img176.imageshack.us/img176/6159/level3wv7.th.png
5) Now also for our example, we'll be defining two different textures to be used by sloping areas, one for slopes in the lower elevation areas of the map, and another for slopes in the higher elevations:
5.1) Lower elevations:
http://img411.imageshack.us/img411/2153/slope1on6.th.png
5.2) Higher elevations:
http://img411.imageshack.us/img411/8908/slope2fk7.th.png
6) Create an empty text file in your C:\Povmap folder named gen_pov_texture.pov
7) Copy the following povray scene code into the above file:
|
What we're essentially doing above is:
- Setting up scene parameters: lighting, the orthographic camera, etc.
- Defining a set of textures to display at different elevations and different slopes; and
- Defining a heightmap that uses our png image and applies our texture to this object
8) Double click on your gen_pov_texture.pov file so that it opens up in Povray.
9) Add a new render size (8192 x 8192):
9.1) Drop down menu "Render" > "Edit Settings/Render" > Click "Edit" button
9.2) Add text at bottom of file:
|
9.3) Save file
10) Restart Povray so that it re-reads the ini-file
11) Select your new render size and click Render. This creates a bitmap file: gen_pov_texture.bmp
12) Convert to gen_pov_texture.bmp to a png file if you're using the new mapconv (it doesn't seem to like bitmaps). I personally use imagemagick to do this as it has a simple command line program "convert.exe" that will convert an image from one format to another and it works well with the very large bitmap image that comes out of the above steps.
13) Do all the other map stuff: metal placement bitmap, feature placement bitmap, smd file
14) Compile your map with mapconv
15) Test it :)
Check out your help file that came with Povray. There is a LOT that you can do!
As you can see from the pov code above, a "texture" declaration can be an image (called an "image_map"), but it can also be a definition of a blend between any number of earlier defined textures (called a "texture_map"), which is based on a function. In the above example, it uses the "gradient" function for changes in elevation, and the "slope" function for changes in slope. It is possible to define much more complex sets of textures than those defined above, such as mixing different combination of slope mapings with combinations of elevation mapings.
Our blend function could actually be an image if you wanted finer control of a map's texture, by having sections of metal mixed with sections of wilderness, for example. To do this, you would:
1) Create a new png image the same size as your heightmap (although you could make it larger or smaller) and paint sections of the map that are to use your wilderness textures in white, and the sections that are to use your metal texture in black. For effect you could do a slight blur on the image to create grey coloured transitions where the two sections meet. For our example I created this:
http://img185.imageshack.us/img185/2641/texturedistributionpa8.th.png
3) Change the "final_texture" texture name in your script to "final_nature_texture"
4) Define a set of textures in a similar manner that define your metal textures (based on heights and slopes), with the final blended metal texture named "final_metal_texture". Don't forget to give them different names than the wilderness texture names are.
5) Create a new "final_texture" that is:
|
Here is a screen shot of our map using this:
http://img341.imageshack.us/img341/43/screen000wd0.th.png
It is also possible to use "procedural textures" instead of image_map textures. These can be quite useful for areas on your map that have a high slope as they can create a better looking texture, including effects such as the layered rock textures - like "Painted Rock". Unfortunately these types of textures can result in larger map sizes, but if you just use them on the high slope areas of your map it should not be too bad.
Some good examples used in terrains can be found at the Geomorph website.
The povray install also includes a number of nice example procedural textures.
There are quite a few posible ways to have Povray place metal textures for you. One approach that I have used is:
1) Define a function that will return the current metal locations in a pov kind of way:
|
This function, when called for a given coordinate (0 to 1), returns a vector of the three colours for that point.
2) We now define a texture that we'll use for our metal (this is made up of a number of subcomponent textures):
|
3) Finally, we define a "blob" object that adds a sphere object to the master blob object for each point in the metal map:
|
This all adds some time to the rendering time, but seems to work well enough (although it could be nicer).
Category:Tutorial Category: Map_making