Tutorial:MapWithPOVRay(Tinnut): Difference between revisions

From Spring
Jump to navigationJump to search
Tinnut (talk | contribs)
New page: == Howto: 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. !! Povray is available for both Wi...
 
Tinnut (talk | contribs)
Line 4: Line 4:
!! This is currently a work in progress and make take some time to complete. !!
!! This is currently a work in progress and make take some time to complete. !!


=== Intro ===
This guide will take you through creating a Spring map's texture using the freeware Povray program.  It 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 so in theory these steps should work for both systems.
Povray is available for both Windows and Linux.  I have only tested these steps under Windows, but they should work under Linux.


=== Initial Steps ===
1) Download and install Povray: [http://www.povray.org/ Povray Site]
1) Download and install Povray: [http://www.povray.org/ Povray Site]


Line 29: Line 31:
5.2) Higher elevations:
5.2) Higher elevations:


6)
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:
 
 
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)
9.2)
 
10) Restart Povray
 
11) Select your new reder size Click Render
 
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)
 
13) Do all the other map stuff: metal placement bitmap, feature placement bitmap, smd file
 
14) Compile your map with mapconv
 
15) Test it :)
 
== Advanced stuff ==
Check out your help file that came with Povray.  There is a LOT that you can do!
 
=== Complex Texture Map Combinations ===
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.
 
=== Procedural Textures ===
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.  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 [http://geomorph.sourceforge.net/povray/en/Geomorph%20-%20Predefined%20Povray%20Scripts.html Geomorph website].
 
=== Placing Metal 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:
<pre>
  #declare getMetal = function {
    pigment {
      image_map {
        png "metallocations.png"
      }
      scale <1,-1,1>
    }
  }
</pre>
 
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):
<pre>
// A simple brownish texture
#declare dirt_Texture=
texture {
  pigment { rgb <0.75,0.55,0.35>*0.7 }
  normal {
    granite 0.5  // for use with normal{} (0...1 or more)
    //scale MAP_WIDTH
  }
  finish {
    ambient 0.5
    diffuse .9
  }
}
 
// A shiny metalish texture
#declare metal_TextureBase =
texture {
  pigment {
    rgb<1,1,1>   
  }
  normal {
      granite 0.9  // for use with normal{} (0...1 or more)
    scale 80/5
  }
  finish {
    ambient 0.6
    brilliance 4
    diffuse 1
    specular 0.90
    roughness 1/80
  }
}
 
// A combination of the metal_TextureBase, the dirt_Texture and the Transparent_Texture
#declare metal_Texture=
texture {
  bozo              // very smooth, random noise function
  turbulence 0.3  // turbulence often useful
 
  texture_map {
    [0.0  metal_TextureBase]  //T_Silver_3B
    [0.42  metal_TextureBase]
    [0.47  dirt_Texture]
    [0.50  dirt_Texture]
    [0.55  Transparent_Texture]
    [1.0  Transparent_Texture]
  }
  //scale <16, 16, 16> //even
  scale <7, 32, 16> //stretched
  rotate z*40  //set it at an angle so it looks betterer ;)
}
 
#declare blob_Texture=
texture {
  slope { z, 0.0, 0.5 }
  texture_map {
    [0.0  Transparent_Texture]
    [0.6  Transparent_Texture]
    [1.0  metal_Texture]
  }
} 
</pre>
 
3) Finally, we define a "blob" object that adds a sphere object to the master blob object for each point in the metal map:
{| class="wikitable" style="font-style:italic; font-size:120%; border:1px dashed red;background-color:white"
|
<pre>  #declare metalBlob=
  blob {
  #declare geos=0;
  #declare ix=4.0;
  #declare num=0;
  #while (ix < MAP_WIDTH)
    #declare iy=0.0;
    #while (iy < MAP_WIDTH)
      #declare metal=getMetal(ix/MAP_WIDTH, iy/MAP_WIDTH, 0);
      #if (metal.red)
        #declare Pos = trace(primaryHF,<ix-MAP_WIDTH/2, -iy+MAP_WIDTH/2, MAP_ELEVATION*2>,-z);
        sphere {
            //Pos-<0,0,5>, 8*6, 8 
            Pos-<0,0,5>, 8*2, 8 
        }
      #end
      #declare iy=iy+8;
    #end
    #declare ix=ix+8;
  #end
 
    texture {
      blob_Texture
    }
    scale <1,1,0.5> 
  }  //metalBlob
 
  object {metalBlob}</pre>
|}
This all adds some time to the rendering time, but seems to work well enough (although it could be nicer).
 
