Forests in maya mental ray.


#221

JayHoo, how can you use paintGeometry to make the grass?, are all the patches of grass sharing the same mip_binaryProxy node?, or does every patch has one node?.


#222

As I wrote above the grass patch is made with paintfy and then converted to polygons.

I assigned copies of a cube to every vertex of the ground via the paintGeometryTool(from BonusTools). Then I had to assign the mip__binary_proxy node to every cube(I used a loop script for that). I used only one mip_binary_node. If you use 1000 different nodes the memory saving effect were not taken into account.

Every geometry is loaded into the scene via the binary proxy node.

Animation could work with ncloth. There is a falling leaves example in the docs.

The grass tooks a lot of the rendertimes and the trees had to render transparency and translucency. This is really time consuming.


#223

try to deactivate the construction history and set the undo feature to off.


#224

what cpu are you ussing?? and the OS??

if you have your Shadow method set to segments change it to simple, and set the reflections to 1.


#225

I had a 3 gh quad core amd phenom2 and vista 64bit.

I can try your hints. It really needs some optimizations.


#226

Jayhoo, mip_binaryProxy only renders 9 proxies at render time if you use BSP2 (wich is the one taking the advantages of that proxies BTW, tell me if I’m wrong), so no way to render that amount of patches of grass in an efficient manner?.


#227

Hm… The grass uses one mip_binary and is used in maybe 1000 cubes. I have 3 different trees in the scene. One tree uses 10 mip_binary proxies. I tried earlier rendering 10000 Trees and it work. I have not seen any restictions.


#228

Have you tried this tool?

http://www.creativecrash.com/maya/downloads/scripts-plugins/rendering/misc/c/sppaint3d

You can assign multiple objects to spread around and it doesn’t rely on UV mapping or verts. :wink:


#229

Looks quite useful.


#230

Tried it, but still my computer completely freeze after some hours :frowning:


#231

i have change the script to show what it’s doing

i have tested it with a 160.000 polys for the leaves, 4 quad for each leaf, it has taked about an hour to do the process.

first of all, turn on Heads up display -> current frame. I use the current frame number to create a countdown display, each frame is a leaf.
turn the current view into smooth shaded (i have randomized the color of the leafs, in the perspective view you will see how the leaves change theirs colors)
if they are pfx leafs you will need first to separate the leafs and combine again to get all the leafs in order. Delete the history

select one entire leaf in face selection mode and execute the script.

use the task manager to see if the memory ussage is growing up too much.

int $sys = 4;

if (`window -exists Div_Mesh`) 
  deleteUI Div_Mesh;


window -w 280 -h 600 -title "Dividir mesh" Div_Mesh; 
	columnLayout Ejes;

//Definir los ejes y la tolerancia

	frameLayout -w 285 -bs "etchedIn" -borderVisible true -labelVisible true -labelAlign "center" -marginWidth 5 -marginHeight 5 -label "Define arrangement" -cll true HPlace; 

	columnLayout;
	rowLayout -numberOfColumns 3 -columnWidth 1 100 -columnWidth 2 80 -columnWidth 3 80;
			
				text -l "Matrix:";
				radioCollection; 
				$Matr2 = `radioButton -sl -label "2x2"`; 
				$Matr3 = `radioButton -label "3x3"`;
				
	setParent -u;
//intSliderGrp -label "N. porciones" -field true -maxValue 10 -value 1 -cw 1 60 -cal 1 left -cw 2 50 Perc;

text -l "";

radioButton -edit -onCommand "$sys = 4" $Matr2; 
radioButton -edit -onCommand "$sys = 9" $Matr3;

string $botonaccion = `button -w 270 -h 20 -label "Process" proces`;



showWindow Div_Mesh;


button -edit -command "Seleccionar ($sys)" $botonaccion; 


