adding more visuals without affecting performance
TRANSCRIPT
Adding more visuals to the game without affecting performance
by Dmytro Vovk
PERFORMANCE
Performance
• Why it matters?!
Performance
• Is a shared responsibility of both artists and programmers.
Good Enough
• Don’t do more that it’s needed
TECHNICAL TIPS FOR ART
Technical Artist
• Is a bridge between you and a programmers.• They are usually responsible for technical side
of art and a performance.• Availability of TA in your team doesn’t mean,
that you don’t have to understand tech.
Performance Killers
• Draw calls• Alpha blending• Huge textures
Draw Call
• A command to GPU to render a set of vertices (mesh) with specified state – i.e. textures, shader, blend mode
Draw Call
• Employ texture atlases – a set of small textures combined into big one
• Merge static meshes into one
Texture Atlas
Alpha Blending
• Is the process of combining an image with a background to create the appearance of partial or full transparency.
• Most common blend mode in 2D games.• Most common source of performance
problems also
Alpha Blending
• Alpha blending makes impossible to utilize some hardware optimizations, so it requires both visible and invisible pixels to be processed.
• In extreme cases this can be an order of magnitude slower
Alpha Blending
• The majority of 2D games do not use translucent geometry i.e. alpha value of every pixel in textures is either 0 or 255.
Alpha Blending
• So the pixels with alpha equal to 0 will not contribute to resulting image at all, but they still have to be processed
• And the pixels with alpha equal to 255 will replace any pixel that existed in the background image before, but it still requires those replaced pixels to be processed.
Alpha Blending
• So sprites with huge transparent areas will affect performance a lot.
• This can be solved with a “proper” art
Alpha Blending
• Replace sprite quads with more complex geometry:
Alpha Blending
• Split geometry into two meshes – one alpha blended (blue), one – opaque (red):
Textures
• Textures are the biggest resources in the games.
• Apps are bound by 50 Mb app size limit.• The amount of available GPU memory can be
even lower on a low end device
Textures
• RGB8 texture will occupy the same amount of memory as RGBA8 on most devices.
• Try to lower textures precision – RGB565 instead of RGB888, RGBA5551 instead of RGBA8888, etc.
• Compressed textures are more preferred though.
Compressed Textures
• A texture compressed with a special lossy algorithm optimized for GPU.
• PNG is a lossless compressed image format. Why do you have to use something else?
Texture VS File Compression
• On a disk: PNG (600Kb): PVRTC\DXT\ETC (128Kb):
Texture VS File Compression
• In RAM: PNG (1Mb): PVRTC\DXT\ETC (128Kb):
Texture VS File Compression
• In VRAM: PNG (1Mb): PVRTC\DXT\ETC (128Kb):
Compressed Textures
• So compressed textures are preferable since they are:– Smaller, allow you to have more textures in the
game;– Internally optimized for GPU;– Faster to upload\stream to GPU;– Faster to render;
• They are not always applicable for 2D games
Key Action Points
• Reduce the number of draw calls• Avoid alpha blended geometry as much as
possible• Try to compress your textures
Best practices
• Employ engineering best practices:– Introduce Definition of Done. DoD is a checklist of
valuable activities;– Introduce a Sign Off process;– Talk to your TA, talk to other TA’s;– Talk to your programmers;– Self educate.
BONUS
Alpha test
– Alpha test effects performance heavily;– Use alpha blend instead;– If you still need to use alpha test, try to mimic it
with geometry
Alpha test
• If it’s too hard to avoid alpha test with tessellated geometry, try to localize it into as small region, as possible*
Alpha test
• All engines allow you to control the draw order of your geometry. To get the best performance possible, try do draw you geometry in this order:– Opaque geometry;– Alpha tested geometry;– Alpha blended geometry;