New command line program to create Terrain textures

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
uzik
Goblin
Posts: 202
Joined: Sun Feb 25, 2007 1:45 am
Location: USA
x 6

New command line program to create Terrain textures

Post by uzik »

While working on my project I started putting together textures for the new terrain system and didn't find a method of producing the texture files that I liked.

I've put together a makefile that automates the process of taking four regular single image maps and creates two composite maps used by the texture component. I'm releasing the makefile to the public domain in the hope it is useful and that others will be able to improve on it.

It uses the NetPBM utilities:
Description here: http://en.wikipedia.org/wiki/Netpbm
Project page here: http://netpbm.sourceforge.net/

The pamrgbatopng program seems not to be included in the mingw(windows) port or the Ubuntu Linux package.
I can provide it if you want a pre-compiled elf Linux version. Alternately you can build it from the netpbm sources or get an rpm.

Here's the makefile:

Code: Select all

# makefile for ogre new terrain component textures.
#
# The makefile will attempt to convert separate input image files to a combined ogre compatible format.
# The layer 0 image will be "AlbedoSpecular.png"
# The layer 1 image will be "HeightNormal.png"
#
# Usage:
#  You must provide:
#   An image file with a prefix of 'Height' for the Height map.
#   An image file with a prefix of 'Normal' for the Normal map.
#   An image file with a prefix of 'Albedo' for the Albedo(diffuse) map.
#   An image file with a prefix of 'Specular' for the Specular map.
#
# It is assumed the file names have the correct extension.
# With this version of makefile acceptable formats are:  bmp, jpg, and png.
# It should be simple to accept most other formats.
#
# Run the makefile by issuing the following from your command line or from your build manager:
#   make -f ogre.texture.makefile
#
# Requirements:
#  A standard 'make' program (I believe gnu make and microsoft nmake work)
#  The Netpbm tools for graphics conversions and manipulation into standard ogre format.
#   You can get netpbm free for most environments here: http://netpbm.sourceforge.net
#   or by using your package manager on linux.
#
#  If you're planning on using paging for the terrain you may find the program 'pamdice'
#  in the netpbm package useful. It cuts a single large image into a grid of images. This
#  would be perfect for creating the individual page images.
#
# The final output file:
#  You can use either tga or png format files. The makefile is currently set for png output. See below if you need to change it
#
#  The pamrgbatopng program seems not to be included in the mingw port or the Ubuntu Linux package.
#   I can provide it if you want a pre-compiled elf Linux version.
#
# written by Jay Sprenkle  jsprenkle @ gmail.com  2011-08-08
# I release this file to the public domain. There is no implied or overt warranty.

# implicit rules for conversions

%.ppm : %.bmp
        bmptopnm $< > $@

%.ppm : %.png
        pngtopnm $< > $@

%.pgm : %.ppm
        ppmtopgm $< > $@

%.tga : %.pam
        pamtotga -norle -rgb $< > $@

%.png : %.pam
        pamrgbatopng $< > $@

%.ppm : %.jpg
        jpegtopnm $< > $@

%.ppm : %.jpeg
        jpegtopnm $< > $@

# make all targets by default
#  If you have pamtotga on your system you can switch to tga format by changing the 'png' to 'tga' on the line below.
all: HeightNormal.png AlbedoSpecular.png

clean:
        rm HeightNormal.pam AlbedoSpecular.pam Albedo.ppm Specular.pgm Height.ppm Normal.pgm

# layer 0: combined Albedo and Specular map
AlbedoSpecular.png: AlbedoSpecular.pam

AlbedoSpecular.pam: Albedo.ppm Specular.pgm
        pamstack -tupletype=RGB_ALPHA Albedo.ppm Specular.pgm > $@

# layer 1: combined Height and Normal map
HeightNormal.png: HeightNormal.pam

HeightNormal.pam: Height.ppm Normal.pgm
        pamstack -tupletype=RGB_ALPHA Height.ppm Normal.pgm > $@

---A dream doesn't become reality through magic; it takes sweat, determination and hard work.
User avatar
Jabberwocky
OGRE Moderator
OGRE Moderator
Posts: 2819
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada
x 218

Re: New command line program to create Terrain textures

Post by Jabberwocky »

Nice of you to share.
Image
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Re: New command line program to create Terrain textures

Post by jacmoe »

Really, really awesome! :)
Now we have a command-line option for terrain textures on *nix.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
zarlox
Halfling
Posts: 70
Joined: Tue Apr 19, 2011 12:32 am
Location: Canada
x 2

Re: New command line program to create Terrain textures

Post by zarlox »

Good job and thank you for sharing. That will make the process of creating textures maps less painful