PDA

View Full Version : Mel to selectively polysmooth by certain amounts automatically on rendering?


Unkle Bunkle
04-13-2006, 10:56 AM
Not using renderman, I was wondering is there a way to choose certain objects and have them display
in the viewport at normal res then at render time have these objects automatically have a polysmooth of
a certain value of divisions applied to them, relative to the cameras distance from them.

I know of the ability to run pre-render mel scripts. So I guess you could apply a polySmooth to
all desired objects, and then disable their node state with HasNoEffect. The in the pre-render mel
you could get a list of all polySmooth nodes, and turn them on.
Then simply turn them off in the pos-render mel.

I know you can do it but have no mel experience, has anyone written something similar to this,
or could knock up a quick one?

I'm not too worried about the distance from the camera effecting the
smoothing, more that I can just have my selected objects switch to their smooth version automatically
when I test render.

Thanks in advance.

wdavidlewis
04-13-2006, 07:48 PM
Here's a somewhat boiled down version of something I wrote for a student production about a year and a half ago. It doesn't look too atrocious at this point.

It basically checks to see if a smooth is in the history stack and calls polySmooth if it isn't. You'll want to repeat the smoothing for each bit of geomtry, and you'll probably want to tweak the call to poly smooth.


proc int
wdlHasBeenSmoothed(string $mesh) {
string $history[] = `listHistory $mesh`;
for ($op in $history) {
if (`gmatch $op "polySmoothFace*"`) {
return 1;
}
}
return 0;
}
global proc
wdlSmoothModels() {
/* Repeat for each piece of geometry you want to smooth */
string $mesh = "Sixty|MDL_Clothing";
if (!wdlHasBeenSmoothed($mesh)) {
print ("Smoothing " + $mesh + "\n");
polySmooth -mth 0 -dv 1 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $mesh;
}
}



Hope that helps!

--- David

CGTalk Moderation
04-13-2006, 07:48 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.