33 milliseconds in hell - derschmale.com · recursively divide an expensive task in smaller sized...
TRANSCRIPT
33 milliseconds in hellDamn you 30 fps!
Introduction33 milliseconds in hell
Brief summaryReal time effects: 30 – 60 fps
Limitations Flash Player (oldskool, yo)
Tips & tricks
Mindset
Examples + demos
Commodore 64 (BASIC) PC
Doom, Quake, ...id Software nut: Carmack FTW (@ID_AA_Carmack)90's PC demo scene
Real-time effects2D & 3D graphical programming
Turbo Pascal, C/C++ (DOS: 0xa000)
Flash MXjust like the old days
IntroductionOff the beaten path
Down memory lane
2D + 3D graphical effects
Visual simulations
ActionScript / Pixel Bender / C++ (Alchemy)
Creating visual effects, not art
Introduction33 milliseconds in hell
The present
The boring bits33 milliseconds in hell
IntelliJ, FDT, Flash Builder, ...
Productivity: code less, think more
Refactoring support + code generation
Overview on code
Profiler (Flash Builder, FDT)
Toolset33 milliseconds in hell
IDE
Version: 9 vs 10 vs 10.1
Convince your clients!
Debug vs Release Player
Toolset33 milliseconds in hell
Flash player
Toolset33 milliseconds in hell
Other toolsPixel Bender toolkit / Joa Ebert's PBDT
http://blog.joa-ebert.com/pbdt/
Alchemy
Joa Ebert's Apparat suitehttp://apparat.googlecode.com
Know your tools!
Recursively divide an expensive task in smaller sized subtasks
Divide → Solve → Combine → Conquer
Example: merge sort
Conceptual33 milliseconds in hell
Divide & Conquer vs Brute Force
Conceptual33 milliseconds in hell
D&C: Merge sort
Conceptual33 milliseconds in hell
Get lazy, escape earlyAvoid expensive tasks: is the task even necessary?
Check necessity with a cheaper test(s)
Example:
Which of 100 objects am I hitting?
→ Am I even CLOSE to an object?
Conceptual33 milliseconds in hell
Get lazy, escape earlyCan work even better with Divide and Conquer approach
Conceptual33 milliseconds in hell
Get lazy, escape earlyCan work even better with Divide and Conquer approach
The fun bits33 milliseconds in hell
Faking it33 milliseconds in hell
You faked it?!Of course: All real time effects are fake in a sense
Creating something that works with strict preconditions
Baked lighting (Away3D + Prefab3D)
Casting shadows
Surmounting scale33 milliseconds in hell
Render loop
Surmounting scale33 milliseconds in hell
Render loopTransform and projection cost increases per vertex
Sort and draw cost increases with triangle count
In a huge scene, we're screwed, right?
Surmounting scale33 milliseconds in hell
Binary Space Partitioning (BSP)No sorting
Divide & Conquer
Split scene recursively until we have parts that need no sorting
Simply draw parts in correct order
Precomputed
Also speeds up collision detection
Surmounting scale33 milliseconds in hell
Potentially Visible Set (PVS)Early escape: reduce triangle and vertex count
Which parts in a BSP tree could never be seen from other parts?(per part: simply keep lists of potentially visible parts)
Find the part containing the camera
Only render the parts in the visibility list
Surmounting scale33 milliseconds in hell
BSP/PVS in Away3DObsolete on desktop
Great for Flash!
Generated by Prefab3D
http://www.closier.nl/prefab/
http://www.influxis.com/battlecell/
Pixel bender33 milliseconds in hell
Pixel Bender basics0 or more images → 1 output image
Function per output pixel (so no random access)
Multicore
Can apply it as filter to Flash 3D
Pixel bender33 milliseconds in hell
Away3D shaders
Apply Pixel Bender on a texture
Position and direction data needed,encoded in bitmaps (rgb ~ xyz)
Problem: only static meshes
Pixel bender33 milliseconds in hell
Away3D shaders
Pixel bender33 milliseconds in hell
Dynamic meshes
Procedurally generating position map
Calculate normal map from that
Update mesh according to position mapl
Pixel bender33 milliseconds in hell
Chaining
Chain together several pixel bender effects
Output previous effect is next input
Field-based physic simulations
Pixel bender33 milliseconds in hell
Isosurfaces
Surface of equal values
Cfr weather report (2D)
Pixel bender33 milliseconds in hell
Marching cubes
Don't use Pixel Bender to output image
Number crunching (isovalues, surface normals, ...)
Procedurally create triangles
Order of triangle creation → no sorting or transform needed
→ much higher polycount
Also check: Frank Reitberger – http://prinzipiell.com/
Pixel bender33 milliseconds in hell
Marching cubes: render loop
Demo: Metaballs / Julia Set
Alchemy33 milliseconds in hell
Adobe Alchemy
Compile C/C++ code to ABC
Access fast memory
GCC/G++ does a lot of code optimizing
The last bits33 milliseconds in hell
What, when, how33 milliseconds in hell
What to optimizePretty code vs fast code
Inlining methods1-lining statements
Algorithms/Data structuresThe bigger pictureDivide & ConquerTree structures (BSP, Quadtree Raytracer)Can have most impact on performance
What, when, how33 milliseconds in hell
When to optimizePretty code vs fast code
Wait as long as you canWhen it works
Algorithms/Data structuresUp front“This is going nowhere”Changing tools can cause change of algorithms
The devil in the 9th circle33 milliseconds in hell
WorkflowDesigners vs Developers
Sit together from the get-go
A linear hand-over approach does not work
Give and take
Mediator: director
Closing off33 milliseconds in hell
Evoflash – Spiral OutSimo Santavirta – http://www.simppa.fi
Evoflash – http://evo.bombsquad.org
Real-time “demo-scene” demo in Flash
#1 at Assembly 2010 \m/
Thank you!33 milliseconds in hell
Questions?
David Lenaertswww.derschmale.com
twitter.com/DerSchmale