26 October 2011

Creation expression VS Runtime expression

Over the past few days, I was studying controlling particle using expressions and while I was following a tutorial, I reached a deadlock few times. It took 2 days to sort out the problems. It has completely messed up my head so that I had to study the concept of creation / runtime expression from the beginning again.

The original particle movement I wanted to create was that randomly created particles revolving around the Y axis in a limited area. Below video is the final succeeded example.





At first, I wanted particles emitting from an emitter and revolve around the Y axis. So I created an emitter and typed the expression in particleshape like below. The expression means "the particles' position = (From the position of a point, rotate around coordinate <0, 0, 0>, angle of radius 0.1)".




However, the result seemed the expression didn't work at all as you can see from the below video.




It looked like emitter created only one particle and it just vibrates itself. I checked the emitter and particleshape attribute but there was nothing unusual. So I looked up on the internet forums and scripting books, and found the answer. It was because I didn't initialize the position of particles with creation expression.

There are two types of expressions which are runtime and creation. You can apply creation expression and runtime expression to the particles. It can be used separately and both together at the same time. If you connect expression to ordinary object, you can set expressions to each different attributes, however, you can set creation expression and runtime expression to only one particle bearing no relation to attribute.


Creation expression evaluated only once for each particle when particle is born. So it doesn't affect to the particle after it has been created.
Runtime expression evaluated at least once per particle per frame but not at particle birth. For the same instance as creation expression, particles from emitter will be affected by the expression even after their birth.

I found this summary from my blog that i made for tutorial unit last year.. [http://pnsamelie.blogspot.com/2011/03/creation-expression-vs-runtime.html]
I should have been aware of the difference between two types of expression since I cleared up the definition. I am SURE I will never forget these.

So I added a creation expression which initialise the start position as <3,0,0>.



And it didn't work as i wanted it to be again. The result was like this video.




The emitter worked and particles were created. However I had to ask myself why the particles are only created but don't move at all. As now I use both runtime and creation expression, they should have rotated around the axis. According to the expressions, a particle is under the control of runtime expression after it's created, which makes it to rotate around <0, 0, 0> angle of radius 0.1.

I was confused again, I couldn't understand why particles don't move. I looked up online forums with every possible keywords. Then yesterday, I finally knew how i can figured out the situation while I was working on different example. I could easily check it by changing the particle render type to numeric. It shows the creation number of each particle.

It wasn't the matter of expression, but only an eye trick. They are actually rotating in a circle. It just looked like staying on the same spots, because the particle movement was so regular that newer particles created on the same position as older particles'. Below video is rendered in numeric but it's a shame it doesn't show the numbers clearly due to the size of video..




Now I changed the creation expression to gives random creation spots in the space within coordinate of <5, 5, 5>.






The final result looks satisfactory. The first problem can be seen as a mistake because I couldn't remember the attributes of expression, but the second one was much harder to figure out without knowing the "numeric" render type. I'm sure there will be another way to find it wasn't the matter of expression but still it would be the fastest and easiest way to check individual particle's behaviour.



No comments:

Post a Comment