SlideShare ist ein Scribd-Unternehmen logo
1 von 58
Downloaden Sie, um offline zu lesen
LWF	
  in	
  real	
  life:	
  	
  
「どうぶつフレンズ」の開発事例	
David	
  Gavilan	
  
david.gavilan@gree.net	
  
GREE
Agenda	
  	
•  About	
  “Animal	
  Days”	
  
•  About	
  LWF	
  
•  Texture	
  packing	
  
•  Common	
  boFlenecks	
  
•  Profiling	
  your	
  game	
  
•  InvesJgaJng	
  leaks	
  
•  OpJmizaJons
Animal	
  Days	
  /	
  どうぶつフレンズ	
•  2D	
  Game	
  
•  Current	
  plaOorm:	
  Android	
  2.2	
  and	
  up	
  
•  Categories:	
  City	
  building	
  &	
  breeding	
  simulaJon	
  
•  Main	
  tech	
  on	
  the	
  client	
  
– Unity	
  3.5.7,	
  4.0	
  latest	
  (4.1	
  for	
  Profiling)	
  
– LWF	
  
– Webview	
  
•  Tools:	
  TexturePacker,	
  Xcode,	
  ADB
PV	
Animal	
  Days
LWF	
Animal	
  Days
•  Open-­‐source	
  Lightweight	
  SWF:	
  
– hFp://gree.github.com/lwf	
  
– Developed	
  by	
  Kazuki	
  Sakamoto	
  @splhack	
  at	
  GREE	
  
.fla/.swf	
  →	
  .lwf	
I	
  am	
  a	
  
GameObject	
  !
LWF	
  data	
  creaJon	
•  .fla/.swf	
  →	
  .lwf	
  
– 1-­‐step	
  script-­‐based	
  conversion	
  →	
  can	
  be	
  easily	
  
batched	
  
– Can	
  customize	
  the	
  texture	
  and	
  data	
  loaders,	
  
– Can	
  dynamically	
  change	
  the	
  Z-­‐posiJon	
  of	
  the	
  
movie	
  clips,	
  
– …	
  and	
  more!	
  
LWF	
  renderers	
•  DrawMeshRenderer	
  
–  For	
  a	
  given	
  frame,	
  
•  	
  N	
  movie	
  clips	
  =	
  N	
  meshes	
  =	
  N	
  draw	
  calls	
  
–  Slow,	
  but	
  there's	
  no	
  problem	
  with	
  Z-­‐sorJng	
  
–  Separate	
  textures	
  for	
  each	
  clip	
  →	
  DrawMeshRenderer	
  	
  
•  CombinedMeshRenderer	
  
–  For	
  a	
  given	
  frame,	
  	
  
•  N	
  movie	
  clips	
  =	
  1	
  mesh	
  =	
  1	
  draw	
  call	
  
–  Faster,	
  but	
  Z-­‐sorJng	
  works	
  per-­‐object	
  
–  You	
  need	
  to	
  pack	
  all	
  your	
  texture	
  in	
  a	
  single	
  texture	
  
atlas/sheet
TEXTURE	
  PACKING	
Animal	
  Days
Texture	
  packing	
•  Remember	
  this:	
  PACK	
  EVERYTHING	
  
•  We	
  use	
  TexturePacker:	
  
hFp://www.codeandweb.com/texturepacker	
  
Texture	
  sheets	
  ♡	
  LWF	
•  Enables	
  CombinedMeshRenderer	
  
– only	
  1	
  Draw	
  Call	
  per	
  LWF	
  object	
  (worst	
  case)	
  
– if	
  the	
  objects	
  share	
  the	
  same	
  material,	
  they	
  can	
  
also	
  be	
  dynamically	
  batched	
  (N	
  objects	
  in	
  1	
  Draw	
  
Call)
Texture	
  sheets	
  ♡	
  LWF	
•  Eg.	
  Dynamic	
  batching	
  of	
  our	
  balloons
Texture	
  sheets	
  ♡	
  LWF	
•  If	
  you	
  have	
  problems	
  with	
  Z-­‐sorJng	
  (need	
  to	
  
place	
  parts	
  of	
  the	
  same	
  UI	
  before	
  and	
  behind	
  
another	
  object),	
  you	
  can	
  always	
  easily	
  switch	
  
back	
  to	
  DrawMeshRenderer	
  
Texture	
  sheets	
  ♡	
  Versioning	
•  Can	
  compare	
  the	
  changes	
  in	
  the	
  JSON	
  file	
  
•  With	
  one	
  glimpse	
  you	
  can	
  check	
  the	
  changes	
  
in	
  one	
  asset	
  over	
  github
Check	
  asset	
  changes	
  at	
  github	
Previous	
  version	
 New	
  commit
Texture	
  sheets	
  ♡	
  ProducJon	
•  Awesome	
  for	
  controlling	
  your	
  texture	
  budget!	
  
– For	
  rendering	
  and	
  for	
  bundling!	
  
•  Try	
  to	
  answer	
  these	
  quesJons:	
  
– How	
  many	
  objects	
  can	
  we	
  render?	
  
– How	
  much	
  space	
  is	
  taken	
  by	
  UI	
  elements?	
  
– How	
  long	
  does	
  it	
  take	
  to	
  download	
  all	
  the	
  assets?
Texture	
  sheets	
  ♡	
  ProducJon	
•  Once	
  you	
  decide	
  your	
  budget,	
  make	
  scripts	
  to	
  
