<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://blog.stuff-o-matic.com/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Stuffomatic</title>
  <link>http://blog.stuff-o-matic.com/</link>
  <atom:link href="http://blog.stuff-o-matic.com:82/feed/rss2" rel="self" type="application/rss+xml"/>
  <description></description>
  <language>en</language>
  <pubDate>Thu, 31 Jan 2013 11:42:13 +0100</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Improving a sprite-based rendering procedure</title>
    <link>http://blog.stuff-o-matic.com/post/2013/01/19/Improving-a-sprite-based-rendering-procedure</link>
    <guid isPermaLink="false">urn:md5:6357f71f322af13f4e751dc6a56db857</guid>
    <pubDate>Sat, 19 Jan 2013 09:02:00 +0100</pubDate>
    <dc:creator>Julien</dc:creator>
            
    <description>    &lt;p&gt;So you are developing a 2D game and, suddenly, you discover that the
rendering procedure is slow. What would you do? Would you put less elements in
your levels or would you render them more efficiently? Since you are here, I
suppose that you would pick the latter. So, here we go, I am going to tell you
how to render less things while having more.&lt;/p&gt;
&lt;p&gt;The first part of this post describes how much work is done during the
rendering of a scene. Then I will compare it with the results of an easy to
implement improved procedure. And finally I will give you the pointers to an
even better procedure. This final procedure has been used in &lt;a href=&quot;http://www.stuff-o-matic.com/asgp/&quot; hreflang=&quot;en&quot;&gt;Andy's Super Great Park&lt;/a&gt;
and in the —work in progress— Plee the Bear.&lt;/p&gt;
&lt;h2&gt;Background&lt;/h2&gt;
&lt;p&gt;In the first versions of Plee the Bear we were not really worried about the
speed of the rendering procedure, nor the speed of any other procedure. Keeping
in mind that &lt;a href=&quot;http://en.wikipedia.org/wiki/Donald_Knuth&quot; hreflang=&quot;en&quot;&gt;premature optimization is the root of all evil&lt;/a&gt;, we had to make things
work before making them working fast. That was some years ago. Then the game
has grown, we began to put a lot of stuff in the levels and finally the time of
thinking about accelerating things did come. That is the subject of today's
post: how the rendering procedure evolved with the growing of the game.&lt;/p&gt;
&lt;p&gt;The initial procedure was as simple as possible. Elements are rendered from
the background to the foreground, as is. Having something drawn on the screen
was a sufficient result at this time.&lt;/p&gt;
&lt;p&gt;So, what amount of work this procedure does? Let's see how many times each
pixel of the screen is written in a given scene. We will use the very beginning
of the first act of the forest of Plee the Bear, just when the player can start
to control Plee:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://blog.stuff-o-matic.com/public/.scene_m.jpg&quot; alt=&quot;The moment of the game used for the experiments.&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;The moment of the game used for the experiments., janv. 2013&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And we will apply the following color representation: &lt;img src=&quot;http://blog.stuff-o-matic.com/public/table.png&quot; alt=&quot;table.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;table.png, janv. 2013&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Here is the result for the aforementioned scene: &lt;a href=&quot;http://blog.stuff-o-matic.com/post/2013/01/19/C&quot; title=&quot;/public/result-dumb-rain.png&quot;&gt;&lt;img src=&quot;http://blog.stuff-o-matic.com/public/.result-dumb-rain_m.jpg&quot; alt=&quot;The number of times each pixel is written. The graph on the right shows the percentage of the pixels for each number of passes (range is (0, 0.5&quot; /&gt;
 .&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Not surprisingly, with three layers of rain plus the background, each pixel
