PDA

View Full Version : Scripted Operators --> bad performance ??


Helli
03-13-2005, 12:35 PM
Hi all

My question is again about scripted Operators.
Is it normal that they have really bad perforance or did I just do something wrong ??

The performance when using the script is only about 1/10 of the normal scene performance using no scripts.
So the whole idea behind is useless because no one wants to animate with a rig when he has to wait after moving the controlers for the rig Oo


Here is the script:
'----------------------Augen Direction steuern----------------------------
FaktorX = 600
FaktorY = 100

If controler_direction.value.posx <> "0" Or controler_direction.value.posy <> "0" Then
Select Case Out.Name
Case "Bone0_out"
Out.value.posx = Bone0.value.posx.value + controler_direction.value.posx.value/(FaktorX*0.8)
Out.value.posy = Bone0.value.posy.value + controler_direction.value.posy.value/(FaktorY)
Case "Bone1_out"
Out.value.posx = Bone1.value.posx.value + controler_direction.value.posx.value/(FaktorX*0.5)
Out.value.posy = Bone1.value.posy.value + controler_direction.value.posy.value/(FaktorY)
Case "Bone2_out"
Out.value.posx = Bone2.value.posx.value + controler_direction.value.posx.value/(FaktorX*0.3)
Out.value.posy = Bone2.value.posy.value + controler_direction.value.posy.value/(FaktorY)
Case "Bone3_out"
Out.value.posx = Bone3.value.posx.value + controler_direction.value.posx.value/(FaktorX*0.5)
Out.value.posy = Bone3.value.posy.value + controler_direction.value.posy.value/(FaktorY)
Case "Bone4_out"
Out.value.posx = Bone4.value.posx.value + controler_direction.value.posx.value/(FaktorX*0.8)
Out.value.posy = Bone4.value.posy.value + controler_direction.value.posy.value/(FaktorY)
Case "Bone5_out"
Out.value.posx = Bone5.value.posx.value + controler_direction.value.posx.value/(FaktorX*0.5)
Out.value.posy = Bone5.value.posy.value + controler_direction.value.posy.value/(FaktorY)
Case "Bone6_out"
Out.value.posx = Bone6.value.posx.value + controler_direction.value.posx.value/(FaktorX*0.3)
Out.value.posy = Bone6.value.posy.value + controler_direction.value.posy.value/(FaktorY)
Case "Bone7_out"
Out.value.posx = Bone7.value.posx.value + controler_direction.value.posx.value/(FaktorX*0.5)
Out.value.posy = Bone7.value.posy.value + controler_direction.value.posy.value/(FaktorY)
End Select

End if


'---------------------Lider steuern-----------------------------------
maxY = -4.8928

If controler_lider.value <> 0 then
Select Case Out.Name

'---Oberlid


Case "Bone1_out"
yDistanz = Bone1.value.posy.value - Bone7.value.posy.value
maxYoberlid = yDistanz * upper_lid_down
moveY = (maxYoberlid * (100/(maxY / controler_lider.value))/100)
out.value.posy = Bone1.value.posy.value - moveY
xDistanz = Bone7.value.posx.value - Bone1.value.posx.value
moveX = 0.5 * xDistanz * ((100/(maxY / controler_lider.value))/100)
out.value.posx = Bone1.value.posx.value + moveX

Case "Bone2_out"
yDistanz = Bone2.value.posy.value - Bone6.value.posy.value
maxYoberlid = yDistanz * upper_lid_down
moveY = (maxYoberlid * (100/(maxY / controler_lider.value))/100)
out.value.posy = Bone2.value.posy.value - moveY
xDistanz = Bone6.value.posx.value - Bone2.value.posx.value
moveX = 0.5 * xDistanz * ((100/(maxY / controler_lider.value))/100)
out.value.posx = Bone2.value.posx.value + moveX

Case "Bone3_out"
yDistanz = Bone3.value.posy.value - Bone5.value.posy.value
maxYoberlid = yDistanz * upper_lid_down
moveY = (maxYoberlid * (100/(maxY / controler_lider.value))/100)
out.value.posy = Bone3.value.posy.value - moveY
xDistanz = Bone5.value.posx.value - Bone3.value.posx.value
moveX = 0.5 * xDistanz * ((100/(maxY / controler_lider.value))/100)
out.value.posx = Bone3.value.posx.value + moveX

