|
contact |
|
01. 912 . 272 . 2209
davekcw@yahoo.com.sg |
|
   |
|
|
|
Mel, Python and Renderman II - The weed generator
|
|
|
|
This project explores further the possibilities of RIB archives, by using python as a middle man to write data outside of Maya's limitations and generating procedural RIB archives. In this case, the subject of interest in procedural curves tapered to look like grass.
Notes!
This project may differ from the initial assignment writeup written for Professor Malcolm Kesson. It would have been edited to also reflect my later experiences, clearer tutorial techniques/codes and also later advancements made to the projects as well. |
| |
 |
| |
|
|
Introduction |
|
For this last and final assignment, I wish to explore the procedural power of using texture, light and rendering effects. In this concept, I will be using Maya to input layers such as fertility, water and light information onto a planar object, or any ground-like object with a RGB image map. Of which, the light information would be created via tracing 3d world light objects as they cast their rays onto their respective points on the "ground"
Using these information, Maya will procedurally create and grow plants on the plane. The lushness of the plants would depend greatly on how well the 3 channels mix together - is there sufficient water, nutrients and sun... So technically, I would expect to beable to grow an entire garden of plants just by simply putting a single seed onto the plane, while of course also expecting inter-reaction between the various plants as they grow to overshadow one another in competition of nutrients and resources. |
|
Let There Be Light...
What would a garden be if without light. By choosing to have a randomly generated garden, I would most definitely prefer to use more physically accurate information. Yes, by this I meant using actual lights in the scene. While in Maya, there are two known ways to this technique. One would be the Surface Luminance node (which is excessively heavy) and the more ellusive sampleCmd...
Unfortunately, this very code is also a key source of my problems. The flaw with Maya, as I see is - is the way many features though old and ancient since Maya 7.0, have not yet been implemented fully into the system. Autodesk itself do not provide the sampleCmd function as a plugin or API inbuilt into Maya, but as a uncompiled C++ Maya API. While compiling the elements should not be a general issue, the saddening fact however is that Maya's devkit items cannot be compiled by any other G++ application except .... and very specifically 4.1.20. Living in the era of Ubuntu 4.2.31, the older GNU has already seen the last ray of its light. Having spent an entire forthnight writing in C and trying to compile the code in Linux - battling the limitations that I do not own a copy of Renderman and yet do not have admin rights to extracts certain shared librarys and that even a self installed Ubuntu seemed to be missing the correct components, I decided to compile the code in Visual C of windows instead... However this also meant that I was unable to extract the compiled plugins for linux either. But I was able to bake/render a Vertex colored information from the code to use as a light map. |
|
 |
|
|

|
| |
Points on a Surface points on a Mesh goes Mashed...
Well, when it comes to positioning random surfaced on a geometry, everyone would say pointsOnSurface. Indeed, hands down this is the best technique. But we are advancing into an era where nurbs are quickly being replaced by the functionality of the polygon and the SubDs. My project was one such intention as well... considering that I have had sculpted the "heroic" ground plane for this project's demostration in Mudbox - Yes! a polygon.
So we come back to the topic of Maya's ancient plugins and uncompiled coding once again... and this time it is with the pointsOnMesh command! Well don't get deceived by the little thing. While it seemingly works like the pointsOnSurface, it is not the same! Due to the lack of proper documentation on things Maya claims to have but not yet bothered to implement, I later realized that the pointsOnMesh command actually runs with an additional flag... and that is the face number...
In case anyone is wondering, the Us and the Vs in the pointsOnMesh command is a lie!! Just like how vectors or XYZ is often mingled with the colors of RGB, the U and the Vs in the pointsOfMesh command merely refers to the surface of a face... meaning a 0.5 and 0.5 on face 1 merely refers to the position directly in the very middle of the surface area... you won't find any UV references there to extract any color images later on...
So how did I solve my problem? I merely wrote a little overwrite on my code. By projecting my objects on a planar nurbs, I was able to project my weeds onto the actualy polygonal geometry using constraints... There and my problem was solved.
|
|
 |
|
| |
The Inception...
Finally, back to the code! While I do intend to create some eye candy out of this script, my most important reason behind it is in its application and experimentation. The concept of the code itself goes as this - Firstly, the script places proxies upon the surface of the supposed target "ground". This proxies extracts the information such as the material coordinates of UVs and the cartesian coordinates of their relative points. Using these proxies and connected mediums to control the results of my renders, these proxies calls out Pre-Shape Mel commands which evalutes their conditions with relationship based on the positioning, controlmap, lightmap, watermap and fertilitymap to generate weeds from the 3 classes - Grass,Weed and Shrubs.
An example of the entire interface can be seen below:- |
| |
 |
|
 |
|
Hopefully not confusing anyone... There is indeed a massive level of adjustments in the script that I have forseen. As a randomly simulated item, seed values are definitely important, they together with the 4 controlling bitmaps are the key factors towards the structure of the code.
The remaining values are fine tuning variables. The determine the optimal conditions for Grass, Weed and Shrubs to grow in relationship to the Lightmap, Watermap , Fertility levels and also how much tolerance they would have before totally dying out should the conditions be close, but not near optimal.
Other functions included are of course a generic world scalar function, mutipoints to spawn mutiple series of weeds on a single vertex and of couse the conditions to determine the object colors and all of their variating factors With those finely tuned, we can see the examples listed below...
|
|
| |

 |
| |
 |
| |
And then came the Eye Candy...
With all these tests and neats things in place after a extremely short dateline to produce something presentable, I have finally taken my Mudbox polygon (seen below) and rendered it in Renderman with the Weed Garden script and viola! |
| |

|
| |
 |
| |
and some additional research photography performed during the exercise... |
| |
 |
| |
|
|
|