is written at least 4 times, most of them 5 or 6 times and some are written up
to 9 times. And once the rain is gone, the range goes from 1 to 6 writings:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.stuff-o-matic.com/public/result-dumb-post-rain.png&quot;&gt;&lt;img src=&quot;http://blog.stuff-o-matic.com/public/.result-dumb-post-rain_m.jpg&quot; alt=&quot;Number of writings once the rain is gone.&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Number of writings once the rain is gone., janv. 2013&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;An interesting thing in these two pictures is that even parts hidden by the
middle ground decorations are rendered.&lt;/p&gt;
&lt;h2&gt;Improving the rendering procedure&lt;/h2&gt;
&lt;p&gt;The improvement we wanted to introduce then was to avoid rendering elements
that will be hidden by other elements. The idea is to maintain a representation
of the empty parts of the screen whilst considering the elements from the
foreground toward the background. For each element there are to steps. First,
if the element intersects the empty parts of the screen, we split it into
sub-elements that will cover only the empty parts of the screen. Then, if the
initial element is opaque, we update the emptiness of the screen.&lt;/p&gt;
&lt;p&gt;To keep things simple, we represent the parts of the screen with
axis-aligned boxes. Elements are considered as opaque if there is no alpha
transparency in the source image and if they are not rotated.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.stuff-o-matic.com/public/illustration.png&quot;&gt;&lt;img src=&quot;http://blog.stuff-o-matic.com/public/.illustration_m.jpg&quot; alt=&quot;The different steps of the algorithm.&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;The different steps of the algorithm., janv. 2013&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Let's come back to the game to see how many times the pixels are written
with this procedure. During the rain:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.stuff-o-matic.com/public/result-smart-rain.png&quot;&gt;&lt;img src=&quot;http://blog.stuff-o-matic.com/public/.result-smart-rain_m.jpg&quot; alt=&quot;Number of writings per pixels once the rain is gone, with the improved rendering procedure.&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Number of writings per pixels once the rain is gone, with the improved rendering procedure., janv. 2013&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Pixels are written from 2 to 8 times. Contrary to the original procedure,
some of them are drawn 2 or 3 times. The number of pixels drawn more than 3
times has been greatly reduced. And after the rain:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.stuff-o-matic.com/public/result-smart-post-rain.png&quot;&gt;&lt;img src=&quot;http://blog.stuff-o-matic.com/public/.result-smart-post-rain_m.jpg&quot; alt=&quot;Number of writings per pixels once the rain is gone, with the improved rendering procedure.&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Number of writings per pixels once the rain is gone, with the improved rendering procedure., janv. 2013&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here the range becomes 1-5 writings per pixels, most of them are written 1
or 2 times. Contrary to the original algorithm, we have more pixels written
once than three times.&lt;/p&gt;
&lt;h2&gt;The benchmark&lt;/h2&gt;
&lt;p&gt;Finally, for all this work to be useful there must be an increase of the
performance. That is: more frames rendered per second. To keep an uniform
sequence of rendered items among the tests, we use a demo script that runs in
the game. Here are the results:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.stuff-o-matic.com/public/result.png&quot;&gt;&lt;img src=&quot;http://blog.stuff-o-matic.com/public/.result_m.jpg&quot; alt=&quot;Number of frames per seconds during the demo.&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Number of frames per seconds during the demo., janv. 2013&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;One can see that the new procedure greatly increases the number of frames
per seconds, which is exactly what we wanted.&lt;/p&gt;
&lt;h2&gt;Can we have more?&lt;/h2&gt;
&lt;p&gt;Yes! we can do better. You may have noticed on the above captures that some
parts of the screen seem to be written several times even if the foreground
seems opaque. The main reason is that these foreground sprites have some
transparent pixels on one of the edges of their box. Thus, the procedure does
not consider any opaque box for them.&lt;/p&gt;
&lt;p&gt;In order to improve this, we just have to compute some kind of opaque box
inside each sprite. More precisely, we want &lt;em&gt;the largest opaque box of each
sprite&lt;/em&gt;. Is it easy to compute? Well, it may be easy, if you reformulate
the problem as &lt;em&gt;the largest rectangle with no transparent pixel&lt;/em&gt;. You
now have an instance of the well known &lt;a href=&quot;http://en.wikipedia.org/wiki/Largest_empty_rectangle&quot; hreflang=&quot;en&quot;&gt;Largest
Empty Rectangle problem&lt;/a&gt; for which you will find good resources, such as an
article named &lt;em&gt;&lt;a href=&quot;http://www.scs.carleton.ca/~dehne/publications/1-09.pdf&quot; hreflang=&quot;en&quot;&gt;Computing the Largest Empty Rectangle on One- and Two-Dimensional
Processor Arrays&lt;/a&gt;&lt;/em&gt; by Frank Dehne.&lt;/p&gt;
&lt;p&gt;Contrary to the previous procedure this one cannot be executed at run time
(unless you accept the levels to be be loaded in several minutes). For our
games, we managed to insert the procedure in the level editor, as an
optimization step executed when the level is compiled. Then the game engine
just have to read the computed opaque boxes and to apply them in the initial
procedure.&lt;/p&gt;
&lt;ul class=&quot;reseaux_sociaux&quot; style=&quot;list-style-type:none;&quot;&gt;
&lt;li style=&quot;list-style-type:none;float:left;width:32px;&quot;&gt;&lt;a href=&quot;http://www.facebook.com/share.php?u=http://blog.stuff-o-matic.com/post/2013/01/19/Efficient-sprite-based-rendering-procedure&quot;&gt;
&lt;img src=&quot;http://blog.stuff-o-matic.com/public/facebook.png&quot; style=&quot;border:0;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;list-style-type:none;float:left;width:32px;&quot;&gt;&lt;a href=&quot;http://twitter.com/share?url=http://blog.stuff-o-matic.com/post/2013/01/19/Efficient-sprite-based-rendering-procedure&quot;&gt;
&lt;img src=&quot;http://blog.stuff-o-matic.com/public/twitter.png&quot; style=&quot;border:0;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br style=&quot;clear:left;&quot; /&gt;</description>
    
    
    
          <comments>http://blog.stuff-o-matic.com/post/2013/01/19/Improving-a-sprite-based-rendering-procedure#comment-form</comments>
      <wfw:comment>http://blog.stuff-o-matic.com/post/2013/01/19/Improving-a-sprite-based-rendering-procedure#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.stuff-o-matic.com/feed/atom/comments/715677</wfw:commentRss>
      </item>
    
  <item>
    <title>Andy's Super Great Park</title>
    <link>http://blog.stuff-o-matic.com/post/2012/12/12/Andy-s-Super-Great-Park</link>
    <guid isPermaLink="false">urn:md5:38b726dfc5a9018aab80ed5fa620e962</guid>
    <pubDate>Wed, 12 Dec 2012 21:27:00 +0100</pubDate>
    <dc:creator>Julien</dc:creator>
            
    <description>    &lt;p&gt;Here we go, we have finally made our first complete game: &lt;a href=&quot;http://www.stuff-o-matic.com/asgp/&quot;&gt;Andy's Super Great Park&lt;/a&gt;. It took a lot
