| click to enlarge the image |
 |
 |
 |
 |
 |
 |
|
 |
|
Terrain Generator: In Maya, I wanted a way to generate fractal terrain for rendering
fantasy environments. A high level of art directability was required for my project so I created a special pipeline just for it. I create
a shader in slim that uses fractals, and then from this I create a texture and create a hight field to build up a mesh, just like terrain.
The complete program is here, it uses both Mel and traditional C programming. Why both Mel nd C? Read below to find out!
bb_TerrainMakerGUI
|
|
 |
First, I just make a fractal texture like this one in SLIM. Its a combination of fractal noises, and I make sure to keep it
in grey scale because this is what I use to generate a height field. Dark is low, and white is higher elevations. This is a classic problem
in real time graphics, but not so common in Maya for a few reasons, mainly, what kind of image to use and how to read it in Mel? I chose PPM
since that is most familiar to me, but you could have chosen any I think!
|
|
 |
Now I have to figure out a way to get this height map read into Maya. The idea is to make a Mel GUI that
reads in this fractal image and computes a mesh from it. Everything was pretty straight forward until I
had to interprete a PPM character. Mel is unable (to my knowledge) to read in a character and do a binary shift, and
this is what I needed in order to interpret a hight value from the pixel. At least the GUI worked! But this made
things complicated.
|
|
 |
After a few hours of searching the net for a Mel or Python scriptable bit shift, I was out of luck. Only the shell could do it, or a real program.
Therefore I utilized Mel's popen() command, which theoretically would allowe me to open a pipe and get output from a C program.
Here is the Mel code that allowed me to do this!
|
|
 |
The real fun began with the C program that read in the PPM. For each pixel, do a binary shift, compute a hight value, and send back to Mel.
Mel has an array that is taking in my height values. The same indexing works for both the mesh buildign and pixel reading, so PPM was
a great choice of a image format!
|
|
 |
So now that I have a mesh to work with, I output an obj from Maya and fire up ZBrush. In Zbrush I flattened out an area that I wanted to represent a as
path using the Smooth tool. When everything looked ok I started painting using some of the default brushes. In here I defined my UVs and spat out a couple of textures.
|
|
 |
Back in Maya I opened up SLIM and created a new Layered shader using my new texture maps and the original fractal above. Now its render time!
|
|
|
|