Particle System - How to Store Particle Age?

Warning! Some information on this page is older than 3 years now. I keep it for reference, but it probably doesn't reflect my current knowledge and beliefs.

Dec 2012

Particle System - How to Store Particle Age?

Particle effects are nice because they are simple and look interesting. Besides, coding it is fun. So I code it again :) Particle systems can have state (when parameters of each particle are calculated based on previous values and time step) or stateless (when parameters are always recalculated from scratch using fixed function and current time). My current particle system has the state.

Today a question came to my mind about how to store age of a particle to delete it after some expiration time, determined by the emitter and also unique for each particle. First, let's think for a moment about the operations we need to perform on this data. We need to: 1. increment age by time step 2. check if particle expired and should be deleted.

If that was all, the solution would be simple. It would be enough to store just one number, let's call it TimeLeft. Assigned to the particle life duration at the beginning, it would be:

Step with dt: TimeLeft = TimeLeft - dt
Delete if: TimeLeft <= 0

But what if we additionally want to determine the progress of the particle lifetime, e.g. to interpolate its color of other parameters depending on it? The progress can be expressed in seconds (or whatever time unit we use) or in percent (0..1). My first idea was to simply store two numbers, expressed in seconds: Age and MaxAge. Age would be initialized to 0 and MaxAge to particle lifetime duration. Then:

Step with dt: Age = Age + dt
Delete if: Age > MaxAge
Progress: Age
Percent progress: Age / MaxAge

Looks OK, but it involves costly division. So I came up with an idea of pre-dividing everything here by MaxAge, thus defining new parameters: AgeNorm = Age / MaxAge (which goes from 0 to 1 during particle lifetime) and AgeIncrement = 1 / MaxAge. Then it gives:

Step with dt: AgeNorm = AgeNorm + dt * AgeIncrement
Delete if: AgeNorm > 1
Progress: Age / AgeIncrement
Percent progress: AgeNorm

This needs additional multiplication during time step and division when we want to determine progress in seconds. But as I consider progress in percent more useful than the absolute progress value in seconds, that's my solution of choice for now.

Comments (2) | Tags: math rendering | Author: Adam Sawicki | Share


