sergey gonchar - fast rendering with starling
TRANSCRIPT
Stage3D API• Since 2011 (Flash Player 11)
• Unified API for managing texture memory, vertex shading, pixel shading, and mesh rendering
• Transparently executed using OpenGL and DirectX
Each frame
— clear backbuffer by calling Context3D.clear— set gpu state through Context3D API— call drawTriangles()— repeat until the scene is entirely rendered— call the present() method to display the rendered
scene on the stage. It copies the backbuffer to a framebuffer
Context3D profiles
• BASELINE_CONSTRAINED for web - windows
• BASELINE for web - mac
• MAX PROFILE for mobile
Profiling Tools• Adobe Scout
https://creative.adobe.com/ru/products/scout
• Intel GPA https://software.intel.com/en-us/gpa
• Xcode OpenGL Tools https://developer.apple.com/opengl/
• RenderDoc http://cryengine.com/renderdoc
http://gamua.com/starling/
How does QuadBatch work?
• Collects quads with the same state(same texture, blendMode, shader)
• Transforms all vertices to one space and upload to VertexBuffer
• Render
Starling VertexBufferDescr
• va0 - x,y
• va1 - r,g,b,a
• va2 - u,v
Constants approach• Create one common vertexBuffer during
application init, upload data once
• Batch quads and images by the same state and set program constants array(x,y,width,height,uv,tintcolor,rotation)
• Render
New VertexBufferDescr
• va0 - x,y,index
How does it work?
PixelPerfect Touch CPU Approach
• hitTest Quads
• hitTest texture
• repeat until find
PixelPerfect Touch GPU!
• Use simple shader which renders images with single color
• Optimization: collect candidates by bounds
• Render targets to 1x1 texture on desktop or 4x4 texture on mobile
• Read back & sample color from texture
Scene
Touch test
Books
http://www.amazon.com/Practical-Rendering-Computation-Direct3D-11/dp/1568817207
http://www.amazon.com/Adobe-Stage3D-Molehill-Programming-Beginners/dp/1849691681
Thank you!
• Blog http://gonchar.me/
• Follow me http://twitter.com/UnknownFlasher
• Stage3D http://facebook.com/groups/stage3d
• FlashDaily http://flashdaily.net