automaJcally	
  popup	
  warnings/errors:
Texture	
  sheets	
  ♡	
  ProducJon	
•  Pack	
  all	
  your	
  texture	
  sheets	
  in	
  a	
  single	
  texture	
  
for	
  visualizaJon	
  
– Easily	
  detect	
  assets	
  using	
  too	
  much	
  space	
  
– Good	
  to	
  check	
  the	
  amount	
  of	
  "empty	
  space"	
  
– Good	
  to	
  explain	
  to	
  directors	
  and	
  arJsts	
  the	
  goods	
  
and	
  wrongs
Eg.	
  Detect	
  “outliers”	
Why	
  are	
  
these	
  assets	
  
so	
  big?
Eg.	
  How	
  much	
  space	
  can	
  we	
  save	
  by	
  
allowing	
  textures	
  to	
  be	
  of	
  any	
  size?
Eg.	
  Tell	
  arJsts	
  where	
  to	
  cut	
This	
  texture	
  alone	
  is	
  
256×1200	
  pixels!!
Eg.	
  Tell	
  arJsts	
  where	
  to	
  cut	
•  Use	
  affine	
  transforms	
  
to	
  enlarge/bend	
  
graphics	
  
•  Use	
  vertex	
  colors	
Replaced	
  the	
  background	
  
by	
  a	
  few	
  colored	
  pixels	
  
BOTTLENECKS	
  &	
  PROFILING	
Animal	
  Days
Common	
  boFlenecks	
•  Rendering	
  
– For	
  a	
  2D	
  game,	
  fill-­‐rate	
  is	
  probably	
  the	
  most	
  
common	
  rendering	
  boFleneck	
  
– Reduce	
  number	
  of	
  draw	
  calls	
  
– Reduce	
  render	
  area	
  
•  Object	
  updates	
  
– Update	
  only	
  when	
  necessary	
  
•  Network	
  access	
  
– Reduce	
  data	
  size	
  →	
  smaller	
  textures
Profiling	
  your	
  game	
•  Pick	
  up	
  a	
  slow	
  device	
  
– Even	
  if	
  you	
  target	
  a	
  high-­‐spec	
  device,	
  in	
  slow	
  
devices	
  the	
  boFlenecks	
  are	
  easier	
  to	
  spot	
  
– Eg.	
  We	
  target	
  ~Samsung	
  Galaxy	
  S2,	
  but	
  I	
  use	
  
Sharp	
  IS03	
  for	
  profiling
Profiling:	
  Unity	
  Profiler	
•  First,	
  check	
  CPU	
  usage	
  in	
  the	
  device
Profiling:	
  Unity	
  Profiler	
•  Once	
  you	
  locate	
  a	
  boFleneck,	
  use	
  Deep	
  
Profiling	
  on	
  the	
  Editor,	
  
1.  Locate	
  the	
  heavy	
  funcJon	
  
calls	
 ms
Profiling:	
  Unity	
  Profiler	
2.	
  Fix	
  
3.	
  Check	
  difference	
  	
  
ms	
-­‐10	
  ms
Profiling:	
  Game	
  window	
•  Prepare	
  debugging	
  scripts	
  so	
  you	
  can	
  easily	
  
debug	
  in	
  the	
  device,	
  even	
  without	
  Unity	
  
Profiler	
  
– Use	
  Time.deltaTime	
  to	
  create	
  a	
  simple	
  FPS	
  
counter	
  
– Create	
  a	
  custom	
  memory	
  profiler;	
  	
  
– it	
  doesn’t	
  need	
  to	
  be	
  fancy:	
  just	
  count	
  objects	
  
Custom	
  profiler	
  in	
  Game	
  window
Custom	
  profiler	
  in	
  Game	
  window	
•  Count	
  object	
  references	
  
•  Count	
  Unity	
  objects	
  (every	
  2	
  secs)	
  
•  Get	
  heap	
  usage	
  naJvely	
  
Profiling:	
  Xcode	
  instruments	
•  Even	
  if	
  you	
  are	
  not	
  releasing	
  for	
  iPhone,	
  build	
  
on	
  iPhone	
  and	
  use	
  Instruments!
Create	
  test	
  scenes	
•  Test	
  scenes	
  are	
  good	
  to	
  esJmate	
  the	
  
maximum	
  amount	
  of	
  data/assets	
  we	
  can	
  
handle/display	
  in	
  different	
  devices	
  
•  They	
  are	
  good	
  for	
  invesJgaJng	
  leaks	
  too
ASSET	
  TEST	
  DEMO	
Animal	
  Days
MEMORY	
  LEAKS	
Animal	
  Days
InvesJgaJng	
  leaks	
  with	
  adb	
•  adb	
  gives	
  you	
  important	
  informaJon!	
  (and	
  is	
  
scriptable)	
  
•  Check	
  Pss	
  (ProporJonal	
  set	
  size:	
  the	
  amount	
  
of	
  pages	
  a	
  process	
  has	
  in	
  memory)	
  
•  If	
  Pss	
  is	
  too	
  big,	
  the	
  OS	
  will	
  kill	
  your	
  app	
  →	
  
check	
  for	
  low	
  memory	
  warnings	
  
•  Eg.	
  on	
  IS03,	
  ~260MB	
  will	
  get	
  your	
  app	
  
terminated
adb	
  memory	
  informaJon	
$ adb shell dumpsys meminfo ’..animal’	
	
