SlideShare a Scribd company logo
1 of 123
RENDER FOR SPEED
ABOUT ME



           Lee Brimelow
           Game Developer Evangelist


           www.leebrimelow.com
           www.gotoandlearn.com


           brimelow@adobe.com
           @leebrimelow
AGENDA
AGENDA



         - Traditional rendering
AGENDA



         - Traditional rendering
         - Blitting techniques
AGENDA



         - Traditional rendering
         - Blitting techniques
              - Full stage blitting
AGENDA



         - Traditional rendering
         - Blitting techniques
              - Full stage blitting
              - Partial blitting
AGENDA



         - Traditional rendering
         - Blitting techniques
              - Full stage blitting
              - Partial blitting
              - Dirty blitting
AGENDA



         - Traditional rendering
         - Blitting techniques
              - Full stage blitting
              - Partial blitting
              - Dirty blitting
              - Bitmap armatures
AGENDA



         - Traditional rendering
         - Blitting techniques
              - Full stage blitting
              - Partial blitting
              - Dirty blitting
              - Bitmap armatures
              - MovieClip caching
AGENDA



         - Traditional rendering
         - Blitting techniques
              - Full stage blitting
              - Partial blitting
              - Dirty blitting
              - Bitmap armatures
              - MovieClip caching
         - Mobile rendering
AGENDA



         - Traditional rendering
         - Blitting techniques
              - Full stage blitting
              - Partial blitting
              - Dirty blitting
              - Bitmap armatures
              - MovieClip caching
         - Mobile rendering
         - Stage 3D
AGENDA



         - Traditional rendering
         - Blitting techniques
              - Full stage blitting
              - Partial blitting
              - Dirty blitting
              - Bitmap armatures
              - MovieClip caching
         - Mobile rendering
         - Stage 3D
         - New 2D framework
A SIDE NOTE ABOUT HTML5
HELP AND INSPIRATION
HELP AND INSPIRATION
HELP AND INSPIRATION
HELP AND INSPIRATION
HELP AND INSPIRATION
HELP AND INSPIRATION
DISCLAIMER
There is no perfect rendering method. Choosing the right one takes
experimentation and should be based on the type of content.
FLASH RENDERING METHODS
TRADITIONAL RENDERING
TRADITIONAL RENDERING
TRADITIONAL RENDERING



           PROS

           - Easiest to develop
           - Vectors can be smoothly scaled at runtime
           - Non-animating clips can use cacheAsBitmap
TRADITIONAL RENDERING



           PROS

           - Easiest to develop
           - Vectors can be smoothly scaled at runtime
           - Non-animating clips can use cacheAsBitmap



           CONS

           - MovieClips and Sprites have a lot of overhead
           - Can be slow with large numbers of animated objects
           - Can take up much more memory
Most Flash games will run great simply if cacheAsBitmap is used.
THE CRAZY WORLD OF BLITTING
SPRITE SHEETS
TEXTURE PACKER
TEXTURE PACKER DISCOUNT CODE

  fotb2011-lee-brimelow
     to get 20% discount for TexturePacker and/or PhysicsEditor
BLITTING EXPLAINED



   BitmapData                       Sprite sheet




                               ls
                          Pixe
                     copy
BLITTING STEPS
BLITTING STEPS




            1    Create pre-rendered sprite sheet of animations
BLITTING STEPS




            1    Create pre-rendered sprite sheet of animations


            2    Add single BitmapData canvas to the display list
BLITTING STEPS




            1    Create pre-rendered sprite sheet of animations


            2    Add single BitmapData canvas to the display list


            3    Copy the background into the canvas or erase
BLITTING STEPS




            1    Create pre-rendered sprite sheet of animations


            2    Add single BitmapData canvas to the display list


            3    Copy the background into the canvas or erase


            4    Copy any game sprites into the canvas
BLITTING STEPS




            1    Create pre-rendered sprite sheet of animations


            2    Add single BitmapData canvas to the display list


            3    Copy the background into the canvas or erase


            4    Copy any game sprites into the canvas


            5    Repeat steps 3 and 4 inside of main game loop