{| class="wikitable" style="font-style:italic; font-size:120%; border:3px dashed red;background-color:white"
|+Multiplication table
|-
! &times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
 
http://meta.wikimedia.org/wiki/Help:Table

Revision as of 07:12, 26 February 2008

Howto: 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. !!

Intro

This guide will take you through creating a Spring map's texture using the freeware Povray program. It 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.

Initial Steps

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). Here is the one we'll use for our map:


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):

4.2) Middle elevation (main map surface):

4.3) Highest elevation (mountains):

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:

5.2) Higher elevations:

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:


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) 9.2)

10) Restart Povray

11) Select your new reder size Click Render

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)

13) Do all the other map stuff: metal placement bitmap, feature placement bitmap, smd file

14) Compile your map with mapconv

15) Test it :)

Advanced stuff

Check out your help file that came with Povray. There is a LOT that you can do!

Complex Texture Map Combinations

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.

Procedural Textures

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. 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.

Placing Metal 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:

  #declare getMetal = function {
    pigment {
      image_map {
        png "metallocations.png"
      }
      scale <1,-1,1>
    }
  }

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):

// A simple brownish texture
#declare dirt_Texture=
texture {
  pigment { rgb <0.75,0.55,0.35>*0.7 }
  normal {
    granite 0.5  // for use with normal{} (0...1 or more)
    //scale MAP_WIDTH
  }
  finish {
    ambient 0.5
    diffuse .9
  }
}

// A shiny metalish texture
#declare metal_TextureBase = 
texture { 
  pigment {
    rgb<1,1,1>    
  }
  normal {
      granite 0.9  // for use with normal{} (0...1 or more)
    scale 80/5
  }
  finish {
    ambient 0.6
    brilliance 4
    diffuse 1
    specular 0.90
    roughness 1/80
  }
}

// A combination of the metal_TextureBase, the dirt_Texture and the Transparent_Texture
#declare metal_Texture=
texture {
  bozo              // very smooth, random noise function
  turbulence 0.3  // turbulence often useful

  texture_map {
    [0.0  metal_TextureBase]  //T_Silver_3B
    [0.42  metal_TextureBase]
    [0.47  dirt_Texture]
    [0.50  dirt_Texture]
    [0.55  Transparent_Texture]
    [1.0  Transparent_Texture]
  }
  //scale <16, 16, 16> //even
  scale <7, 32, 16> //stretched 
  rotate z*40  //set it at an angle so it looks betterer ;)
}

#declare blob_Texture=
texture {
  slope { z, 0.0, 0.5 }
  texture_map {
    [0.0  Transparent_Texture]
    [0.6  Transparent_Texture]
    [1.0  metal_Texture]
  }
}  

3) Finally, we define a "blob" object that adds a sphere object to the master blob object for each point in the metal map:

  #declare metalBlob=
  blob {
  #declare geos=0;
  #declare ix=4.0;
  #declare num=0;
  #while (ix < MAP_WIDTH)
    #declare iy=0.0;
    #while (iy < MAP_WIDTH)
      #declare metal=getMetal(ix/MAP_WIDTH, iy/MAP_WIDTH, 0);
      #if (metal.red)
        #declare Pos = trace(primaryHF,<ix-MAP_WIDTH/2, -iy+MAP_WIDTH/2, MAP_ELEVATION*2>,-z);
        sphere {
            //Pos-<0,0,5>, 8*6, 8  
            Pos-<0,0,5>, 8*2, 8  
        }
      #end 
      #declare iy=iy+8;
    #end
    #declare ix=ix+8;
  #end
  
    texture {
      blob_Texture
    }
    scale <1,1,0.5>  
  }  //metalBlob

  object {metalBlob}

This all adds some time to the rendering time, but seems to work well enough (although it could be nicer).

Multiplication table
× 1 2 3
1 1 2 3
2 2 4 6
3 3 6 9
4 4 8 12
5 5 10 15

http://meta.wikimedia.org/wiki/Help:Table