PapaBlueMarlin opened this issue on Aug 18, 2006 · 87 posts
Dead_Reckoning posted Sat, 26 August 2006 at 6:37 AM
The attached Script Works Fine.
When I change this:
def ApplyBruise(s, cx, cy, br, maxblend):
To this:
def ApplyBruisePair(s, cx, cy, br, maxblend):
ApplyBruise(s, cx, cy, br, maxblend)
ApplyBruise(s, cx, cy, br, maxblend)
or this:
def ApplyBruisePair(s, cx, cy, br, separation, maxblend):
ApplyBruise(s, cx - separation/2, cy, br, maxblend)
ApplyBruise(s, cx + separation/2, cy, br, maxblend)
or this:
def ApplyBruisePair(s, cx, cy, br, separation, maxblend, graniteamount):
ApplyBruise(s, cx - separation/2, cy, br, maxblend, graniteamount)
ApplyBruise(s, cx + separation/2, cy, br, maxblend, graniteamount)
I get the following Error Message
----- MATMATIC COMPILER -----
verbose 1
Warning: config scan dir not found: Runtime:Libraries:pose:MatmaticDemos
Processing script C:Program FilesCurious LabsPoser 6RuntimeLibrariesmaterialsMatmaticDemosRDNABruisesJames2Bruise.mm1.txt -> material
MATMATIC Script Error: invalid syntax (line 190)
Traceback (most recent call last):
File "C:Program FilesCurious LabsPoser 5RuntimePythonmatmaticcompiler.py", line 232, in processScript
File "
x = U - cx
^
!! Matmatic stopping because of error !!
------ MATMATIC COMPILER DONE ----
Cheers
DR
Quote - Ah now I understand.
You tried to add it to this:
ApplyBruise(c.Head, Add(.4).labelled("PM:Bruise U"), Add(.525).labelled("PM:Bruise V"),
Add(.07).labelled("PM:Bruise R"), Add(0).labelled("PM:Bruise Blend"),
)This is the invocation of the "ApplyBruise" function that I made for that script. You are trying to pass an extra argument, but there is no parameter in the function declaration to receive it. Have I overwhelmed you with computer jargon? I tried to covere this in the manual where I "gently" introduce you to Python.
We can do one of two things:
Add a parameter to the ApplyBruise function, so you can pass the argument.
Just forget about the parameter - build it into the function automatically.
The latter is quicker, but less flexible. It all depends on how you want to use the function and the resulting shader.
To add a parameter to the function we could do this:
def ApplyBruise(s, cx, cy, br, maxblend, graniteamount):
Then inside we have to figure out how to use the graniteamount value.
To my mind a very simple way is to just use it to blend between two alternatives. We just need to change one line - the place where you create the granite:
myGraniteNode = Blend(WHITE, Granite(myNoiseNode), graniteamount)
Blend takes two values and blends them using the third. It will generate a Blender node, most of the time. However, if Matmatic sees that graniteamount is always 0, it will skip the blend and just use WHITE. And later when you multiply bruiseclr * WHITE, it will reduce that to bruiseclr. In other words, when you turn things off, Matmatic will optimize away crap you don't use in the shader. Cool huh?
If you pass an Add node for the argument to graniteamount, then Matmatic can see that it is not constant - it can change. So it will produce the Blender node and wire it in.
Now you can add the additional PM value to the invocation with all the others.
Now for the coolest part. Because we wrote the ApplyBruise function in such a way that it just adds some more stuff to the Alternate_Diffuse shader tree, you can call it MORE THAN ONCE!
For example, if you want a matched pair of bruises separated by some distance, you could make yet another function:
def ApplyBruisePair(s, cx, cy, br, separation, maxblend, graniteamount):
ApplyBruise(s, cx - separation/2, cy, br, maxblend, graniteamount)
ApplyBruise(s, cx + separation/2, cy, br, maxblend, graniteamount)Then change your call at the bottom from ApplyBruise to ApplyBruisePair and add another argument for the separation parameter, which you probably want to be a PM value.
"That government is
best which governs the least, because its people discipline
themselves."
Thomas Jefferson