global proc Seleccionar (int $typo) {

print $typo;
float $scaleuv, $moveuv;


	
string $Locator_nodes[] = `ls -sl -fl`;

int $leafF = size ($Locator_nodes);
print ("Numero de poligonos por hoja: " + $leafF + "
");

string $tokens[];
int $numTokens = `tokenize $Locator_nodes[0] "." $tokens`;

select -r $tokens[0];


int $totalf[] = `polyEvaluate -f`;

string $object;


ConvertSelectionToUVs;

if ($typo == 4){
	
	$scaleuv = 0.49;
	$moveuv = 0.25;
	
	}
	
if ($typo == 9){
	
	$scaleuv = 0.32;
	$moveuv = 0.3333333;
	
}

polyEditUV -pu 0.5 -pv 0.5 -su $scaleuv -sv $scaleuv ;	

for ($Sn= 0; $Sn <$typo; $Sn++){
	
	crearLambert ("lambert_" + $Sn);
	
	}



int $f = 0;

selectMode -component;

selectType -pf true;




int $totalF = $totalf[0]/$leafF;


int $time = $totalF;

currentTime $time;


for ($f=0; $f< $totalF; $f++)
{ 
	
	int $factor = (`rand 0 ($typo)`);
//    select -r ($Locator_nodes[0] + ".f[" + $f +"]");

		for ($fg=0; $fg < $leafF; $fg++){
	

		sets -e -forceElement ("lambert_" + $factor + "SG") ($tokens[0] + ".f[" + (($f * $leafF) + $fg) +"]");
	
		}


		
			$time--; 
    currentTime $time;

}
	
	for ($Sn= 0; $Sn <$typo; $Sn++){
		
		switch ($Sn){
			case 0:
				select -r ("lambert_" + $Sn + "SG");
				ConvertSelectionToUVs;
				
				if ($typo == 4){

					polyEditUV -u -0.25 -v -0.25 ;
					
				} else {
					
					polyEditUV -u -0.33333 -v -0.33333 ;
				}

			break;
			
			
			case 1:
				select -r ("lambert_" + $Sn + "SG");
				ConvertSelectionToUVs;
				
				if ($typo == 4){

					polyEditUV -u 0.25 -v -0.25 ;
					
				} else {
					
					polyEditUV -u 0 -v -0.33333 ;
				}

			break;
			
			case 2:
				select -r ("lambert_" + $Sn + "SG");
				ConvertSelectionToUVs;
				
				if ($typo == 4){

					polyEditUV -u 0.25 -v 0.25 ;
					
				} else {
					
					polyEditUV -u 0.33333 -v -0.33333 ;
				}

			break;
			
			case 3:
				select -r ("lambert_" + $Sn + "SG");
				ConvertSelectionToUVs;
				
				if ($typo == 4){

					polyEditUV -u -0.25 -v 0.25 ;
					
				} else {
					
					polyEditUV -u -0.33333 -v 0 ;
				}

			break;
			
			case 4:
				select -r ("lambert_" + $Sn + "SG");
				ConvertSelectionToUVs;
							
				polyEditUV -u 0 -v 0 ;


			break;
			
			case 5:
				select -r ("lambert_" + $Sn + "SG");
				ConvertSelectionToUVs;
							
				polyEditUV -u 0.33333 -v 0 ;


			break;
			
			case 6:
				select -r ("lambert_" + $Sn + "SG");
				ConvertSelectionToUVs;
							
				polyEditUV -u -0.33333 -v 0.33333 ;


			break;
			
			case 7:
				select -r ("lambert_" + $Sn + "SG");
				ConvertSelectionToUVs;
							
				polyEditUV -u 0 -v 0.33333 ;


			break;
			
			case 8:
				select -r ("lambert_" + $Sn + "SG");
				ConvertSelectionToUVs;
							
				polyEditUV -u 0.33333 -v 0.33333 ;


			break;
		
		
		
		}
		
		
	
	
	
	}
	
	
	

}

	

proc crearLambert (string $shaderName) 

{


	if (`objExists ($shaderName + "SG")` == 0){
	
		sets -renderable true -noSurfaceShader true -empty -name ($shaderName + "SG");


		shadingNode -asShader lambert - n $shaderName;
		
		float $R = (`rand 0 1`);
		float $G = (`rand 0 1`);
		float $B = (`rand 0 1`);
		
		setAttr ($shaderName + ".color") -type double3 $R $G $B ;
	

		connectAttr ($shaderName + ".outColor") ($shaderName + "SG.surfaceShader");
	
	}



}

#232

Jayhoo, I thought it was well stablished that, in order to take all the advantages of the proxies en MR (reading from disk instead of RAM and that sort of things) you had to use BSP2, and with that in mind, is not posible to render more than 9 proxies with the same mip_binaryProxy node…


#233

Strange, this is definitely not the case for me. I rendered maybe 1000 grass patches with the same mip_binary_proxy.

By the way I could reduce my rendertimes a lot. I optimized the Raytrace settings, and changed reflection to 1 for the grass. I used higher contrast settings 0.05 instead of 0.02. This was way to much.

edit: Forgot to mention the new rendetimes. :wip: Now I am at 3 hours.


#234

Hi InfernalDarkness, here you have the first results of my script:

The reasson to develop it is that ussually is a hard task to get a tree with a convincing trunk, or if you get these trunk, the branches are in other disposition that the one you need.

here is a nice trunk with a bad branch disposition, too much twigs, and very wide.

i have decided to keep only the trunk and the main branches and to create a new tree with these information. ussually it’s easy to prune the rest of the tree because the trunk and the main branches are a diferent geometry than the rest of the tree or it’s easy to select it.

after that i have use my script to create new branches with lower twig density and in a correct scale.

and also ussing the script, you can change the look of the tree:

here the interface (sorry it’s in spanglish):

now i’m developing the creation of the uvs and the leaves in a sky sensitive mode (almost done), the main problem is that it’s a MEL script, too slow (about an hour to complete the first tree)please, if someone has information about any tutorial to start with the Maya API… i would like to try to traslate it into a maya plugin and share it if somebody is interested.


#235

Amazing results, my friend. The script looks great so far; nobody’s expecting you to nail it perfectly so quickly. When you’re ready to share it I’d love to give it a whirl and possibly help with the plug-in-izing part of it? Or did you already post it earlier in this thread?

Looks very advanced, and very powerful.


#236

tankx Infernal, it has been easier than i thought. I have still not posted it, i have find a bug than i’m debugging now and i want to ad two more option to the branch generation, i hope to post it before christmas with a sample scene to play with it


#237

is this an onyx tree or self optimized. The branches looks really good. Especially it does not look like tubes sticked together.


#238

no, the first image is from a evermotion library tree, i have pruned ir manually to get the second image, the third and fourth are dones with a MEL script developed by me.

all the branches are dones in only one piece. the diferent levels will be selectables with selection sets.


#239

Wow! Super cool tostao_wayne! Those new branches look terrific.


#240

Hi tostao_wayne, I just dropped in today to this thread and I am quite impressed by your work. For a long time now I have been searching for a good tool to create some trees and I have a quite used some for several projects throughout of this year. Yet I haven’t found a good solution so that I already thought about writing a script myself but I didn’t have enough time yet to get started… (as always)
Really great work that you are doing there. Keep it up!

Cheers, Ingo