'---Unterlid
Case "Bone5_out"
yDistanz = Bone3.value.posy.value - Bone5.value.posy.value
maxYunterlid = yDistanz * (1 - upper_lid_down)
moveY = (maxYunterlid * (100/(maxY / controler_lider.value))/100)
out.value.posy = Bone5.value.posy.value + moveY
xDistanz = Bone5.value.posx.value - Bone3.value.posx.value
moveX = 0.5 * xDistanz* ((100/(maxY / controler_lider.value))/100)
out.value.posx = Bone5.value.posx.value - moveX

Case "Bone6_out"
yDistanz = Bone2.value.posy.value - Bone6.value.posy.value
maxYunterlid = yDistanz * (1 - upper_lid_down)
moveY = (maxYunterlid * (100/(maxY / controler_lider.value))/100)
out.value.posy = Bone6.value.posy.value + moveY
xDistanz = Bone6.value.posx.value - Bone2.value.posx.value
moveX = 0.5 * xDistanz* ((100/(maxY / controler_lider.value))/100)
out.value.posx = Bone6.value.posx.value - moveX

Case "Bone7_out"
yDistanz = Bone1.value.posy.value - Bone7.value.posy.value
maxYunterlid = yDistanz * (1 - upper_lid_down)
moveY = (maxYunterlid * (100/(maxY / controler_lider.value))/100)
out.value.posy = Bone7.value.posy.value + moveY
xDistanz = Bone7.value.posx.value - Bone1.value.posx.value
moveX = 0.5 * xDistanz * ((100/(maxY / controler_lider.value))/100)
out.value.posx = Bone7.value.posx.value - moveX
End Select
End if

ThE_JacO
03-13-2005, 12:46 PM
in first place you are so overloading the Outward connections that you are evaluating the contents of the update routine probably hundreds of times for every tiny movment.
you should try and split it into more scops.

secondly why are you using a SCOP for these kind of operations? it seems to me like you are complicatnig your life seriously wanting to use a SCOP when all you have is a single conditional statments and some basic arithmetical operations.

last but not least, SCOPs perform quite well on many things, in this particular case though you are using them for something that takes zillions of cycles just to evaluate.
You'd be probably getting subpar performance from this thing even if you were to write it compiled.

what exactly are you trying to do?

Helli
03-13-2005, 12:53 PM
First thx for your real fast answer.

Okey this is what I want to do:

I have 2 controlers (nulls) for my eyes/lids.

The first controler is for teh direction the eyes looking at.
The second controler is for open and closing the lids.

When moving the first controler not only the direction of the eyes should change also the lids should slightly move in the same direction.
When moving the second controler eyes should open/close, no matter where the eyes are looking at (so positoin of lids shouldn't matter)

The basic idea behind this is to have a facial rig wich you only need to merge in your scene, change the position of the "bone-nulls" so that they fit on your charakter and envelope your face.
It works as I want i to, I can change the position of the eye-lid-bones as I like and when moving the controler the eyes will open/close correct.

If there is a better way to reach this I am open to ideas :)

greets Mario

ThE_JacO
03-13-2005, 01:00 PM
this eye setup is something we constantly use in all our facial rigs (remember to put an activity control in there though, so that animators can turn off the eyelids automation if they wish).
and, as SCOP happy as I normally am when rigging, it's all done by expressions with a conditional statment in them, and it's perfectly realtime (along with another 50 to 200 controls we have on heads depending if they're heroes or not).

first why do you have so many bones if I may ask? all you need is one bone (I use sections of spheres for that, helps a lot visually) per eyelid and some decent weighting.
could you post your rig please? (links to pics and some explanation I mean, not the scene)
I have a sneaking suspicion you are being trigger happy and making your life harder then it should be :)

Helli
03-13-2005, 01:20 PM
Okey here is a movie, where you can see the rig and how it works. The script isn't optimized in this version so the eye lid bones aren't closing correct but solved this in a later version(where i messed up other things :D )

The bone in the middle is the jaw bone, the bones driven by the jaw bone are for the lips

Video (5,7 Mb xvid compressed):
http://lamp.fh-stpoelten.ac.at/studenten/tm011096/temp/facerig_test.avi



This is my first try making a facial rig, so I have no idea how something should be done and with what. I have only ideas in my mind what would be cool and try to make them real.

ThE_JacO
03-13-2005, 01:40 PM
This is my first try making a facial rig, so I have no idea how something should be done and with what. I have only ideas in my mind what would be cool and try to make them real.

