EXPRESSIONS FOR ALL! (knowledge tidbits)
Sorry to break-in mind-raper, but I'm making this thread STICKY so it will always be at the top for everyone to learn from!
Post your particle/dynamics EXPRESSIONS here for everyone to learn from! Please write a little "how-to" along with your expression, so we will all know how to try it, and experiment with applying it to our dynamics/particle scenes! Thanks all!:beer: THREAD STARTS HERE first post by mind_raper here's a little nice expression to .. colorize you particles system, i have learnd it from gnomon workshop well its really good & ... is very simply first from general options add per particle attribute the rightclick---> write creation expression:: take ur your are particle shape node (particleShape1) and add per particle attiribute (rgbPP) and then assign a random value b/w (minVector i.e <<.3,5,7>>) and (maxVector i.e <<.5,7,1>>). select the render type streaks or multi-streaks or what ever u want check on the color Accum button and the lightining button too play around the values to see different color effects... particleShape1.rgbPP = rand(<<.3,5,7>>,<<.5,7,1>>); hope u find it usefull enjoy - -> :banana: |
Thanks mind-raper!
I think everyone should know the power of using expressions with particle systems, and your post will help others "EXPERIMENT" and learn, rather than be affraid, or overwhelmed. Good job m8! |
Here is a little expression tidbit from me to help this thread along:
TO RANDOMIZE STUFF: selectedObjectname.tx = rand(-10,10); "tx", or whatever, is the attribute you can choose to have the expression applied to. So, for random particle ROTATION: selectedObjectname.rotX = rand(0,360); selectedObjectname.roty = rand(0,360); selectedObjectname.rotz = rand(0,360); Try this as a CREATION expression, AND then try it as a RUNTIME expression to see the difference between these calculation types:) |
Speed, Stuff
i think that was difficult...
well no prb.... tell u one thing....they are very easy just u need little bit of understanding......here's one more example from maya's documentation! moving the particles..... Use the Particle Tool to place a collection of particles in the workspace. You then create the following creation expression to control their velocity: particleShape1.velocity = <<0,1,0>>; All the particles move in a Y-axis direction at one grid unit per second as the animation plays. explaination "particleShape1" is the shape node for ur particle object that can be anything that u have named "velocity" is the attirbute for shape node. "<<0,1,0>>" is the value for X, Y, Z Respectivly try to change the values and make it more dynamic with coditional statments like if frame==something move in X direction or the way u wanted. hope this works for u ....! enjoy coding...! :beer: |
Kill particles a few moments after they reach a specified locator
create an emitter and a locator and create another locator
first select the particle and shift select the 1st locator goto --- > Particles -- > goals--option reset the setting and press ok do the same with other locator Animate the particle from one locator to another using Goalweight attribute then add the following script and see the magic of expressions thanks for the cool expression << Daniele Tosti >> <b> vector $partPos = particleShape1.position; if ($partPos > locatorName.ty) { particleShape1.lifespanPP = rand (5); } else { particleShape1.lifespanPP = 5 ; }</b> enjoy coding :beer: :banana: |
Attribute of an object at a certain
This expression will take the attribute of an object at a certain “offset” time, and apply it to another objects attribute. For instance it will take it off a cubes translateZ attribute, and assign it to a spheres translateZ attribute.
-Create a new scene. -Create a polyCube. -Create a polySphere. -Translate the sphere about 10 units in Y. -Open the Expressions editor, then Select Filter/By Expression Name. -Type in the following: int $offset = 10; int $currentTime = `currentTime -q`; $offsetTime = $currentTime - $offset; $cube1Zpos = `getAttr -t $offsetTime pCube1.tz`; pSphere1.translateZ = $cube1Zpos; -Hit Create. and here is the explaination ! //Time offset expression //offset length (in frames) int $offset = 10; //Get current time int $currentTime = `currentTime -q`; //Substract the offset to the current time //so if current time is 10, //and offset is 2, offsetTime will be 8 $offsetTime = $currentTime - $offset; //Get the value of pCube1.translateZ //at frame $offsetTime (8 in our example) $cube1Zpos = `getAttr -t $offsetTime pCube1.tz`; //Assign it to pSphere1.translateZ pSphere1.translateZ = $cube1Zpos; This could be taken much further, you could for example setup joints and IK so it looks like power tubes are going from the mothership to the children, you could also add a custom attribute called “motion” and multiply the “noise” section of the expression by it, so that if you decide to turn you noisy motion off you would just have to set the custom attribute to 0. You could keyframe that attribute so you could control the random “floating” motion of the ship throughout the scene so it stops looking as if it were floating if it lands for example. This type of setup could also be applied to a cranefly, or any other type of futuristic flying object etc. Experiment with setting all sorts of different relationships etc until you are comfortable with this expression. this is very handy little snippet from Oliver Shyal Beardsley thanks alot for .......it hope you enjoy it........... |
Nice thread here, i know i'll be learning from it, just hope it sticks :D
|
Wow nice thread :) THis is a really good idea
brian |
It can only get bigger:)
|
yes absolutly !
Cause expression makes ur animation look more healthy and realistic support is all needed...! |
Here's a little tip. If you use the seed() function you can be sure your expression with rand() functions run always the same way.
Code:
{ |
Cool K!!
|
Removing linear breaks
Moving a turbulance field with object the problem is..
noise patterens move slong with it if u we want remove linear breaks we use turbulance phase attribute let say you....want to move a turbulance field...through particles and want to.... effect its nearest as u know turbulance field is not good at moving, thats why to aviod that we use phase as per need Example script : turbulance field.phaseX = times * 4; play wid it.... it really handy in particle system..! enjoying coding..! |
Rock on m8!
|
Some Handly Little Expressions
Rotating Wheels of Car or anything
Wheels on a car: apply to the wheel rotate in z channel wheel.rz=car.tx/(2*3.145) * 1*360; Wind shield wipers Windshield wipers: apply to the wiper rotate in x channel wiper.rx = (sin (.9 *time)*45)+10; wiper = wiper sine = sine speed = how much fast you want() here i have put .9 time = time degree = i put (45) offset for position i put (10) Random Imbedded Sin Waves for a Random Effect ty = sin (sin (.5 * time) * time); enjoy ~ ! |
Thanks again mind-raper!
..and to post another variant for randomly-created particle attributes per a request in the MATRIX BULLET TRAIL thread on how to get emitted particle instances (or even just particles) to emit at random scale values: Quote:
|
Controlling speed for instanced Object
when you have instanced an object to particle specially a moving geometry its sometime very difficult to handle cause sometime movement of particles is higher than your instanced object or the other way your object speed is higher then particles(e.g you have created a crown moving through the scene and when you have instanced it to particle they are moving (sliding). there are other manual ways to fix it but i will show you how to do it with expressions, And For this we use a matching script with it you can query how much fast is....particle/object is moving and then according to it you can plug that value into your instanced object/Particles.
A real good way while you are using instanced Geometry, is to use Custom Attributes and then write the expression on the custom attribute and then plug that custom attribute into your instanced geometry. for a situation where let say you have (crowd) walking animation you instanced it with particles first you instance like you do normally with basic cautions thats you take before instancing any geometry create custom attibute from Particle Attribute goto ADD DYNAMIC ATTRIBUTE and add a attribute with you desired setting customAge float and Per Particle Array you will see a new attribute in per particle array attributes named customAge we'll write a custom expression as follow:- float $Speed = mag(particle2Shape.velocity); particleShape1.customAge = particleShape1.age * $Speed /10 (this number can differ as per your need you have to keep playing untill your object is no longer sliding !) ; mag is for Magnitude ! see documentation for it ! if you are not getting a very good try low down da lifespan of the particle through the scene hope it helps enjoy instancing :bannana: |
Rock on m8! That's a keeper!
|
this one selects a random element from an array
proc int selectRandArrayVal(string $arr[]) { int $randomInt = floor(rand(size($arr)))+1; return $randomInt ; } :) Cool thread btw Alan |
Hehe, I think mind_raper is raping all the gnomon video expressions
|
Hummmm
lolz
yeah.......... Cause not everyOne has the material so i think.....its helpfull ...! but offcourse not all of them.....the are from different authors they are also mentioned ! |
its all cool
|
Either way, an expression is an expression, so keep em coming guys! :)
|
Ok here's one which I just figured out.
Driving a shader attribute with distance from camera Let's dig in to this with an example: 1. Create a lambert shader 2. Create a ramp texture (delete the place2dTexture node if it is created) 3. Connect the ramp's output to the lambert's color channel 4. Create a sampler info node 5. Create an expression with following code: Code:
// NOTE: I'm using default object names here |
WOW! Kinda like the Yuya Depth shader, only better!
Good one Kman! |
I just figured out that controlling things based on the distance from camera is really usefull. For example HW particles (mainly points and streaks) are sized in pixels. So no matter how far they are, they will be (HW) rendered the same size -> not exactly realistic looking. If you add a runtime expression which scales the opacityPP based on the distance from the current camera it will look a lot better.
Example: Code:
vector $vPPos = lpos; // last position of the particle |
And with this expression, who says a lot of rain spoils a shot?
Good one again Kman! |
yeah that helps in densed(populated) particles scene where it need lots of camera adjustment will cut down lots of time !
|
I don't care from where they come here
Hi.
Cool thread ! I'm new here and I'd learned alot from these expressions. I don't care from where they come here, all of them are good for me. Thank mind_raper and everyone. Why the thread had stoped ? Sorry about my poor English. |
Hasn't really stopped, just slowed down a bit because folks are a little busy.
It is a "sticky" thread so that way it is always at the top for reference:) Feel free to post any questions, and we will see if we can help:) |
Creating runway lighiting effects
Well its time for a cool Particle function guys...!
A linstep function is used in conjunction with a ramp to control the rgbPP attribute of the particles color. The particles appear to "turn on" sequentially from front to back. An offset is added to the particle's age to create this effect. creation expression: $pos=particleShape1.position; particleShape1.lightOffset= ($pos.z+20); -------------------- Runtime expression: $myAge=particleShape1.age-(particleShape1.lightOffset*.25); particleShape1.rgbVPP=linstep (2,3,$myAge); enjoying...! |
Quote:
If you have an expression for it ... I love the thread. tathu |
I personaly would use blendshapes for that, but in combination with that, you might also wanna try doing it with SetDriven Keys as well maybe.
I think Mike Mckinley or even Danny Ngan know of a way to do this, so they might be better people to ask:) Thanks! Good luck! |
Thanks for your response so fast, and sorry if I do harass the thread.
:( |
No prob!
|
well if u still want to use expression then u can ......program ur geometry e.g
like: if (your foot touches ground ) the ground should effect; else if (if its leaving the surface) the ground should effect; i think u'll not be able to ...produce realistic effects with only expressions like Rage said blendshape could help....and i think that there will be an attribute that can be keyable and can be controlled through expressions...so...give a try...u know...expression makes your scene clean from raw data that take up extra..resourse cause they excute when conditions are met...... well will be putting....expression for same type of effect soon...which produces swells in softbodies....it will be helpfull to produce perfect result...for ur scene enjoy .... |
1 Attachment(s)
A noise function is used to control the Y position of a string of particles. Arithmetic operators are used to control the amplitude, frequency and offset of the function.
1. Create an emitter with as desired parameters...... 2. Create Custom Attributes as follows a. tornodoRadius b. tornodoTwist c. tornodoRadiusMult now let code: creation Expression particleShape1.tornadoRadius=rand (.75,1.25); particleShape1.toranadoTwist=rand (1,3); particleShape1.position=<<1000,0,0>>; **** Runtime Expression vector $pos=particleShape1.position; float $radius=particleShape1.tornadoRadius*particleShape 1.tornadoRadiusMult; float $speed=time*particleShape1.toranadoTwist; float $noise=noise((time*.3)+(particleShape1.particleId* .01)); particleShape1.position=<<($radius*(sin($speed+par ticleShape1.particleId)))+$noise ,$pos.y+.1, ($radius*(cos($speed+particleShape1.particleId)))+ $noise>>; **** and third create a ramp on tornodoRadiusMult custom attribute this ramp will be used to control its hollowness from top or bottom..... adding source file.........check it out...! enjoying.......! :beer: |
hey guys, I've decided to join in the fun as well :D.
Let's see, for a spotlight, you attach the color to a water map, edit it as you like and then for the expression (for your new water1 texture): water1.waveTime = time*0.2 and water1.waveVelocity = (cos(time)+1)/2 If you put a nice fog to it, and color the water map right, you could have a cool spotlight for underwater (works very well with www.thegnomonworkshop.com 's fog light,) or the illusion of the sunlight going trough the leaves of trees when you move under them. water1.waveTime = time*0.2 makes sure the wave texture 'moves' to the left ( because it's endless ), and water1.waveVelocity = (cos(time)+1)/2 makes sure the number stays between the 0 and 1, so that when spotlighted, it increases and decreases, just as if waves take away some sunlight :). I hope I helped! :D:bgreen: |
hey thats....good
this means we all are learning.....more n more..
|
Speak for yourself... the more expressions I seem to learn, the more I forget about the rest of the world :p :D :beer: :bgreen: It's just like :beer: , you learn to drink more and you forget more about the rest while doing that :D :beer:
|
All times are GMT. The time now is 10:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018