Applications Memory Usage (kB):	
Uptime: 573793345 Realtime: 609753074	
	
** MEMINFO in pid 1952 [com.gree.animal] **	
native dalvik other total	
size: 35000 4743 N/A 39743	
allocated: 34714 4357 N/A 39071	
free: 39 386 N/A 425	
(Pss): 10697 4232 29856 44785	
(shared dirty): 2752 4104 8380 15236	
(priv dirty): 10612 2980 15892 29484
Disable	
  objects	
  to	
  discard	
  culprits	
•  Disable	
  objects	
  and	
  repeat	
  tests
Replace	
  all	
  textures	
•  To	
  compute	
  texture	
  impact,	
  replace	
  all	
  
textures	
  by	
  very	
  small	
  ones	
  (8×8)
Count	
  references	
•  For	
  non-­‐Unity.Objects,	
  add	
  simple	
  counters	
  
for	
  your	
  debugging	
  scripts	
  
•  If	
  the	
  destructor	
  is	
  never	
  called,	
  it	
  means	
  it	
  
never	
  gets	
  GC'ed	
  !!
Nullify	
  everything	
•  Object	
  references	
  can	
  be	
  kept	
  in	
  memory	
  for	
  
obscure	
  reasons	
  (mono?).	
  Eg.	
  using	
  the	
  
argument	
  of	
  a	
  lambda	
  funcJon	
  inside	
  another	
  
lambda	
  funcJon	
  
•  As	
  a	
  general	
  pracJce,	
  set	
  to	
  null	
  the	
  
references	
  you	
  don't	
  need	
  anymore,	
  even	
  
local	
  variables	
  and	
  pointers	
  to	
  callback	
  
funcJons
Nullify	
  inside	
  closures
Nullify	
  callback	
  references
OPTIMIZATIONS	
Animal	
  Days
OpJmizaJon:	
  Object	
  updates	
•  Don't	
  update	
  objects	
  outside	
  camera	
  view	
•  Limit	
  the	
  number	
  of	
  objects	
  that	
  can	
  be	
  updated/
animated	
  
–  Eg.	
  From	
  all	
  the	
  visible	
  characters,	
  the	
  LWF	
  update	
  is	
  
called	
  for	
  N	
  at	
  most	
  
–  Change	
  N	
  depending	
  on	
  the	
  device	
  capabiliJes.	
  Eg.	
  
Nhigh_spec	
  =	
  25;	
  Nlow_spec	
  =	
  12	
  
•  Be	
  polite	
  and	
  save	
  baFery	
  
–  Only	
  use	
  60fps	
  when	
  interacJng	
  (touching	
  screen)
Rendering:	
  limit	
  max	
  drawable	
  objects	
•  Check	
  FPS	
  on	
  the	
  device,	
  and	
  take	
  note	
  of	
  the	
  
slow	
  scenes	
  
•  On	
  the	
  Editor,	
  check	
  the	
  number	
  of	
  draw	
  calls	
  
for	
  those	
  scenes.	
  
•  Eg.	
  for	
  low-­‐spec	
  devices,	
  set	
  a	
  more	
  restricJve	
  
zoom-­‐out	
  level
Rendering:	
  check	
  fill-­‐rate	
•  If	
  Camera.Render	
  is	
  slow	
  even	
  for	
  simple	
  
scenes,	
  reduce	
  the	
  resoluJon	
  of	
  the	
  
backbuffer	
  (to	
  a	
  respectable	
  DPI)	
  
Reduce	
  draw	
  calls	
  by	
  using	
  Z-­‐layers	
•  If	
  possible,	
  place	
  all	
  the	
  LWF	
  that	
  share	
  the	
  
same	
  material	
  far	
  from	
  others,	
  so	
  they	
  can	
  be	
  
dynamically	
  batched	
  
•  Eg.	
  Our	
  bubbles	
  all	
  live	
  far	
  away	
  and	
  they	
  are	
  
rendered	
  in	
  1	
  draw	
  call
…	
  when	
  aFaching	
  LWFs	
•  …	
  to	
  replace	
  a	
  movie	
  clip,	
  make	
  sure	
  the	
  clip	
  is	
  in	
  
front	
  to	
  avoid	
  Z-­‐sorJng	
  problems	
  when	
  using	
  
CombinedMeshRenderer	
3	
  draw	
  calls	
Character	
  and	
  Rainbow	
  are	
  
aFached	
  to	
  the	
  Flash	
  UI
Reduce	
  draw	
  calls	
  with	
  custom	
  2D	
•  Eg.	
  Use	
  point-­‐sampled	
  textures	
  to	
  render	
  lines	
  
and	
  grid	
  cells
Line	
  texture	
Cell	
  texture
Wrap-­‐up	
•  For	
  2D	
  games,	
  Unity	
  &	
  LWF	
  make	
  a	
  perfect	
  match	
  
•  Use	
  Texture	
  sheets	
  everywhere	
  
–  Enable	
  faster	
  rendering	
  in	
  LWF	
  
–  Good	
  for	
  controlling	
  texture	
  budgets	
  
–  Good	
  for	
  visually	
  detect	
  problems	
  
•  When	
  profiling,	
  
–  Use	
  external	
  tools	
  to	
  detect	
  real	
  problems	
  in	
  devices	
  
–  Once	
  a	
  possible	
  problem	
  is	
  detected,	
  use	
  Unity	
  Editor	
  
to	
  extract	
  as	
  much	
  informaJon	
  as	
  possible	
  and	
  for	
  
