SlideShare une entreprise Scribd logo
1  sur  54
Flash Particle System
    leonskywalker@163.com
1.Overview
A particle system
          usually consists of

          3 parts.*

Physics
                    *Typical Implementation
Emitter
This is an emitter
What an emitter do:

1.emit particles.
2.controls how to emit particles.
 (birthrate, velocity, direction..etc).
3.holds a zone to generate particles.
 (can be a point, textfield or any bitmapdata using
 alpha mask..etc)
Uniform




Directional
Point




TextField
Particle
Particle is   What is a particle?

1.What you just see(the little blocks).
2.Basic units of a particle system.
3.Usually in (really) large number.
4.Does not necessarily be small.
This is particle.
This is particle.
This is also particle!
Physics
Physics system controls the motion
of every particle.




     v               a
            G
Even more advanced physics

• Mutual Gravity
Even more advanced physics



Turbulence
2.Implement
Physics
Global Environmental Variables
• Gravity
• Air Resistence Factor
• Wind

Physics calculations
 Concrete calculation is in each
 particle’s loop.
Physics
Particle       • Position
Attributes*    • Velocity (speed and direction)
               • Color
               • Lifetime
               • Age
               • Shape
               • Size
               • Transparency


*By Siggraph
Particle     • Position
Attributes   • Velocity (speed and direction)
             • Color
             • Lifetime
             • Age
             • Shape
             • Size
             • Transparency
Value Object   ItemRenderer
• Velocity     • Position
• Lifetime     • Transparency
• Age          • Color
• Position     • Shape
• Mass         • Size
• Update()
Pseudo code
function update(){
      age++;
      if(age > lifetime){
            dispose();
            return;
      }
      …
      calculateAcceleration(SpeedX,SpeedY);
      updatePosition(acceleration,oldX,oldY);
      …
      draw();
}
Physics
We need one major loop to

• Generate and dispose particles.
• Interacting with mouse position(if
  needed).
• Update particles’ attributes(position,
  rotation, alpha..etc.).

 We can put it in Emitter class
ENTER_FRAME

          particle = new Particle() n times
          n = number per frame
            = birthrate / framerate
          setInitialAttribute(particle);



 foreach particle in particlesArray
 particle.update();
A very basic particle system
3.Optimize
Facts #1:


• large amount of objects are being
  generated.
• at the same time large amount of
  objects are marked for GC.
Try using Object Pool.
Destroy              particles


                     Emitter
                                               Create


                    Object Pool
recycling to pool
                               Trying to find an instance
if(pool.length >0){
                 return pool.pop();
create    }else{
                 return new Particle();
          }


          particle.initialize();
destroy   pool.push(particle);
Facts #2:


• large amount of objects are being
  displayed at the same time.
Try using BitmapData.
Value Object   ItemRenderer
• Velocity     • Position
• Lifetime     • Transparency
• Age          • Color
• Position     • Shape
• Mass         • Size
• Update()
Value Object   BitmapCanvas
               ItemRenderer
• Velocity     • Position
• Lifetime     • Transparency
• Age          • Color
• Position     • Shape
• Mass         • Size
• Update()
Value Object     BitmapCanvas
                 ItemRenderer
• Velocity
• Lifetime
• Age
• Transparency
• Color
• Shape
• Position
• Mass
• Update()
bitmapdata.lock()
 point               foreach particle in particleArray
                          bitmapdata.setpixel32()
                     bitmapdata.unlock();


bitmap               Bitmapdata.copyPixels()
(No rotation and scale)


 sprite               bitmapdata.draw(source,
                      matrix, colorTransform
                      )
• More memory usage
(compared to cacheAsBitmap=false)


• Drastic performance boost
Because we manually overrode the process of native displaying,
bypassed the native rasterize engine
More speed means
more effects available.
Glowing trails
Depth of Field
Advanced glow and motion blur
4.Real world use
Some popular open
source particle engines
You can start building your works today
http://flintparticles.org/




http://code.google.com/p/stardust-
particle-engine/
Plugin Structure
   Provides more flexibility
Initialize

addInitializer(new Color(color));
addInitializer(new Position(new
SinglePoint(320, 480)));
addInitializer(new Velocity(bitmapZone));
addInitializer(new Life(new
UniformRandom(120, 30)));
Particle Behavior:
var gravity:Gravity = new Gravity();
gravity.addField(new UniformField(0, 0.1));
addAction(gravity);
addAction(new Age());
addAction(new DeathLife());
addAction(new Move());
addAction(new AlphaCurve(0, 60));
Examples used in previous slides:

• http://mrdoob.com/lab/pv3d/dof/06/

• http://co.youa.baidu.com/content/promo/10
  0shops7/index.html
Thank you!
        Q&A




 leonskywalker@163.com
        Mar 2010

Contenu connexe

Tendances

Gdc2011 direct x 11 rendering in battlefield 3
Gdc2011 direct x 11 rendering in battlefield 3Gdc2011 direct x 11 rendering in battlefield 3
Gdc2011 direct x 11 rendering in battlefield 3
drandom
 
