13. Re-usable loosely coupled code
Target multiple scene nodes with a single script
Easily build and share your own library of useful scripts
Easily fetch and use the communities code snippets
// only 1 script
var kbScript : KeyboardMoveScript = new KeyboardMoveScript();
// but it controls 2 targets
cube.addController(kbScript);
sphere.addController(kbScript);
14. Easy access to
Mouse/keyboard properties and signals
time, deltaTime
Scene
A lot of other properties useful to script stuff…
// if the right arrow key is down…
if (keyboard.keyIsDown(Keyboard.RIGHT))
target.transform.appendTranslation(.1);
15. Similar to Event.ENTER_FRAME but
Lighter
Customisable per-script « frame rate »
// execute this script only once per second
this.framerate = 1;
16. Example: move objects with the
keyboard
public class KeyboardMoveController extends AbstractScriptController
{
override protected function update(target : ISceneNode) : void
{
if (keyboard.keyIsDown(Keyboard.RIGHT))
target.transform.appendTranslation(.1);
if (keyboard.keyIsDown(Keyboard.LEFT))
target.transform.appendTranslation(-.1);
if (keyboard.keyIsDown(Keyboard.UP))
target.transform.appendTranslation(0., .1);
if (keyboard.keyIsDown(Keyboard.DOWN))
target.transform.appendTranslation(0., -.1);
if (keyboard.keyIsDown(Keyboard.PAGE_UP))
target.transform.appendTranslation(0., 0., .1);
if (keyboard.keyIsDown(Keyboard.PAGE_DOWN))
target.transform.appendTranslation(0., 0., -.1);
}
}
17. Usage
// instanciate the script
var kbScript : KeyboardMoveScript = new KeyboardMoveScript();
// add the script to a target
cube.addController(kbScript);
// remove the script from a target
cube.removeController(kbScript);
18. More about scripts and controllers…
Write your first controller
A Script To Move Objects With The Keyboard
Handle Mouse Focus With A Script
Switching Material With a Controller
Create Procedural 3D Animations
22. 1992 2001 2004 2011
Mortal Kombat GTA III Doom 3 Crysis 2
1996
Evolution of shader languages
23. What about AGAL?
1992 2001 2004 2011
Mortal Kombat GTA III Doom 3 Crysis 2
1996
Language Features
24. In 1992, Flash was called FutureSplash Animator and written by a single man: Jonathan Gay
25. learning AGAL != learning GPU programming
AGAL is awesome for 3D engines developers
Low-level binary assembly code
Cross-platform
AGAL is a nightmare for 3D applications
developers
26. With Minko you can program the GPU
using ActionScript 3.0 !
27.
28. Minko embedded JIT
Compiler
Shader ByteCode
ActionScript Shader
Code
public class MyShader
{
public function getVertexPosition() : SFloat
{
return localToScreen(vertexXYZ);
}
public function getPixelColor() : SFloat
{
return sampleTexture(
meshBindings.getTextureParameter(‘texture’),
interpolate(vertexUV)
);
}
}
m44 vt0, va0, vc0
m44 vt0, vt0, vc5
mov oc, vt0
mov v0, va1
tex ft0, v0 <linear,2d>
mov oc, ft0
at runtime compilation
29. ActionScript
Shader
•Use all ActionScript 3.0 features
•getOutputPosition => Vertex Shader
•getOutputColor => Fragment Shader
•OOP style
•CPU/GPU balancing
ASG
•Abstract Shader Graph
•Optimizations
•Constants and temporary registers
allocation
•Operations re-ordering for faster
execution and optimal use of temporary
registers
AGAL
•Direct bytecode generation at runtime
•Custom compiler
•Optional debug data
•AGAL assembly output
•Shader graph output
•Memory allocation map
Execution
Full AS3 workflow
Conditionnals and loops
Classes and methods
Dynamic OOP coding style
Exhaustive AGAL implementation
Extra high-level operations set
Re-usable « shader parts »
Shaders compiled at-runtime
Just like any other AS3 code
Dynamic according to
The scene properties
The mesh properties/material
Any constant, variable, etc…
Redistributable as SWF/SWC files
31. ACTIONSCRIPT IS NOW
THE MOST POWERFUL
SHADER LANGUAGE
(as a language, but not GPU feature wise because of Stage3D limitations )
32. More about shaders…
JIT shaders for better performance
Create your first shader
Understanding vertex to fragment
interpolation
Get ActionScript shaders compilations logs
Create a shader rendering per-pixel normals
Create a « black and white » post-processing
effect
40. MK File Format
Fully optimized for Minko
More suitable for web/mobile apps in general
Binary
Light
Zip, deflate or LZMA
Readable with AS3, PHP, C++ and JavaScript
41. More about the editor…
Normal mapping and specular maps
Importing Collada files
46. Fast, robust and extensible
Create new kind of forces, force fields…
Add specialized shapes and collision detection
algorithms
Comprehensive set of shapes
Box, sphere, cone, cylinder…
Triangle mesh
Convex hull
Heightmap
Triggers for scripting
47.
48.
49.
50.
51.
52.
53. // listen to the Collider.collisionStarted signal
redGoalCollider.collisionStarted.add(
function (collision : CollisionStarted) : void
{
_numPointB++;
resetBall();
}
);
// do the same for Collider.collisionStopped…
Working with triggers
54. Best practice: implement triggers using scripts.
You will soon be able to bind them directly in the editor!
56. MK Optimizations
A new file format for 3D content
Readable with AS3, PHP, C++ and JavaScript
Optimized for the web
Lossy and lossless 3D compression
3D streaming (WIP)
Optimized for mobile devices
Automated shape-conservative 3D simplification
Fast implementation
Automated ATF compression for textures