TIP
Be sure to call bitmapData.lock() before doing multiple copyPixel calls
to prevent unnecessary updating, followed by bitmapData.unlock().
COPYPIXELS VS DRAW
COPYPIXELS VS DRAW



         Best performance
COPYPIXELS VS DRAW



         Best performance




         Most exible




                   (Sprites can be transformed and use blend modes)
TIP
If you game is fully blitted you can set the stage quality to low.
FULL STAGE BLITTING



            BitmapData




                - Single bitmapData canvas on display list
                - All sprites are blitted to this single canvas
                - Good for large number of animated sprites
DEMO
So when should you use full blitting for your game?
BUT SERIOUSLY
BUT SERIOUSLY


        Fast action scrollers
BUT SERIOUSLY


        Fast action scrollers




        Tile-based games
Creating games using the HTML5 canvas element uses
these same blitting techniques. The canvas tag is similar
to a bitmapData object in Flash.
DIRTY BLITTING




            BitmapData




             - Store the previous frames rectangle
             - Then only repaint dirty regions of the background
PARTIAL BLITTING



            Stage                                   Bitmap


                                     Bit
                                           ma
                                              p


                       ap
                B   itm




                                                        Bit
                                                         m
                                                             ap
            - Each sprite is blitted to individual bitmapData
            - Bitmap objects can be easily transformed
            - Good tradeoff between exibility and performance
DEMO
BITMAP ARMATURES




      Instead of drawing a unique illustration for each frame of the model's
      animation, armature models are drawn as a series of body parts that
      move in relationship to each other just like the bones in your skeleton.
DEMO
WHICH TECHNIQUE TO USE
WHICH TECHNIQUE TO USE


         FULL BLITTING
        Best when frequent redraws of the entire screen are required.
        Think fast-action side scrollers like Canabalt.
WHICH TECHNIQUE TO USE


         FULL BLITTING
        Best when frequent redraws of the entire screen are required.
        Think fast-action side scrollers like Canabalt.


         PARTIAL BLITTING
        Great choice when frequent redraws of the entire screen are not
        required. Also much easier to do transforms and does not require
        pre-rotated sprite sheets.
WHICH TECHNIQUE TO USE


         FULL BLITTING
        Best when frequent redraws of the entire screen are required.
        Think fast-action side scrollers like Canabalt.


         PARTIAL BLITTING
        Great choice when frequent redraws of the entire screen are not
        required. Also much easier to do transforms and does not require
        pre-rotated sprite sheets.


         ARMATURE MODELS
        Best choice when a large number of customizable characters are
        required. RPGs are a classic example of this.
RUNTIME MOVIECLIP CACHING
RUNTIME MOVIECLIP CACHING




                   Array of BitmapData