quick	
  debugging	
  
•  "Animal	
  Days"	
  is	
  cute.	
  Please	
  play!
Copyright © GREE, Inc. All Rights Reserved.
Unity  Technologies  社と包括的業務提携
GREE向けのNativeアプリケーション開発に必要なUnityプロライセンス
「Unity  Pro  +  iOS  Pro  +  Android  Pro」累累計5セットを無料料提供
GREE  Platform  SDK  for  Unityを提供
GREE  Platformが提供する各種機能をUnityアプリで実装可能
Unityを活⽤用した⾃自社タイトルを続々リリース
グリーはUnityに本気です!
Copyright © GREE, Inc. All Rights Reserved.
Do  you  want  a  challenging  job  in
a  fast-‐‑‒paced,  innovative  environment?
http://jobs.gree.net/

Weitere ähnliche Inhalte

Was ist angesagt?

Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engineDaosheng Mu
 
Authoring of procedural rocks in The Blacksmith realtime short
Authoring of procedural rocks in The Blacksmith realtime shortAuthoring of procedural rocks in The Blacksmith realtime short
Authoring of procedural rocks in The Blacksmith realtime shortVesselin Efremov
 
Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Optimization in Unity: simple tips for developing with "no surprises" / Anton...Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Optimization in Unity: simple tips for developing with "no surprises" / Anton...DevGAMM Conference
 
The Unusual Rendering Pipeline of Sigils - Battle for Raios
The Unusual Rendering Pipeline of Sigils - Battle for RaiosThe Unusual Rendering Pipeline of Sigils - Battle for Raios
The Unusual Rendering Pipeline of Sigils - Battle for RaiosDietmar Hauser
 
Rendering Tech of Space Marine
Rendering Tech of Space MarineRendering Tech of Space Marine
Rendering Tech of Space MarinePope Kim
 
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...Electronic Arts / DICE
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法Unite2017Tokyo
 
2 Dimensions Of Awesome: Advanced ActionScript For Platform Games by Iain Lobb
2 Dimensions Of Awesome: Advanced ActionScript For Platform Games by Iain Lobb2 Dimensions Of Awesome: Advanced ActionScript For Platform Games by Iain Lobb
2 Dimensions Of Awesome: Advanced ActionScript For Platform Games by Iain Lobbmochimedia
 
BSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOSBSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOSBSides Delhi
 
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化Unity Technologies Japan K.K.
 
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open ProblemsHPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open ProblemsElectronic Arts / DICE
 
Ottawa unity user_group_feb13_2015
Ottawa unity user_group_feb13_2015Ottawa unity user_group_feb13_2015
Ottawa unity user_group_feb13_2015Karman Interactive
 
Horizon Zero Dawn: The Early Days
Horizon Zero Dawn: The Early DaysHorizon Zero Dawn: The Early Days
Horizon Zero Dawn: The Early DaysDevGAMM Conference
 
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's EdgeSIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's EdgeElectronic Arts / DICE
 
Advanced Timeline and Cinemachine
Advanced Timeline and CinemachineAdvanced Timeline and Cinemachine
Advanced Timeline and CinemachineUnity Technologies
 
Basic Optimization and Unity Tips & Tricks by Yogie Aditya
Basic Optimization and Unity Tips & Tricks by Yogie AdityaBasic Optimization and Unity Tips & Tricks by Yogie Aditya
Basic Optimization and Unity Tips & Tricks by Yogie AdityagamelanYK
 
Game Engine for Serious Games
Game Engine for Serious GamesGame Engine for Serious Games
Game Engine for Serious GamesKashif Shamaun
 

Was ist angesagt? (18)

Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engine
 
Authoring of procedural rocks in The Blacksmith realtime short
Authoring of procedural rocks in The Blacksmith realtime shortAuthoring of procedural rocks in The Blacksmith realtime short
Authoring of procedural rocks in The Blacksmith realtime short
 
Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Optimization in Unity: simple tips for developing with "no surprises" / Anton...Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Optimization in Unity: simple tips for developing with "no surprises" / Anton...
 
The Unusual Rendering Pipeline of Sigils - Battle for Raios
The Unusual Rendering Pipeline of Sigils - Battle for RaiosThe Unusual Rendering Pipeline of Sigils - Battle for Raios
The Unusual Rendering Pipeline of Sigils - Battle for Raios
 
Rendering Tech of Space Marine
Rendering Tech of Space MarineRendering Tech of Space Marine
Rendering Tech of Space Marine
 
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
 
2 Dimensions Of Awesome: Advanced ActionScript For Platform Games by Iain Lobb
2 Dimensions Of Awesome: Advanced ActionScript For Platform Games by Iain Lobb2 Dimensions Of Awesome: Advanced ActionScript For Platform Games by Iain Lobb
2 Dimensions Of Awesome: Advanced ActionScript For Platform Games by Iain Lobb
 
BSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOSBSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOS
 
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
 
Lighting the City of Glass
Lighting the City of GlassLighting the City of Glass
Lighting the City of Glass
 
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open ProblemsHPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
 
Ottawa unity user_group_feb13_2015
Ottawa unity user_group_feb13_2015Ottawa unity user_group_feb13_2015
Ottawa unity user_group_feb13_2015
 
Horizon Zero Dawn: The Early Days
Horizon Zero Dawn: The Early DaysHorizon Zero Dawn: The Early Days
Horizon Zero Dawn: The Early Days
 
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's EdgeSIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
 