of effort and we are quite proud of the result. Now that the game is available,
we are working to put it on variousportals, like Steam (&lt;a href=&quot;http://steamcommunity.com/sharedfiles/filedetails/?id=112946373&amp;amp;searchtext=&quot;&gt;vote
for us!&lt;/a&gt;), Indiecity and Indievania, and we are preparing the Ubuntu
version.&lt;/p&gt;
&lt;p&gt;Check &lt;a href=&quot;http://www.stuff-o-matic.com/asgp/&quot;&gt;the game's page&lt;/a&gt; to
watch a video, to see some screenshot and to play the demo,&lt;/p&gt;
&lt;ul class=&quot;reseaux_sociaux&quot; style=&quot;list-style-type:none;&quot;&gt;
&lt;li style=&quot;list-style-type:none;float:left;width:32px;&quot;&gt;&lt;a href=&quot;http://www.facebook.com/share.php?u=http://blog.stuff-o-matic.com/post/2012/12/12/Andy-s-Super-Great-Park&quot;&gt;
&lt;img src=&quot;http://blog.stuff-o-matic.com/public/facebook.png&quot; style=&quot;border:0;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;list-style-type:none;float:left;width:32px;&quot;&gt;&lt;a href=&quot;http://twitter.com/share?url=http://blog.stuff-o-matic.com/post/2012/12/12/Andy-s-Super-Great-Park&quot;&gt;
&lt;img src=&quot;http://blog.stuff-o-matic.com/public/twitter.png&quot; style=&quot;border:0;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br style=&quot;clear:left;&quot; /&gt;</description>
    
    
    
          <comments>http://blog.stuff-o-matic.com/post/2012/12/12/Andy-s-Super-Great-Park#comment-form</comments>
      <wfw:comment>http://blog.stuff-o-matic.com/post/2012/12/12/Andy-s-Super-Great-Park#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.stuff-o-matic.com/feed/atom/comments/710333</wfw:commentRss>
      </item>
    
  <item>
    <title>Stuffomatic</title>
    <link>http://blog.stuff-o-matic.com/post/2012/03/27/first</link>
    <guid isPermaLink="false">urn:md5:ad59aa829b5ff26b95410466c69aa99f</guid>
    <pubDate>Tue, 27 Mar 2012 20:01:00 +0000</pubDate>
    <dc:creator>Julien</dc:creator>
            
    <description>    &lt;p&gt;&lt;strong&gt;Stuffomatic&lt;/strong&gt; is a French company composed of talented
friends from Nantes, France. We joined together to develop entertaining games,
starting with &lt;strong&gt;Plee the Bear&lt;/strong&gt;, a great platform game. Check
&lt;a hreflang=&quot;en&quot; href=&quot;http://blog.stuff-o-matic.com/pages/Who-are-We&quot;&gt;this page&lt;/a&gt; to learn more about our
team!&lt;/p&gt;
&lt;p&gt;&lt;img title=&quot;Plee the Bear, mar. 2012&quot; style=&quot;margin: 0 auto; display: block;&quot; alt=&quot;&quot; src=&quot;http://blog.stuff-o-matic.com/public/.plee_s.jpg&quot; /&gt;&lt;strong&gt;Plee the Bear&lt;/strong&gt; is a platform game in
which the player controls an angry bear, gone after his greedy son after he was
kidnapped. In this great travel taking him all over the world, the daddy will
have to show agility and strength to find and save the cub. The player's
journey is livened up with different game modes implementing varied gameplay
and punctuated with interactions on the social networks.&lt;/p&gt;
&lt;ul class=&quot;reseaux_sociaux&quot; style=&quot;list-style-type:none;&quot;&gt;
&lt;li style=&quot;list-style-type:none;float:left;width:32px;&quot;&gt;&lt;a href=&quot;http://www.facebook.com/share.php?u=http://www.stuff-o-matic.compost/http://blog.stuff-o-matic.com/post/2012/03/27/first&quot;&gt;
&lt;img src=&quot;http://blog.stuff-o-matic.com/public/facebook.png&quot; style=&quot;border:0;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;list-style-type:none;float:left;width:32px;&quot;&gt;&lt;a href=&quot;http://twitter.com/share?url=http%3A%2F%2Fwww.stuff-o-matic.compost%2Fhttp%3A%2F%2Fblog.stuff-o-matic.com%2Fpost%2F2012%2F03%2F27%2Ffirst&quot;&gt;
&lt;img src=&quot;http://blog.stuff-o-matic.com/public/twitter.png&quot; style=&quot;border:0;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br style=&quot;clear:left;&quot; /&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>