adding more visuals without affecting performance

35
Adding more visuals to the game without affecting performance by Dmytro Vovk

Upload: st1x

Post on 11-Apr-2017

196 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Adding more visuals without affecting performance

Adding more visuals to the game without affecting performance

by Dmytro Vovk

Page 2: Adding more visuals without affecting performance

PERFORMANCE

Page 3: Adding more visuals without affecting performance

Performance

• Why it matters?!

Page 4: Adding more visuals without affecting performance
Page 5: Adding more visuals without affecting performance
Page 6: Adding more visuals without affecting performance

Performance

• Is a shared responsibility of both artists and programmers.

Page 7: Adding more visuals without affecting performance

Good Enough

• Don’t do more that it’s needed

Page 8: Adding more visuals without affecting performance

TECHNICAL TIPS FOR ART

Page 9: Adding more visuals without affecting performance

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.

Page 10: Adding more visuals without affecting performance

Performance Killers

• Draw calls• Alpha blending• Huge textures

Page 11: Adding more visuals without affecting performance

Draw Call

• A command to GPU to render a set of vertices (mesh) with specified state – i.e. textures, shader, blend mode

Page 12: Adding more visuals without affecting performance

Draw Call

• Employ texture atlases – a set of small textures combined into big one

• Merge static meshes into one

Page 13: Adding more visuals without affecting performance

Texture Atlas

Page 14: Adding more visuals without affecting performance
Page 15: Adding more visuals without affecting performance

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

Page 16: Adding more visuals without affecting performance

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

Page 17: Adding more visuals without affecting performance

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.

Page 18: Adding more visuals without affecting performance

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.

Page 19: Adding more visuals without affecting performance

Alpha Blending

• So sprites with huge transparent areas will affect performance a lot.

• This can be solved with a “proper” art

Page 20: Adding more visuals without affecting performance

Alpha Blending

• Replace sprite quads with more complex geometry:

Page 21: Adding more visuals without affecting performance

Alpha Blending

• Split geometry into two meshes – one alpha blended (blue), one – opaque (red):

Page 22: Adding more visuals without affecting performance
Page 23: Adding more visuals without affecting performance

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

Page 24: Adding more visuals without affecting performance

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.

Page 25: Adding more visuals without affecting performance

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?

Page 26: Adding more visuals without affecting performance

Texture VS File Compression

• On a disk: PNG (600Kb): PVRTC\DXT\ETC (128Kb):

Page 27: Adding more visuals without affecting performance

Texture VS File Compression

• In RAM: PNG (1Mb): PVRTC\DXT\ETC (128Kb):

Page 28: Adding more visuals without affecting performance

Texture VS File Compression

• In VRAM: PNG (1Mb): PVRTC\DXT\ETC (128Kb):

Page 29: Adding more visuals without affecting performance

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

Page 30: Adding more visuals without affecting performance

Key Action Points

• Reduce the number of draw calls• Avoid alpha blended geometry as much as

possible• Try to compress your textures

Page 31: Adding more visuals without affecting performance

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.

Page 32: Adding more visuals without affecting performance

BONUS

Page 33: Adding more visuals without affecting performance

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

Page 34: Adding more visuals without affecting performance

Alpha test

• If it’s too hard to avoid alpha test with tessellated geometry, try to localize it into as small region, as possible*

Page 35: Adding more visuals without affecting performance

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;