Advanced Timeline and Cinemachine
Advanced Timeline and CinemachineAdvanced Timeline and Cinemachine
Advanced Timeline and Cinemachine
 
Basic Optimization and Unity Tips & Tricks by Yogie Aditya
Basic Optimization and Unity Tips & Tricks by Yogie AdityaBasic Optimization and Unity Tips & Tricks by Yogie Aditya
Basic Optimization and Unity Tips & Tricks by Yogie Aditya
 
Game Engine for Serious Games
Game Engine for Serious GamesGame Engine for Serious Games
Game Engine for Serious Games
 

Andere mochten auch

Приклади проблемних завдань
Приклади проблемних завданьПриклади проблемних завдань
Приклади проблемних завданьМарина Оленюк
 
[GDC2010] Blizzard Design Process_KOR
[GDC2010] Blizzard Design Process_KOR[GDC2010] Blizzard Design Process_KOR
[GDC2010] Blizzard Design Process_KORPaul Jung
 
Εκπαιδευτικά ηλεκτρονικά παιχνίδια
Εκπαιδευτικά ηλεκτρονικά παιχνίδιαΕκπαιδευτικά ηλεκτρονικά παιχνίδια
Εκπαιδευτικά ηλεκτρονικά παιχνίδιαLiana Lignou
 
Στάσεις Εκπαιδευτικών για τις ΤΠΕ.
Στάσεις Εκπαιδευτικών για τις ΤΠΕ.Στάσεις Εκπαιδευτικών για τις ΤΠΕ.
Στάσεις Εκπαιδευτικών για τις ΤΠΕ.Liana Lignou
 
Aσφάλεια στο διαδίκτυο. Μια πρώτη προσέγγιση.
Aσφάλεια στο διαδίκτυο. Μια πρώτη προσέγγιση.Aσφάλεια στο διαδίκτυο. Μια πρώτη προσέγγιση.
Aσφάλεια στο διαδίκτυο. Μια πρώτη προσέγγιση.Liana Lignou
 
" Tα Σκουλήκια και οι Δασοφύλακες"
" Tα Σκουλήκια και οι Δασοφύλακες"" Tα Σκουλήκια και οι Δασοφύλακες"
" Tα Σκουλήκια και οι Δασοφύλακες"Liana Lignou
 
