4. http://soccerpun.ch
Full 3D game built with Minko in just 48h!
http://www.youtube.com/watch?v=Hv0cp4NwSoY
Your smartphone is the gamepad: up to 8 players!
All assets hanlded through the editor
Imported from 3DS Max
Editor available for free on http://minko.io
Physics rigging in a few clicks
Extensive use of particles
Designed with the new particles editor
Running with a new C++ particles engine
7. … and now!
What are shaders?
Why is AGAL hard to work with and what
solutions does Minko provide?
A few simple shader examples
Hardware accelerated particles with shaders
Particles engine and editor!
9. Hardware specific shader bytecode
Program3D
AGAL bytecode
Vertex Shader Fragment Shader
GLSL/HLSL
Program3D
PixelBender3D AGAL assembly
ActionScript3FlashHardware
10.
11.
12. Program3D – Vertex Shader
va1.x va1.y 0 0 …
x y z w …
v0 …
Varying
Registers
IndexBuffer3D
-5 -5 0 0 1 0 5 0 0 0.5 5 -5 0 1 1 …
x y z u v x y z u v x y z u v x
VertexBuffer3D
0 1 2
0 2 1 …
InputProgramOutput
0 (-5, -5, 0)
1 (0, 5, 0)
2 (5, -5, 0)
15. 1992 2001 2004 2011
Mortal Kombat GTA III Doom 3 Crysis 2
1996
Evolution of shader languages
16. What about AGAL?
1992 2001 2004 2011
Mortal Kombat GTA III Doom 3 Crysis 2
1996
Language Features
17. In 1992, Flash was called FutureSplash Animator and written by a single man: Jonathan Gay
18. Simple scene use case
How many shaders?
Shadows
Lights
Animations
19. How many « possible shaders » ?
Handle 0 to 8 joints
With normals
With tangents
Handle 0 to 5 lights
With bump-mapping or not
Handle shadows
(9 x 3 x 6 x 2 x 2)²
= 419904 different shaders!
• To write
• To test
• To debug
• To maintain
• To distribute
• To adapt
• …
21. 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
22. With Minko you can program the GPU
using ActionScript 3.0 !
23.
24. 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
25. 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
26. public class RedShader extends Shader
{
override protected function getVertexPosition() : Sfloat
{
return worldToScreen(localToWorld(vertexXYZ));
}
override protected function getPixelColor() : SFloat
{
return float4(1, 0, 0, 1);
}
}
RedShader – Step 1: AS3
39. interpolate()
Fragment Shader
Varying Registers
Vertex Shader
vertex0
x y r g b
Vertex Shader Output
Varying Registers
Vertex Shader
vertex1
x y r g b
Vertex Shader Output
Varying Registers
Vertex Shader
vertex2
x y r g b
Vertex Shader Output
Pixel Shader Output
Linear
Interpolation
color
x y z w
Linear
Interpolation
vertex0
vertex1vertex2
40. Particles
1. Fill vertex buffer with batched « quads »
2. (optional) Edit quads position on the CPU
State-related animations
3. Render all the quads in a single draw call
Stateless position/size/rotation animation in the
vertex shader
Stateless color animation in the fragment shader
44. Vertex shader logic
1. Transform quad center to view space
2. Add offset (~= corner position) to the view space
quad center
3. Apply rotation
4. Project on the screen
45. Particule Properties
Each particle can have many properties!
Start/end color
Start/end velocity
Start/end force
…
Particles design can be done with code…
… but it is much more efficient with an editor!
46. Particle Editor
Full WYSIWYG particles editor!
http://www.youtube.com/watch?v=tyW2RUm2naI
Stay tuned for the release (June)
Follow @Minko3D
Read http://minko.io