2015-05-27 05:26:17
chanel handbags,
flat iron,
converse shoes,
salvatore ferragamo,
gucci handbags,
north face outlet,
north face clearance,
burberry factory,
ralph lauren uk,
polo outlet,
polo ralph lauren,
insanity workout,
jimmy choo,
jordan shoes,
juicy couture outlet,
juicy couture handbags,
kate spade,
kate spade handbags,
louis vuitton,
cheap michael kors,
michael kors outlet online,
michael kors outlet,
michael kors outlet online sale,
michael kors outlet store,
north face,
oakley sunglasses,
pandora jewelry,
prada handbags,
prada outlet,
ray ban outlet,
ray-ban sunglasses,
rolex watches,
swarovski crystal,
north face outlet,
tiffany and co,
tiffany jewelry,
true religion,
true religion jeans,
ugg australia,
ugg boots,
ugg boots clearance,
uggs on sale,
uggs outlet,
cheap oakley sunglasses,
oakley sunglasses cheap,
ralph lauren outlet,
polo ralph lauren outlet,
toms shoes,
toms outlet,
christian louboutin,
tory burch outlet,
gucci outlet,
hollister clothing,
nfl jerseys,
beats by dre,
beats headphones,
hair straightener,
ray ban sunglasses,
michael kors uk,
michael kors,
marc jacobs handbags,
louis vuitton,
ralph lauren,
nike free,
rolex watches,
wedding dresses,
pandora charms,
thomas sabo,
louboutin shoes,
nike huarache,
nike roshe,
north face,
louis vuitton canada,
air jordan,
jordan retro,
cheap jordans,
nike factory,
nike outlet store,
nike shoes,
nike air max,
nike air max 2015,
air max,
nike free run,
nike free,
supra shoes,
new balance,
mont blanc pens,
ferragamo shoes,
mcm bags,
nike mercurial,
celine handbags,
roshe run,
nike roshe,
vans shoes,
timberland boots,
iphone cases,
baseball bats,
babyliss pro,
louis vuitton,
christian louboutin shoes,
louis vuitton bags,
prada outlet,
michael kors outlet,
michael kors outlet online,
tommy hilfiger outlet,
mcm backpack,
kate spade outlet online,
salvatore ferragamo,
louis vuitton outlet online,
burberry outlet,
burberry clothes,
the north face,
monster beats outlet,
gucci shoes,
longchamp handbags,
ralph lauren shirts,
coach handbags,
beats by dre outlet,
coach outlet,
coach outlet online,
coach store online,
michael kors bags sale,
coach factory,
cheap oakley ,
hermes outlet online,
air jordans,
coach outlet,
coach outlet usa,
gucci shoes outlet,
coach outlet,
michael kors,
gucci factory,
the north face jackets,
cheap ugg boots,
tory burch outlet,
tommy hilfiger kids,
vuitton handbags,
cheap calvin kleins,
christian louboutin shoes,
air jordan shoes,
burberry outlet online,
abercrombie and fitch,
cheap oakley sunglasses,
oakley outlet,
oakley sunglasses,
swarovski jewelry,
replica handbags,
boots on sale,
basketball shoes,
chanel sunglasses,
true religion outlet,
abercrombie and fitch,
hermes birkin,
yoga pants,
gucci shoes,
ray ban sunglasses outlet,
omega watches,
eyeglass frames,
eyeglasses online,
cheap michael kors,
cheap ray ban,
ray bans,
ray ban wayfarer,
easton bats,
burberry outlet,
christian louboutin outlet,
tory burch sandals,
soccer shoes,
timberland outlet,
retro jordans,
toms shoes outlet,
2016-03-29 08:56:54
my first time to Shanghai, to help me find a dozen dollars hostel, please?"So, to accompany her to find hostels. At 7:00 pm was staying in a cheap hostel but also 40 yuan a night. I want to leave, she let go, her eyes riveted on me, repeated the phrase: "? I first came to Shanghai, you spend time with me, please" like to see her, I could not help students from compassion heart of. I inserted through the team in Jiangxi Province. Twenty years of joint swelling and pain can not walk, the production team with a dray uncle sent me to commune health centers for treatment. Now the little girl and I was not also the case with what? A single person, in need of help, I can not ask her? I went to apply for a stay formalities, she lives upstairs, I live downstairs. I went to the supermarket to buy two sets of towels, toothbrush, toothpaste, they have to spend to stay.After dinner, I go with her to the supermarket plaza. The first time I saw so many customers, bustling crowd, her age girl wearing Western style fashion, she was very envious. The first elevator ride elevators and stairs room, gesticulating see so many people standing looking at her surprised. First sat on a long bench enjoying central air conditioning blowing cool breezes, her temperament is particularly comfortable. She opened the door panel of the soul, to tell me her story. Her surname situation, 24 years old this year, who lives in Jiangxi Nanshan District, poor economic conditions at home, and nothing good local place to make moneI heard that Shanghai life is better, earn more, she charmed one day to see. The village has seen young men and women to go to Guangzhou, Shanghai to work, she echocardiography. But mother does not agree, do not trust her to go out alone. That day, she and her mother had a big fight. At night, while sleeping parents left home alone, by car, by train, they go to work in Shanghai Pudong cousin. In Shanghai, because the address does not have to call home to ask, he said, can not find the address of the first to come back, her mother fell ill in bed, so he had to return. In the road to the train station, a brother lie to her on the bus, turn a long time to ask for 100 dollars. In the car, but also hands and feet, touched her breasts. She was afraid. Later I met, I feel like her cousin, honest, caring, considerate. Come here and opened the eyes, I feel very happy. I said, you yearn for Fu-life is right. Now your mother sick, certainly you do not worry. You can go home and talk to my mother, reassured her, and then you come to Shanghai. A girl is not easy to Shanghai to work, to learn skills, to adapt to the urban environment as soon as possible, but also pay attention to protect themselves. As long as they work hard, work hard, you will succeed.Back to Hostel has 10 points. In her room,

Post comment

Nick *
Your name or nickname
Your contact information (optional, will not be shown)
Text *
Content of your comment
Calculate *
(* - required field)
STAT NO AD [Stat] [Admin] [STAT NO AD] [pub] [Mirror] Copyright © 2004-2017 Adam Sawicki
Copyright © 2004-2017 Adam Sawicki