2o Γυμνάσιο Ελληνικού - Εθνικό Ιστορικό Μουσείο- National History Museum ( A...
2o Γυμνάσιο Ελληνικού - Εθνικό Ιστορικό Μουσείο- National History Museum  ( A...2o Γυμνάσιο Ελληνικού - Εθνικό Ιστορικό Μουσείο- National History Museum  ( A...
2o Γυμνάσιο Ελληνικού - Εθνικό Ιστορικό Μουσείο- National History Museum ( A...Liana Lignou
 
presentation-web
presentation-webpresentation-web
presentation-webAmanda Choy
 

Andere mochten auch (8)

Приклади проблемних завдань
Приклади проблемних завданьПриклади проблемних завдань
Приклади проблемних завдань
 
[GDC2010] Blizzard Design Process_KOR
[GDC2010] Blizzard Design Process_KOR[GDC2010] Blizzard Design Process_KOR
[GDC2010] Blizzard Design Process_KOR
 
Εκπαιδευτικά ηλεκτρονικά παιχνίδια
Εκπαιδευτικά ηλεκτρονικά παιχνίδιαΕκπαιδευτικά ηλεκτρονικά παιχνίδια
Εκπαιδευτικά ηλεκτρονικά παιχνίδια
 
Στάσεις Εκπαιδευτικών για τις ΤΠΕ.
Στάσεις Εκπαιδευτικών για τις ΤΠΕ.Στάσεις Εκπαιδευτικών για τις ΤΠΕ.
Στάσεις Εκπαιδευτικών για τις ΤΠΕ.
 
Aσφάλεια στο διαδίκτυο. Μια πρώτη προσέγγιση.
Aσφάλεια στο διαδίκτυο. Μια πρώτη προσέγγιση.Aσφάλεια στο διαδίκτυο. Μια πρώτη προσέγγιση.
Aσφάλεια στο διαδίκτυο. Μια πρώτη προσέγγιση.
 
" Tα Σκουλήκια και οι Δασοφύλακες"
" Tα Σκουλήκια και οι Δασοφύλακες"" Tα Σκουλήκια και οι Δασοφύλακες"
" Tα Σκουλήκια και οι Δασοφύλακες"
 
2o Γυμνάσιο Ελληνικού - Εθνικό Ιστορικό Μουσείο- National History Museum ( A...
2o Γυμνάσιο Ελληνικού - Εθνικό Ιστορικό Μουσείο- National History Museum  ( A...2o Γυμνάσιο Ελληνικού - Εθνικό Ιστορικό Μουσείο- National History Museum  ( A...
2o Γυμνάσιο Ελληνικού - Εθνικό Ιστορικό Μουσείο- National History Museum ( A...
 
presentation-web
presentation-webpresentation-web
presentation-web
 

Ähnlich wie Unite2013-gavilan-pdf

Ceph Performance and Optimization - Ceph Day Frankfurt
Ceph Performance and Optimization - Ceph Day Frankfurt Ceph Performance and Optimization - Ceph Day Frankfurt
Ceph Performance and Optimization - Ceph Day Frankfurt Ceph Community
 
MongoDB and AWS Best Practices
MongoDB and AWS Best PracticesMongoDB and AWS Best Practices
MongoDB and AWS Best PracticesMongoDB
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidStanojko Markovik
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法Unity Technologies Japan K.K.
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Droidcon Berlin
 
Dev tools rendering & memory profiling
Dev tools rendering & memory profilingDev tools rendering & memory profiling
Dev tools rendering & memory profilingOpen Academy
 
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Máté Nádasdi
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript ProgrammingYoshiki Shibukawa
 
Castle Game Engine and the joy of making and using a custom game engine
Castle Game Engine and the joy  of making and using a custom game engineCastle Game Engine and the joy  of making and using a custom game engine
Castle Game Engine and the joy of making and using a custom game engineMichalis Kamburelis
 
Dynamic Languages in Production: Progress and Open Challenges
Dynamic Languages in Production: Progress and Open ChallengesDynamic Languages in Production: Progress and Open Challenges
Dynamic Languages in Production: Progress and Open Challengesbcantrill
 
The FT Web App: Coding Responsively
The FT Web App: Coding ResponsivelyThe FT Web App: Coding Responsively
The FT Web App: Coding ResponsivelyC4Media
 
React Conf 17 Recap
React Conf 17 RecapReact Conf 17 Recap
React Conf 17 RecapAlex Babkov
 
PHP Backends for Real-Time User Interaction using Apache Storm.
PHP Backends for Real-Time User Interaction using Apache Storm.PHP Backends for Real-Time User Interaction using Apache Storm.
PHP Backends for Real-Time User Interaction using Apache Storm.DECK36
 
Devopsdays se-2011
Devopsdays se-2011Devopsdays se-2011
Devopsdays se-2011lusis
 
Open Source Storage at Scale: Ceph @ GRNET
Open Source Storage at Scale: Ceph @ GRNETOpen Source Storage at Scale: Ceph @ GRNET
Open Source Storage at Scale: Ceph @ GRNETNikos Kormpakis
 
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate GuideДмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate GuideUA Mobile
 
Boulder JS meet up presentation for April 16
Boulder JS meet up presentation for April 16Boulder JS meet up presentation for April 16
Boulder JS meet up presentation for April 16Matthew Schrepel
 
Django Deployment with Fabric
Django Deployment with FabricDjango Deployment with Fabric
Django Deployment with FabricJonas Nockert
 

Ähnlich wie Unite2013-gavilan-pdf (20)

Ceph Performance and Optimization - Ceph Day Frankfurt
Ceph Performance and Optimization - Ceph Day Frankfurt Ceph Performance and Optimization - Ceph Day Frankfurt
Ceph Performance and Optimization - Ceph Day Frankfurt
 
MongoDB and AWS Best Practices
MongoDB and AWS Best PracticesMongoDB and AWS Best Practices
MongoDB and AWS Best Practices
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with android
 
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014
 
From Web to Mobile with Stage 3D
From Web to Mobile with Stage 3DFrom Web to Mobile with Stage 3D
From Web to Mobile with Stage 3D
 
Dev tools rendering & memory profiling
Dev tools rendering & memory profilingDev tools rendering & memory profiling
Dev tools rendering & memory profiling
 
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
 
Multi screenlab
Multi screenlabMulti screenlab
Multi screenlab
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript Programming
 
Castle Game Engine and the joy of making and using a custom game engine
Castle Game Engine and the joy  of making and using a custom game engineCastle Game Engine and the joy  of making and using a custom game engine
Castle Game Engine and the joy of making and using a custom game engine
 
Dynamic Languages in Production: Progress and Open Challenges
Dynamic Languages in Production: Progress and Open ChallengesDynamic Languages in Production: Progress and Open Challenges
Dynamic Languages in Production: Progress and Open Challenges
 
The FT Web App: Coding Responsively
The FT Web App: Coding ResponsivelyThe FT Web App: Coding Responsively
The FT Web App: Coding Responsively
 
React Conf 17 Recap
React Conf 17 RecapReact Conf 17 Recap
React Conf 17 Recap
 
PHP Backends for Real-Time User Interaction using Apache Storm.
PHP Backends for Real-Time User Interaction using Apache Storm.PHP Backends for Real-Time User Interaction using Apache Storm.
PHP Backends for Real-Time User Interaction using Apache Storm.
 
Devopsdays se-2011
Devopsdays se-2011Devopsdays se-2011
Devopsdays se-2011
 
Open Source Storage at Scale: Ceph @ GRNET
Open Source Storage at Scale: Ceph @ GRNETOpen Source Storage at Scale: Ceph @ GRNET
Open Source Storage at Scale: Ceph @ GRNET
 
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate GuideДмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
 
Boulder JS meet up presentation for April 16
Boulder JS meet up presentation for April 16Boulder JS meet up presentation for April 16
Boulder JS meet up presentation for April 16
 
Django Deployment with Fabric
Django Deployment with FabricDjango Deployment with Fabric
Django Deployment with Fabric
 

Unite2013-gavilan-pdf

  • 1. LWF  in  real  life:     「どうぶつフレンズ」の開発事例 David  Gavilan   david.gavilan@gree.net   GREE
  • 2. Agenda   •  About  “Animal  Days”   •  About  LWF   •  Texture  packing   •  Common  boFlenecks   •  Profiling  your  game   •  InvesJgaJng  leaks   •  OpJmizaJons
  • 3.
  • 4. Animal  Days  /  どうぶつフレンズ •  2D  Game   •  Current  plaOorm:  Android  2.2  and  up   •  Categories:  City  building  &  breeding  simulaJon   •  Main  tech  on  the  client   – Unity  3.5.7,  4.0  latest  (4.1  for  Profiling)   – LWF   – Webview   •  Tools:  TexturePacker,  Xcode,  ADB
  • 5.
  • 8. •  Open-­‐source  Lightweight  SWF:   – hFp://gree.github.com/lwf   – Developed  by  Kazuki  Sakamoto  @splhack  at  GREE  
  • 9. .fla/.swf  →  .lwf I  am  a   GameObject  !
  • 10. LWF  data  creaJon •  .fla/.swf  →  .lwf   – 1-­‐step  script-­‐based  conversion  →  can  be  easily   batched   – Can  customize  the  texture  and  data  loaders,   – Can  dynamically  change  the  Z-­‐posiJon  of  the   movie  clips,   – …  and  more!  
  • 11. LWF  renderers •  DrawMeshRenderer   –  For  a  given  frame,   •   N  movie  clips  =  N  meshes  =  N  draw  calls   –  Slow,  but  there's  no  problem  with  Z-­‐sorJng   –  Separate  textures  for  each  clip  →  DrawMeshRenderer     •  CombinedMeshRenderer   –  For  a  given  frame,     •  N  movie  clips  =  1  mesh  =  1  draw  call   –  Faster,  but  Z-­‐sorJng  works  per-­‐object   –  You  need  to  pack  all  your  texture  in  a  single  texture   atlas/sheet
  • 13. Texture  packing •  Remember  this:  PACK  EVERYTHING   •  We  use  TexturePacker:   hFp://www.codeandweb.com/texturepacker  
  • 14. Texture  sheets  ♡  LWF •  Enables  CombinedMeshRenderer   – only  1  Draw  Call  per  LWF  object  (worst  case)   – if  the  objects  share  the  same  material,  they  can   also  be  dynamically  batched  (N  objects  in  1  Draw   Call)
  • 15. Texture  sheets  ♡  LWF •  Eg.  Dynamic  batching  of  our  balloons
  • 16. Texture  sheets  ♡  LWF •  If  you  have  problems  with  Z-­‐sorJng  (need  to   place  parts  of  the  same  UI  before  and  behind   another  object),  you  can  always  easily  switch   back  to  DrawMeshRenderer  
  • 17. Texture  sheets  ♡  Versioning •  Can  compare  the  changes  in  the  JSON  file   •  With  one  glimpse  you  can  check  the  changes   in  one  asset  over  github
  • 18. Check  asset  changes  at  github Previous  version New  commit
  • 19. Texture  sheets  ♡  ProducJon •  Awesome  for  controlling  your  texture  budget!   – For  rendering  and  for  bundling!   •  Try  to  answer  these  quesJons:   – How  many  objects  can  we  render?   – How  much  space  is  taken  by  UI  elements?   – How  long  does  it  take  to  download  all  the  assets?
  • 20. Texture  sheets  ♡  ProducJon •  Once  you  decide  your  budget,  make  scripts  to   automaJcally  popup  warnings/errors:
  • 21. Texture  sheets  ♡  ProducJon •  Pack  all  your  texture  sheets  in  a  single  texture   for  visualizaJon   – Easily  detect  assets  using  too  much  space   – Good  to  check  the  amount  of  "empty  space"   – Good  to  explain  to  directors  and  arJsts  the  goods   and  wrongs
  • 22. Eg.  Detect  “outliers” Why  are   these  assets   so  big?
  • 23. Eg.  How  much  space  can  we  save  by   allowing  textures  to  be  of  any  size?
  • 24. Eg.  Tell  arJsts  where  to  cut This  texture  alone  is   256×1200  pixels!!
  • 25. Eg.  Tell  arJsts  where  to  cut •  Use  affine  transforms   to  enlarge/bend   graphics   •  Use  vertex  colors Replaced  the  background   by  a  few  colored  pixels  
  • 27. Common  boFlenecks •  Rendering   – For  a  2D  game,  fill-­‐rate  is  probably  the  most   common  rendering  boFleneck   – Reduce  number  of  draw  calls   – Reduce  render  area   •  Object  updates   – Update  only  when  necessary   •  Network  access   – Reduce  data  size  →  smaller  textures
  • 28. Profiling  your  game •  Pick  up  a  slow  device   – Even  if  you  target  a  high-­‐spec  device,  in  slow   devices  the  boFlenecks  are  easier  to  spot   – Eg.  We  target  ~Samsung  Galaxy  S2,  but  I  use   Sharp  IS03  for  profiling
  • 29. Profiling:  Unity  Profiler •  First,  check  CPU  usage  in  the  device
  • 30. Profiling:  Unity  Profiler •  Once  you  locate  a  boFleneck,  use  Deep   Profiling  on  the  Editor,   1.  Locate  the  heavy  funcJon   calls ms
  • 31. Profiling:  Unity  Profiler 2.  Fix   3.  Check  difference     ms -­‐10  ms
  • 32. Profiling:  Game  window •  Prepare  debugging  scripts  so  you  can  easily   debug  in  the  device,  even  without  Unity   Profiler   – Use  Time.deltaTime  to  create  a  simple  FPS   counter   – Create  a  custom  memory  profiler;     – it  doesn’t  need  to  be  fancy:  just  count  objects  
  • 33. Custom  profiler  in  Game  window
  • 34. Custom  profiler  in  Game  window •  Count  object  references   •  Count  Unity  objects  (every  2  secs)   •  Get  heap  usage  naJvely  
  • 35. Profiling:  Xcode  instruments •  Even  if  you  are  not  releasing  for  iPhone,  build   on  iPhone  and  use  Instruments!
  • 36. Create  test  scenes •  Test  scenes  are  good  to  esJmate  the   maximum  amount  of  data/assets  we  can   handle/display  in  different  devices   •  They  are  good  for  invesJgaJng  leaks  too
  • 39. InvesJgaJng  leaks  with  adb •  adb  gives  you  important  informaJon!  (and  is   scriptable)   •  Check  Pss  (ProporJonal  set  size:  the  amount   of  pages  a  process  has  in  memory)   •  If  Pss  is  too  big,  the  OS  will  kill  your  app  →   check  for  low  memory  warnings   •  Eg.  on  IS03,  ~260MB  will  get  your  app   terminated
  • 40. adb  memory  informaJon $ adb shell dumpsys meminfo ’..animal’ Applications Memory Usage (kB): Uptime: 573793345 Realtime: 609753074 ** MEMINFO in pid 1952 [com.gree.animal] ** native dalvik other total size: 35000 4743 N/A 39743 allocated: 34714 4357 N/A 39071 free: 39 386 N/A 425 (Pss): 10697 4232 29856 44785 (shared dirty): 2752 4104 8380 15236 (priv dirty): 10612 2980 15892 29484
  • 41. Disable  objects  to  discard  culprits •  Disable  objects  and  repeat  tests
  • 42. Replace  all  textures •  To  compute  texture  impact,  replace  all   textures  by  very  small  ones  (8×8)
  • 43. Count  references •  For  non-­‐Unity.Objects,  add  simple  counters   for  your  debugging  scripts   •  If  the  destructor  is  never  called,  it  means  it   never  gets  GC'ed  !!
  • 44. Nullify  everything •  Object  references  can  be  kept  in  memory  for   obscure  reasons  (mono?).  Eg.  using  the   argument  of  a  lambda  funcJon  inside  another   lambda  funcJon   •  As  a  general  pracJce,  set  to  null  the   references  you  don't  need  anymore,  even   local  variables  and  pointers  to  callback   funcJons
  • 48. OpJmizaJon:  Object  updates •  Don't  update  objects  outside  camera  view •  Limit  the  number  of  objects  that  can  be  updated/ animated   –  Eg.  From  all  the  visible  characters,  the  LWF  update  is   called  for  N  at  most   –  Change  N  depending  on  the  device  capabiliJes.  Eg.   Nhigh_spec  =  25;  Nlow_spec  =  12   •  Be  polite  and  save  baFery   –  Only  use  60fps  when  interacJng  (touching  screen)
  • 49. Rendering:  limit  max  drawable  objects •  Check  FPS  on  the  device,  and  take  note  of  the   slow  scenes   •  On  the  Editor,  check  the  number  of  draw  calls   for  those  scenes.   •  Eg.  for  low-­‐spec  devices,  set  a  more  restricJve   zoom-­‐out  level
  • 50. Rendering:  check  fill-­‐rate •  If  Camera.Render  is  slow  even  for  simple   scenes,  reduce  the  resoluJon  of  the   backbuffer  (to  a  respectable  DPI)  
  • 51. Reduce  draw  calls  by  using  Z-­‐layers •  If  possible,  place  all  the  LWF  that  share  the   same  material  far  from  others,  so  they  can  be   dynamically  batched   •  Eg.  Our  bubbles  all  live  far  away  and  they  are   rendered  in  1  draw  call
  • 52. …  when  aFaching  LWFs •  …  to  replace  a  movie  clip,  make  sure  the  clip  is  in   front  to  avoid  Z-­‐sorJng  problems  when  using   CombinedMeshRenderer 3  draw  calls Character  and  Rainbow  are   aFached  to  the  Flash  UI
  • 53. Reduce  draw  calls  with  custom  2D •  Eg.  Use  point-­‐sampled  textures  to  render  lines   and  grid  cells
  • 55. Wrap-­‐up •  For  2D  games,  Unity  &  LWF  make  a  perfect  match   •  Use  Texture  sheets  everywhere   –  Enable  faster  rendering  in  LWF   –  Good  for  controlling  texture  budgets   –  Good  for  visually  detect  problems   •  When  profiling,   –  Use  external  tools  to  detect  real  problems  in  devices   –  Once  a  possible  problem  is  detected,  use  Unity  Editor   to  extract  as  much  informaJon  as  possible  and  for   quick  debugging   •  "Animal  Days"  is  cute.  Please  play!
  • 56.
  • 57. Copyright © GREE, Inc. All Rights Reserved. Unity  Technologies  社と包括的業務提携 GREE向けのNativeアプリケーション開発に必要なUnityプロライセンス 「Unity  Pro  +  iOS  Pro  +  Android  Pro」累累計5セットを無料料提供 GREE  Platform  SDK  for  Unityを提供 GREE  Platformが提供する各種機能をUnityアプリで実装可能 Unityを活⽤用した⾃自社タイトルを続々リリース グリーはUnityに本気です!
  • 58. Copyright © GREE, Inc. All Rights Reserved. Do  you  want  a  challenging  job  in a  fast-‐‑‒paced,  innovative  environment? http://jobs.gree.net/