when rigging remember that very often the simpliest solution is the best, and if it's not the best you should at least try it first.

start with a sphere, 2 sections of spheres of larger radius to simulate the eyelids, and try controlling them with expressions, most of what you'll learn with that exercise will easily trickle down in more complex facial rigs.

I'm leaving now, will try to have a look at the flick and eventually put together an example scene for you later on if I don't come back from the club completely s**tfaced :D

good luck

Helli
03-13-2005, 08:07 PM
start with a sphere, 2 sections of spheres of larger radius to simulate the eyelids, and try controlling them with expressions, most of what you'll learn with that exercise will easily trickle down in more complex facial rigs.


You mean just 2 "half-spheares" simulating eye lids ?
I am used to links, multiple links, constraints (and since an hour to expressions :D )

If you meaned the example as I understood this isn't really hard to make and little bit to basic to help me forward.
Expressions are quite simple as i saw. Tried to write something before, it's more a drag&drop thing than scripting so not that difficult to understand.

But what really sucks is that it's only possible to write one command in an espression or ??
Made some variables with custom propertys (nice way to work with often needed values because it's easy to change and animate them if wanted)

But my problem is I have 8 bones for every eye (2 in the corners and 3 for the upper and lower lid) so I would have to write an expression for every snigle bone because what I want needs to as example subtract the posy of bone 7 from the posy from bone 1 to get the distance between this 2 bones so that I know how far I can max move bone1 in y.
I would have to do this in every expression, so writing 16 expressions can't be the way.

Also the expressions would be quite long and no one would be able to understand them anymore (not even me after say 1 year :/ )

If you wondering why I need the distanc between the bones:
Links only work if you can set them to a constant value.
Expressions work as long as you don't want to be able to have a cutomizable rig.
In this special case I want to be able to change the size, the position and even the form of the eyes.
I am definitly not sure that I can reach this with expression.

Would love to see it working with expression. But my knowledge isn't enough to get this working without sitting here for about 10 hours making 16 different expressions :(

greets Mario

ThE_JacO
03-13-2005, 09:54 PM
the point is that your setup has a major flaw at the base, you are trying to move the controus of the palpebraes like if they had muscles, that AND the fact you'll have huge problems making them slide on top of a curved surface like the eye is.

all you need the eyelids to do s to move up and down on a spherical surface and some careful weighting in the corners.

and yes, expressions can only have one output, but I can't see why you'd need 16 to control 2 eyelids, and the overdone outputs in your scop are your main problem since it makes the operator reevaluate things a ridiculous amount of times for nothing.

don't try to overdo something that mother nature herself kept quite simple.

Helli
03-13-2005, 10:09 PM
Hmm I totaly understand what you mean.

But how would you make this ?

With 3 goals wich should be reached:
* Controler wich drives open/close
* Controler for eyemovment wich also slightly moves Lids in same direction.
* Ability to change size, form and position of the eyes easy (controlers should work after), so that this can be used on every humanlike Charakter.

Maybe you have any tutorials, pdf's, just something to read/look at what may help me.
Thx so far for your help.

greets Mario

ThE_JacO
03-13-2005, 10:33 PM
if you think of it it's simplier then it sounds ;)

make a customCP with:

eyelids open/close
bulb activity (if the bulb movment should affect the eyelids movments or not)

now, with a simple expression (use the cond statment to make it so that it will have certain limits for up and down movments) you can make it so that the eyelid bone rotation will equal:

(eye rotation on X + eyelids control*coefficient)*bulbactivity
you can also introduce factors and exponents to make the progression non linear (more lifelike).

now that you have this much you can have more controls to affect the eyebulb rotation with either constraints, expressions or whatever else you want.

all this results in a simple CP that you can present to the user directly OR link to with your in-scene GUI like you are doing now.
moreso, if you need to change anything in the rig, you won't have to touch the GUI but only change things(expressions, link with, whatever) between the CPset and the eyelid bones.

btw remember that after a certain angle your eyelids' bones will need to stop following the eye, otherwise for extreme poses, or animation with outbound slopes, you could end up with such bones caving the eyelids inside the skin or the forehead.
that's why I also specified you should 2 nested cond statements (floor and ceiling rotations).

hope this brings you a step closer to getting it done :)

CGTalk Moderation
03-13-2005, 10:33 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.