Cyber-Physical Cloud Computing
Cyber-Physical Cloud ComputingCyber-Physical Cloud Computing
Cyber-Physical Cloud Computing
Kyoung-Sook Kim
 

Tendances (7)

OTOY GTC17 Presentation Slides: "The Future of GPU Rendering"
OTOY GTC17 Presentation Slides: "The Future of GPU Rendering"OTOY GTC17 Presentation Slides: "The Future of GPU Rendering"
OTOY GTC17 Presentation Slides: "The Future of GPU Rendering"
 
Gdc2011 direct x 11 rendering in battlefield 3
Gdc2011 direct x 11 rendering in battlefield 3Gdc2011 direct x 11 rendering in battlefield 3
Gdc2011 direct x 11 rendering in battlefield 3
 
Intro to Quantum Computing - IndiQ Hyderabad meetup (Feb 2nd)
Intro to Quantum Computing - IndiQ Hyderabad meetup (Feb 2nd)Intro to Quantum Computing - IndiQ Hyderabad meetup (Feb 2nd)
Intro to Quantum Computing - IndiQ Hyderabad meetup (Feb 2nd)
 
Cyber-Physical Cloud Computing
Cyber-Physical Cloud ComputingCyber-Physical Cloud Computing
Cyber-Physical Cloud Computing
 
PyTorch 튜토리얼 (Touch to PyTorch)
PyTorch 튜토리얼 (Touch to PyTorch)PyTorch 튜토리얼 (Touch to PyTorch)
PyTorch 튜토리얼 (Touch to PyTorch)
 
Rendering Techniques in Rise of the Tomb Raider
Rendering Techniques in Rise of the Tomb RaiderRendering Techniques in Rise of the Tomb Raider
Rendering Techniques in Rise of the Tomb Raider
 
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)
 

En vedette (11)

Web2 And Ajax
Web2 And AjaxWeb2 And Ajax
Web2 And Ajax
 
Stomach cancer
Stomach cancerStomach cancer
Stomach cancer
 
12 regina zilberman
12 regina zilberman12 regina zilberman
12 regina zilberman
 
Rss dan xml
Rss dan xmlRss dan xml
Rss dan xml
 
Electr
ElectrElectr
Electr
 
Spelifierad framtid
Spelifierad framtidSpelifierad framtid
Spelifierad framtid
 
Encryption-Based Multilevel Model for DBMS
Encryption-Based Multilevel Model for DBMSEncryption-Based Multilevel Model for DBMS
Encryption-Based Multilevel Model for DBMS
 
5things2know.About Web Redesign
5things2know.About Web Redesign5things2know.About Web Redesign
5things2know.About Web Redesign
 
Fundamentals of Information Encryption
Fundamentals of Information EncryptionFundamentals of Information Encryption
Fundamentals of Information Encryption
 
Web Services
Web ServicesWeb Services
Web Services
 
Denormalization
DenormalizationDenormalization
Denormalization
 

Similaire à Flash Particle System

Similaire à Flash Particle System (20)

コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門
 
State of GeoTools 2012
State of GeoTools 2012State of GeoTools 2012
State of GeoTools 2012
 
HTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGLHTML5 game dev with three.js - HexGL
HTML5 game dev with three.js - HexGL
 
javascript-Array.ppsx
javascript-Array.ppsxjavascript-Array.ppsx
javascript-Array.ppsx
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
The road to remote debugger
The road to remote debuggerThe road to remote debugger
The road to remote debugger
 
WEB222-lecture-4.pptx
WEB222-lecture-4.pptxWEB222-lecture-4.pptx
WEB222-lecture-4.pptx
 
【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~
【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~
【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~
 
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay
GDC 2010 - A Dynamic Component Architecture for High Performance GameplayGDC 2010 - A Dynamic Component Architecture for High Performance Gameplay
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay
 
Soc research
Soc researchSoc research
Soc research
 
Introduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous AgentsIntroduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous Agents
 
JS Fest 2019. Max Koretskiy. A sneak peek into super optimized code in JS fra...
JS Fest 2019. Max Koretskiy. A sneak peek into super optimized code in JS fra...JS Fest 2019. Max Koretskiy. A sneak peek into super optimized code in JS fra...
JS Fest 2019. Max Koretskiy. A sneak peek into super optimized code in JS fra...
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
 
Decima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero DawnDecima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero Dawn
 
Writing testable code
Writing testable codeWriting testable code
Writing testable code
 
Java dates
Java datesJava dates
Java dates
 
Henrik Christensen - Vision for co-robot applications
Henrik Christensen  -  Vision for co-robot applicationsHenrik Christensen  -  Vision for co-robot applications
Henrik Christensen - Vision for co-robot applications
 
Henrik Christensen - Vision for Co-robot Applications
Henrik Christensen - Vision for Co-robot ApplicationsHenrik Christensen - Vision for Co-robot Applications
Henrik Christensen - Vision for Co-robot Applications
 
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014
Benoit fouletier guillaume martin   unity day- modern 2 d techniques-gce2014Benoit fouletier guillaume martin   unity day- modern 2 d techniques-gce2014
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Flash Particle System