var s:snake = new snake();
var s:snake = new snake();
for(var i:int=1; i<s.totalFrames; i++)
var s:snake = new snake();
for(var i:int=1; i<s.totalFrames; i++)
{
var s:snake = new snake();
for(var i:int=1; i<s.totalFrames; i++)
{
   var bmd:BitmapData = new BitmapData(s.width, s.height);
var s:snake = new snake();
for(var i:int=1; i<s.totalFrames; i++)
{
   var bmd:BitmapData = new BitmapData(s.width, s.height);
   s.gotoAndStop(i);
var s:snake = new snake();
for(var i:int=1; i<s.totalFrames; i++)
{
   var bmd:BitmapData = new BitmapData(s.width, s.height);
   s.gotoAndStop(i);
   bmd.draw(s);
var s:snake = new snake();
for(var i:int=1; i<s.totalFrames; i++)
{
   var bmd:BitmapData = new BitmapData(s.width, s.height);
   s.gotoAndStop(i);
   bmd.draw(s);
   frames.push(bmd);
var s:snake = new snake();
for(var i:int=1; i<s.totalFrames; i++)
{
   var bmd:BitmapData = new BitmapData(s.width, s.height);
   s.gotoAndStop(i);
   bmd.draw(s);
   frames.push(bmd);
}
BLITTING GAME FRAMEWORKS
BLITTING GAME FRAMEWORKS
BLITTING GAME FRAMEWORKS
BLITTING GAME FRAMEWORKS
AIR MOBILE RENDERING
TWO RENDERING MODES
TWO RENDERING MODES



          CPU

          - Everything is rendered in software
          - Use this mode for fully blitted games
          - Good performance on iOS
TWO RENDERING MODES



          CPU

          - Everything is rendered in software
          - Use this mode for fully blitted games
          - Good performance on iOS



          GPU

          - Bitmaps are automatically rendered using the GPU
          - Text and vectors can use cacheAsBitmapMatrix
          - Most all games should be rendered in this mode
CACHING VECTORS



             Application XML




             Vector content
TIP
Objects on the GPU are automatically anti-aliased so you can set
the stage quality to low.
DEMOS
PERFORMANCE TIPS
PERFORMANCE TIPS



         - Keep the display list as at as possible
PERFORMANCE TIPS



         - Keep the display list as at as possible

         - Utilize blitting or partial blitting where appropriate
PERFORMANCE TIPS



         - Keep the display list as at as possible

         - Utilize blitting or partial blitting where appropriate

         - Use object pools to avoid instantiation costs
PERFORMANCE TIPS



         - Keep the display list as at as possible

         - Utilize blitting or partial blitting where appropriate

         - Use object pools to avoid instantiation costs

         - Use cacheAsBitmapMatrix for any non-changing vectors
PERFORMANCE TIPS



         - Keep the display list as at as possible

         - Utilize blitting or partial blitting where appropriate

         - Use object pools to avoid instantiation costs

         - Use cacheAsBitmapMatrix for any non-changing vectors

         - Just say no to using lters
PERFORMANCE TIPS



         - Keep the display list as at as possible

         - Utilize blitting or partial blitting where appropriate

         - Use object pools to avoid instantiation costs

         - Use cacheAsBitmapMatrix for any non-changing vectors

         - Just say no to using lters

         - Test early and often on actual devices
PERFORMANCE TIPS



         - Keep the display list as at as possible

         - Utilize blitting or partial blitting where appropriate

         - Use object pools to avoid instantiation costs

         - Use cacheAsBitmapMatrix for any non-changing vectors

         - Just say no to using lters

         - Test early and often on actual devices

         - Use pro ling tools to nd bottlenecks
STAGE 3D RENDERING
STAGE 3D
STAGE 3D




           Formally known by the code name Molehill.
STAGE 3D




           Formally known by the code name Molehill.


           Stage 3D is a new GPU-accelerated rendering engine for the Flash
           Player. This enables console-level 2D and 3D graphics for games.
PREDICTION
Stage 3D is faster than any other rendering technique and it
will become the de-facto standard for Flash games.
PREDICTION
Stage 3D is faster than any other rendering technique and it
will become the de-facto standard for Flash games.


  But it isn’t released yet and will not be available on mobile for a little while.
INTEGRATION




                                         display list




              wmode=direct is required
LOW-LEVEL STAGE 3D


    //
setup
backbuffer
(level
1
aa,
z
buffer
on)

    context3D.configureBackBuffer(
stage.stage3Ds[0].viewPort.width,
stage.stage3Ds[0].viewPort.height,
1,
true
);

    //
create
a
vertex
buffer
    vertexbuffer
=
context3D.createVertexBuffer(
3,6
);
    vertexbuffer.uploadFromVector
(
Vector.<Number>([


   

    
    
    
    ‐1,‐1,0,

255/255,0,0,

 
    

    
    
    
    0,1,0,



193/255,216/255,47/255,


    
    
    
    1,‐1,0,


0,164/255,228/255








    
    
    ]),0,
3
);
//
start
at
offset
0,
count
3


    //
create
an
index
buffer.
this
is
just
identity
    indexbuffer
=
context3D.createIndexBuffer
(
3
);
    indexbuffer.uploadFromVector
(
Vector.<uint>(
[
0,
1,
2
]
),
0,
3
);
//
start
at
offset
0,
count
3

    //
create
a
vertex
and
fragment
program
‐
from
assembly
    var
vertexShaderAssembler
:
AGALMiniAssembler
=
new
AGALMiniAssembler();
    vertexShaderAssembler.assemble(
Context3DProgramType.VERTEX,

    
    "m44
op,
va0,
vc0
 
     n"
+
/
4x4
matrix
transform

                                        /
    
    "mov
v0,
va1
 
     
    n"


/
copy
stream
1
to
fragment

                                        /
    );
 
     
    
    
    

    var
fragmentShaderAssembler
:
AGALMiniAssembler=
new
AGALMiniAssembler();

    fragmentShaderAssembler.assemble(
Context3DProgramType.FRAGMENT,

    
    "mov
oc,
v0"
//
output
color


    );
    
    
    

    //
upload
the
AGAL
bytecode
    program
=
context3D.createProgram();
    program.upload(
vertexShaderAssembler.agalcode,
fragmentShaderAssembler.agalcode
);

HIGH-LEVEL FRAMEWORKS
HIGH-LEVEL FRAMEWORKS
STAGE 3D DEMOS
NEW OPEN-SOURCE PROJECT
NEW OPEN-SOURCE PROJECT
Adobe is working on an open-source, 2D ActionScript API that leverages
GPU acceleration using Stage 3D. This new API is based on the existing
Flash display list, making it very easy for ActionScript developers to learn.
Sprite sheet and XML
var frames:Vector.<Texture> = getTextureAtlas().getTextures("snake");
var frames:Vector.<Texture> = getTextureAtlas().getTextures("snake");
var hero:MovieClip = new MovieClip(frames, 60);
var frames:Vector.<Texture> = getTextureAtlas().getTextures("snake");
var hero:MovieClip = new MovieClip(frames, 60);
hero.x = Math.random() * 800;
var frames:Vector.<Texture> = getTextureAtlas().getTextures("snake");
var hero:MovieClip = new MovieClip(frames, 60);
hero.x = Math.random() * 800;
hero.y = Math.random() * 600;
var frames:Vector.<Texture> = getTextureAtlas().getTextures("snake");
var hero:MovieClip = new MovieClip(frames, 60);
hero.x = Math.random() * 800;
hero.y = Math.random() * 600;
addChild(hero);
DISPLAY
DisplayObject
Button
Image
MovieClip
Sprite
DISPLAY         EVENTS
DisplayObject   EnterFrameEvent
Button          KeyboardEvent
Image           ResizeEvent
MovieClip       TouchEvent
Sprite
DISPLAY         EVENTS            TEXT
DisplayObject   EnterFrameEvent   BitmapFont
Button          KeyboardEvent     TextField
Image           ResizeEvent
MovieClip       TouchEvent
Sprite
HELLO WORLD
Font glyphs and XML
PARTICLE DESIGNER
WILL BE RELEASED SOON
QUESTIONS?

More Related Content

Recently uploaded

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Render For Speed

  • 2. ABOUT ME Lee Brimelow Game Developer Evangelist www.leebrimelow.com www.gotoandlearn.com brimelow@adobe.com @leebrimelow
  • 4. AGENDA - Traditional rendering
  • 5. AGENDA - Traditional rendering - Blitting techniques
  • 6. AGENDA - Traditional rendering - Blitting techniques - Full stage blitting
  • 7. AGENDA - Traditional rendering - Blitting techniques - Full stage blitting - Partial blitting
  • 8. AGENDA - Traditional rendering - Blitting techniques - Full stage blitting - Partial blitting - Dirty blitting
  • 9. AGENDA - Traditional rendering - Blitting techniques - Full stage blitting - Partial blitting - Dirty blitting - Bitmap armatures
  • 10. AGENDA - Traditional rendering - Blitting techniques - Full stage blitting - Partial blitting - Dirty blitting - Bitmap armatures - MovieClip caching
  • 11. AGENDA - Traditional rendering - Blitting techniques - Full stage blitting - Partial blitting - Dirty blitting - Bitmap armatures - MovieClip caching - Mobile rendering
  • 12. AGENDA - Traditional rendering - Blitting techniques - Full stage blitting - Partial blitting - Dirty blitting - Bitmap armatures - MovieClip caching - Mobile rendering - Stage 3D
  • 13. AGENDA - Traditional rendering - Blitting techniques - Full stage blitting - Partial blitting - Dirty blitting - Bitmap armatures - MovieClip caching - Mobile rendering - Stage 3D - New 2D framework
  • 14. A SIDE NOTE ABOUT HTML5
  • 21. DISCLAIMER There is no perfect rendering method. Choosing the right one takes experimentation and should be based on the type of content.
  • 25. TRADITIONAL RENDERING PROS - Easiest to develop - Vectors can be smoothly scaled at runtime - Non-animating clips can use cacheAsBitmap
  • 26. TRADITIONAL RENDERING PROS - Easiest to develop - Vectors can be smoothly scaled at runtime - Non-animating clips can use cacheAsBitmap CONS - MovieClips and Sprites have a lot of overhead - Can be slow with large numbers of animated objects - Can take up much more memory
  • 27.
  • 28. Most Flash games will run great simply if cacheAsBitmap is used.
  • 29. THE CRAZY WORLD OF BLITTING
  • 32. TEXTURE PACKER DISCOUNT CODE fotb2011-lee-brimelow to get 20% discount for TexturePacker and/or PhysicsEditor
  • 33. BLITTING EXPLAINED BitmapData Sprite sheet ls Pixe copy
  • 35. BLITTING STEPS 1 Create pre-rendered sprite sheet of animations
  • 36. BLITTING STEPS 1 Create pre-rendered sprite sheet of animations 2 Add single BitmapData canvas to the display list
  • 37. BLITTING STEPS 1 Create pre-rendered sprite sheet of animations 2 Add single BitmapData canvas to the display list 3 Copy the background into the canvas or erase
  • 38. BLITTING STEPS 1 Create pre-rendered sprite sheet of animations 2 Add single BitmapData canvas to the display list 3 Copy the background into the canvas or erase 4 Copy any game sprites into the canvas
  • 39. BLITTING STEPS 1 Create pre-rendered sprite sheet of animations 2 Add single BitmapData canvas to the display list 3 Copy the background into the canvas or erase 4 Copy any game sprites into the canvas 5 Repeat steps 3 and 4 inside of main game loop
  • 40. TIP Be sure to call bitmapData.lock() before doing multiple copyPixel calls to prevent unnecessary updating, followed by bitmapData.unlock().
  • 42. COPYPIXELS VS DRAW Best performance
  • 43. COPYPIXELS VS DRAW Best performance Most exible (Sprites can be transformed and use blend modes)
  • 44. TIP If you game is fully blitted you can set the stage quality to low.
  • 45. FULL STAGE BLITTING BitmapData - Single bitmapData canvas on display list - All sprites are blitted to this single canvas - Good for large number of animated sprites
  • 46. DEMO
  • 47. So when should you use full blitting for your game?
  • 48.
  • 50. BUT SERIOUSLY Fast action scrollers
  • 51. BUT SERIOUSLY Fast action scrollers Tile-based games
  • 52. Creating games using the HTML5 canvas element uses these same blitting techniques. The canvas tag is similar to a bitmapData object in Flash.
  • 53. DIRTY BLITTING BitmapData - Store the previous frames rectangle - Then only repaint dirty regions of the background
  • 54. PARTIAL BLITTING Stage Bitmap Bit ma p ap B itm Bit m ap - Each sprite is blitted to individual bitmapData - Bitmap objects can be easily transformed - Good tradeoff between exibility and performance
  • 55. DEMO
  • 56. BITMAP ARMATURES Instead of drawing a unique illustration for each frame of the model's animation, armature models are drawn as a series of body parts that move in relationship to each other just like the bones in your skeleton.
  • 57. DEMO
  • 59. WHICH TECHNIQUE TO USE FULL BLITTING Best when frequent redraws of the entire screen are required. Think fast-action side scrollers like Canabalt.
  • 60. WHICH TECHNIQUE TO USE FULL BLITTING Best when frequent redraws of the entire screen are required. Think fast-action side scrollers like Canabalt. PARTIAL BLITTING Great choice when frequent redraws of the entire screen are not required. Also much easier to do transforms and does not require pre-rotated sprite sheets.
  • 61. WHICH TECHNIQUE TO USE FULL BLITTING Best when frequent redraws of the entire screen are required. Think fast-action side scrollers like Canabalt. PARTIAL BLITTING Great choice when frequent redraws of the entire screen are not required. Also much easier to do transforms and does not require pre-rotated sprite sheets. ARMATURE MODELS Best choice when a large number of customizable characters are required. RPGs are a classic example of this.
  • 63. RUNTIME MOVIECLIP CACHING Array of BitmapData
  • 64.
  • 65. var s:snake = new snake();
  • 66. var s:snake = new snake(); for(var i:int=1; i<s.totalFrames; i++)
  • 67. var s:snake = new snake(); for(var i:int=1; i<s.totalFrames; i++) {
  • 68. var s:snake = new snake(); for(var i:int=1; i<s.totalFrames; i++) { var bmd:BitmapData = new BitmapData(s.width, s.height);
  • 69. var s:snake = new snake(); for(var i:int=1; i<s.totalFrames; i++) { var bmd:BitmapData = new BitmapData(s.width, s.height); s.gotoAndStop(i);
  • 70. var s:snake = new snake(); for(var i:int=1; i<s.totalFrames; i++) { var bmd:BitmapData = new BitmapData(s.width, s.height); s.gotoAndStop(i); bmd.draw(s);
  • 71. var s:snake = new snake(); for(var i:int=1; i<s.totalFrames; i++) { var bmd:BitmapData = new BitmapData(s.width, s.height); s.gotoAndStop(i); bmd.draw(s); frames.push(bmd);
  • 72. var s:snake = new snake(); for(var i:int=1; i<s.totalFrames; i++) { var bmd:BitmapData = new BitmapData(s.width, s.height); s.gotoAndStop(i); bmd.draw(s); frames.push(bmd); }
  • 79. TWO RENDERING MODES CPU - Everything is rendered in software - Use this mode for fully blitted games - Good performance on iOS
  • 80. TWO RENDERING MODES CPU - Everything is rendered in software - Use this mode for fully blitted games - Good performance on iOS GPU - Bitmaps are automatically rendered using the GPU - Text and vectors can use cacheAsBitmapMatrix - Most all games should be rendered in this mode
  • 81. CACHING VECTORS Application XML Vector content
  • 82. TIP Objects on the GPU are automatically anti-aliased so you can set the stage quality to low.
  • 83. DEMOS
  • 85. PERFORMANCE TIPS - Keep the display list as at as possible
  • 86. PERFORMANCE TIPS - Keep the display list as at as possible - Utilize blitting or partial blitting where appropriate
  • 87. PERFORMANCE TIPS - Keep the display list as at as possible - Utilize blitting or partial blitting where appropriate - Use object pools to avoid instantiation costs
  • 88. PERFORMANCE TIPS - Keep the display list as at as possible - Utilize blitting or partial blitting where appropriate - Use object pools to avoid instantiation costs - Use cacheAsBitmapMatrix for any non-changing vectors
  • 89. PERFORMANCE TIPS - Keep the display list as at as possible - Utilize blitting or partial blitting where appropriate - Use object pools to avoid instantiation costs - Use cacheAsBitmapMatrix for any non-changing vectors - Just say no to using lters
  • 90. PERFORMANCE TIPS - Keep the display list as at as possible - Utilize blitting or partial blitting where appropriate - Use object pools to avoid instantiation costs - Use cacheAsBitmapMatrix for any non-changing vectors - Just say no to using lters - Test early and often on actual devices
  • 91. PERFORMANCE TIPS - Keep the display list as at as possible - Utilize blitting or partial blitting where appropriate - Use object pools to avoid instantiation costs - Use cacheAsBitmapMatrix for any non-changing vectors - Just say no to using lters - Test early and often on actual devices - Use pro ling tools to nd bottlenecks
  • 94. STAGE 3D Formally known by the code name Molehill.
  • 95. STAGE 3D Formally known by the code name Molehill. Stage 3D is a new GPU-accelerated rendering engine for the Flash Player. This enables console-level 2D and 3D graphics for games.
  • 96. PREDICTION Stage 3D is faster than any other rendering technique and it will become the de-facto standard for Flash games.
  • 97. PREDICTION Stage 3D is faster than any other rendering technique and it will become the de-facto standard for Flash games. But it isn’t released yet and will not be available on mobile for a little while.
  • 98. INTEGRATION display list wmode=direct is required
  • 99. LOW-LEVEL STAGE 3D //
setup
backbuffer
(level
1
aa,
z
buffer
on)
 context3D.configureBackBuffer(
stage.stage3Ds[0].viewPort.width,
stage.stage3Ds[0].viewPort.height,
1,
true
); //
create
a
vertex
buffer vertexbuffer
=
context3D.createVertexBuffer(
3,6
); vertexbuffer.uploadFromVector
(
Vector.<Number>([


 
 
 
 
 ‐1,‐1,0,

255/255,0,0,

 
 
 
 
 
 0,1,0,



193/255,216/255,47/255,

 
 
 
 1,‐1,0,


0,164/255,228/255







 
 
 ]),0,
3
);
//
start
at
offset
0,
count
3
 //
create
an
index
buffer.
this
is
just
identity indexbuffer
=
context3D.createIndexBuffer
(
3
); indexbuffer.uploadFromVector
(
Vector.<uint>(
[
0,
1,
2
]
),
0,
3
);
//
start
at
offset
0,
count
3 //
create
a
vertex
and
fragment
program
‐
from
assembly var
vertexShaderAssembler
:
AGALMiniAssembler
=
new
AGALMiniAssembler(); vertexShaderAssembler.assemble(
Context3DProgramType.VERTEX,
 
 "m44
op,
va0,
vc0
 
 n"
+
/
4x4
matrix
transform
 / 
 "mov
v0,
va1
 
 
 n"


/
copy
stream
1
to
fragment
 / );
 
 
 
 
 
 var
fragmentShaderAssembler
:
AGALMiniAssembler=
new
AGALMiniAssembler();
 fragmentShaderAssembler.assemble(
Context3DProgramType.FRAGMENT,
 
 "mov
oc,
v0"
//
output
color

 ); 
 
 
 //
upload
the
AGAL
bytecode program
=
context3D.createProgram(); program.upload(
vertexShaderAssembler.agalcode,
fragmentShaderAssembler.agalcode
);

  • 103.
  • 105. NEW OPEN-SOURCE PROJECT Adobe is working on an open-source, 2D ActionScript API that leverages GPU acceleration using Stage 3D. This new API is based on the existing Flash display list, making it very easy for ActionScript developers to learn.
  • 107.
  • 108. var frames:Vector.<Texture> = getTextureAtlas().getTextures("snake");
  • 109. var frames:Vector.<Texture> = getTextureAtlas().getTextures("snake"); var hero:MovieClip = new MovieClip(frames, 60);
  • 110. var frames:Vector.<Texture> = getTextureAtlas().getTextures("snake"); var hero:MovieClip = new MovieClip(frames, 60); hero.x = Math.random() * 800;
  • 111. var frames:Vector.<Texture> = getTextureAtlas().getTextures("snake"); var hero:MovieClip = new MovieClip(frames, 60); hero.x = Math.random() * 800; hero.y = Math.random() * 600;
  • 112. var frames:Vector.<Texture> = getTextureAtlas().getTextures("snake"); var hero:MovieClip = new MovieClip(frames, 60); hero.x = Math.random() * 800; hero.y = Math.random() * 600; addChild(hero);
  • 113.
  • 115. DISPLAY EVENTS DisplayObject EnterFrameEvent Button KeyboardEvent Image ResizeEvent MovieClip TouchEvent Sprite
  • 116. DISPLAY EVENTS TEXT DisplayObject EnterFrameEvent BitmapFont Button KeyboardEvent TextField Image ResizeEvent MovieClip TouchEvent Sprite
  • 120.
  • 122.

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n