Xgen and LOD just doesn't work

Xgen and LOD just doesn't work

Anonymous
Not applicable
3,346 Views
13 Replies
Message 1 of 14

Xgen and LOD just doesn't work

Anonymous
Not applicable

I've been using XGen to build a forest scene with loads of trees. In an attempt to speed up the rendering I figured it would be good to set up some lower res geometry for the further away trees.

With a bit of messing about I managed to export a tree archive with med and lo versions. This all works nicely in a simple Xgen scene - I can see the level of detail change in the viewport when I change the Medium and Low Distance sliders.

The problem comes with rendering - I only get the High trees at render time. I've tried bringing the distance right down so that I am seeing only low trees in the viewport, but its still rendering the high ones!

I'm using VRay, but the same thing happens with MR. Doesn't really make sense.

 

I've tried again with the simplest of scenes - a different primative shape for each LOD so that I can see for sure if it is working. It's working fine in the viewport, but I am only getting the high object in the render (see below).

 

xgen_lod.jpg

 

Any help would be much appreciated, thanks.

0 Likes
Accepted solutions (1)
3,347 Views
13 Replies
Replies (13)
Message 2 of 14

Anonymous
Not applicable

I have been running into the exact same issue. Maya 2016 SP5. I am using Arnold for render but I get the same problem with MR. I've spent many hours playing with settings, different archives, expressions, etc with no success. I reverted to trying a test, strangely similar to yours before coming here to make a post, haha.

 

In Arnold it defaults to the Lo Index for the render for some reason. The only way I have found to fix this is modify the Med and Lo index expression in the advanced tab. Ex: Change "$aIndex*$aMul + 2 + 3" to "$aIndex*$aMul + 0 + 3". This works as a hack for selecting what gets rendered. I have found no solution for the LOD to actually work as expected. Hopefully someone has a solution.

 

Capture.JPG

Message 3 of 14

Anonymous
Not applicable

I'm not sure if this is related. But I was checking the arhive.log file. This error appears just before [0.00%] processing of each LOD.

 

Error: file: C:/Program Files/Autodesk/Maya2016/plug-ins/xgen/scripts/xgen.mel line 612: AttributeError: file <maya console> line 1: 'NoneType' object has no attribute 'tracking'
Error: file: C:/Program Files/Autodesk/Maya2016/plug-ins/xgen/scripts/xgen.mel line 575: AttributeError: file <maya console> line 1: 'NoneType' object has no attribute 'tracking'

 

All of the files seem to generate properly in the archives.

0 Likes
Message 4 of 14

Anonymous
Not applicable
Accepted solution

I've got it working now. You were almost there with your expressions, you just needed to use the "$aLOD" variable.

 

So all three of the Hi/Mid/Lo index values should read:

"$aIndex*$aMul + $aLOD + 3"

 

I realised it's also useful to play with the proxy index. With this you can choose which objects show up in the viewport. So if you're running a bit slow, you can switch them all to medium with:

"$aIndex*$aMul + 1"

or low with:

"$aIndex*$aMul + 2"

 

You could even just skip the high and show the medium and low by clamping the LOD:

"$aIndex*$aMul + clamp($aLOD,1,2)"

Message 5 of 14

Anonymous
Not applicable

Brilliant. Thanks for that! It's working as expected for me now. I wish there was more documentation about some fo the expressions in XGen. Particularly regarding LOD. Many variables are not even mentioned.

 

I was using the trick to modify the index "$aIndex*$aMul + 1", "$aIndex*$aMul + 2", which was useful for rendering at lower detail previews. But now I can do both and have LOD! 🙂

0 Likes
Message 6 of 14

Anonymous
Not applicable

Having got this working, I'm still having issues with it and VRay, which is still just rendering the High geometry. 

 

Perhaps I should be asking this on the chaos group forum instead, but does anybody have any ideas about what might be going on? 

0 Likes
Message 7 of 14

Anonymous
Not applicable

I'm using Arnold and it does render all the LOD's correctly now if I change the expression. As for Vray I'm not much help.

 

Can you cull primitives outside the camera frustrum? The reason I ask is that it might be related. Arnold had an update recently that fixed XGen passing camera information to the render. Before the Arnold update it would cull in like a top down dial 0-360 degrees not based on the camera. Once they fixed that I assumed it would also fix LOD since it's also camera related. No dice until now.

 

Not much help but maybe it will give you some ideas to look into.

0 Likes
Message 8 of 14

Anonymous
Not applicable

By the way. I liked your expression for clamping "$aIndex*$aMul + clamp($aLOD,1,2)". I'm using that for the Proxy Index, so the viewport only shows med and lo while the render uses all levels.

0 Likes
Message 9 of 14

Anonymous
Not applicable

If you like that, I found it even more useful to attach the proxy index to a simple slider. Try pasting this in.

 

$level = 1;#0,2

$aIndex*$aMul + clamp($aLOD,(2-$level),2)

 

Sill no idea how to get this going in VRay though Smiley Frustrated ...

Message 10 of 14

Anonymous
Not applicable
Actually, it turns out that LOD has just not been implemented into VRay yet (v3.1), just in case anyone else is interested in this.
0 Likes
Message 11 of 14

Anonymous
Not applicable

Nice expression. Love the slider for proxy. Sorry about VRay, I suspected it may not be implemented.

 

On a different subject, since we are both working with populating forests. I have been trying to come up with an expression to limit the primitive generation based on the upward facing portions of the base geometry. So for example on a detailed rock, I want to limit population in areas where things would grow (mostly upward facing). My hope was to have a vector with a slider range that I could multiply against the PTex map in the density field. I'm an amateur at scripting. I tried working with the nVectorMask expression in the samples with no luck:

 

$xAxis =0.000;#-1.000,1.000
$yAxis =0.000;#-1.000,1.000
$zAxis =0.000;#-1.000,1.000

expand( ((($N[0]*0.5)+0.5)*$xAxis) + ((((1-$N[1])*0.5)+0.5)*$yAxis) + ((((1-$N[2])*0.5)+0.5)*$zAxis) , 0,1) - expand(abs($N[1]),0,1)

 

I know how to multiply the expression with a PTex map, but I can't get a working vector expression, or maybe more accurately a curvature type mask.

 

Anyway, just thought I would throw it out there if anyone has any ideas. I have just been relying on painting PTex maps for this but I would love a more effecient method.

0 Likes
Message 12 of 14

Anonymous
Not applicable

I figured that would be useful, so I quickly put together an expression to go into the mask attribute. I only tested it quickly on a sphere, but I think it should work for any object. It is based on the Y axis normal in world space.

 

You'll have 2 sliders:

Position moves the mask to include more or less of the sides.

Tightness changes the spread of the mask - think of it as the blurryness of the mask

 

Let me know if you need any of this explaining.

 

$position = 0.5000; #0.000,1.000

$tighness = 0.5000; #0.000,10.000

$surfNorm = $N;

$n = ($surfNorm[1]);

$a = $n + ($position-0.5)*2;

$a = $a*(1+$tighness)-($tighness/2);

$a = clamp($a,0,1);

$a

Message 13 of 14

Anonymous
Not applicable

Thank you! That is just what I was looking for. So far it's working very well with some dense geometry. I appreciate you taking the time. It also helps me understand a bit more about expressions in XGen. 😉

0 Likes
Message 14 of 14

Anonymous
Not applicable

Is there any documentation on all these variables? $aMul $aIndex $aLod

I searched the documentation and there is no mention of it anywhere.

Thanks

0 Likes