<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><description>Indie Game Developer &amp; drummer

My days, my works, and indie experience out of box.

haxpor {add} gmail.com 

 





Twitter!

follow me on Twitter


</description><title>Indie As Hell</title><generator>Tumblr (3.0; @haxpor)</generator><link>http://haxpor.org/</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Haxpor" /><feedburner:info uri="haxpor" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://tumblr.superfeedr.com/" /><feedburner:emailServiceId>Haxpor</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item><title>Blend it well - Skydome's contact point with Scene</title><description>&lt;p&gt;From my previous &lt;a href="http://haxpor.org/post/22200963760/fog-fog-fog" target="_blank"&gt;post&lt;/a&gt; which I mentioned to write about a simple technique I implemented and used in parallel with fog rendering system in order to pull out every sense of what&amp;#8217;s &amp;#8220;right&amp;#8221; out of the screen, so here we go.&lt;/p&gt;
&lt;p&gt;The problem usually arises when there&amp;#8217;re models or meshes placed on a large flat plane in which a skydome covers entirely of those. What&amp;#8217;s matter is the plane or ground as it interfaces with skydome and produces unpleasant result as seen far away in sight. It&amp;#8217;s too separated and cut off. The artifact is easier to be seen if there&amp;#8217;s not enough objects to distract us from glancing at the line itself. See below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/AXRqe.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m3ejqyNLOq1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The red arrows show what happens to be a problem which we&amp;#8217;re trying to solve.&lt;/p&gt;
&lt;p&gt;So I came across with a simple approach to make a skydome blended well with the scene interfacing with it.&lt;/p&gt;
&lt;p&gt;I jotted down the idea on paper, and decided to share it below for some pleasure in seeing original writing.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/BA2gm.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m3ekxqUdJw1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The main point is at the center of the page. There might be a hard time to clearly see it so I rewrote it (somewhat) cleanly below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/JR3kE.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m3el4rkyCr1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;We have a skydome covering all of the whole scene with its both side of edges may go deep down below and pass through the ground itself. To better blend the color along the line, it should not happen to be a sudden full 100% color from the skydome&amp;#8217;s texture right away, but it should merely smooth out for better transition from normal scene to skydome.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Height&lt;/em&gt; is the estimated length to do linear color blending with fog color (or fixed color value). If y-position is outside this range, then we ignore it. &lt;em&gt;Min&lt;/em&gt; is the position where skydome texture takes all the majority of the result blending color. &lt;em&gt;Max&lt;/em&gt; is the position where fog color (or fixed color value) takes all the majority of the result blending color. So in between, we have a linear transition.&lt;/p&gt;
&lt;p&gt;The following is a section of hlsl code inside an effect file.&lt;/p&gt;
&lt;pre class="brush: cpp"&gt;...
// blend with scene
if(input.WorldPosition.y &amp;lt;  SKYDOME_LS_HEIGHT)
{
        float f = input.WorldPosition.y / SKYDOME_LS_HEIGHT;
        if(fogEnabled)
        {
                blendedColor = f * blendedColor + (1-f)*fogColor*ambientLight;
        }
        else
        {
                blendedColor = f * blendedColor + (1-f)*float4(1.0f, 1.0f, 1.0f, 1.0f)*ambientLight;
        }
}
...
&lt;/pre&gt;
&lt;p&gt;Note here that &lt;em&gt;SKYDOME_LS_HEIGHT&lt;/em&gt; is &lt;em&gt;HEIGHT &lt;/em&gt;as explained above. &lt;em&gt;&lt;strong&gt;f&lt;/strong&gt;&lt;/em&gt; is a percentage describing how much skydome&amp;#8217;s texture color will have majority in result blending color.&lt;/p&gt;
&lt;p&gt;Whenever fog is enabled, then we blend skydome&amp;#8217;s texture color with fog color. I also take a consideration on global light intensity percentage (0.0 - 1.0) or &lt;em&gt;ambientLight&lt;/em&gt; here. As I use a value to represent the sunlight intensity at particular of time to simulate my day-night effect, so I must take it into account as well.&lt;/p&gt;
&lt;p&gt;But when fog is not enabled, then I normally blend it with white color. White color is naturally used to give out a shading level of a target color in blending operation. In additional, I want to keep a sanity in color and not to mess it up. Using white will preserve the color coming from skydome&amp;#8217;s texture.&lt;/p&gt;
&lt;p&gt;This section of code should be added after a main color operation is carried out, but before alpha-channel color operation will be performed (to ensure we won&amp;#8217;t mess up with alpha value). In fact, putting this code into a separate function is also a way to go, but as I want to reduce overhead, so I can live with that.&lt;/p&gt;
&lt;p&gt;See the comparison between turning on/off of this technique while fog is enabled below (click on image for original resolution).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/FOgmM.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m3eojghiMI1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/SVipv.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m3eomtA2lX1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/S6YLW.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m3ep98joXo1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/EbYXd.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m3epaotCDF1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#8217;s it for now. Til next time.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/fVTLdZ563Uo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/fVTLdZ563Uo/22264486013</link><guid isPermaLink="false">http://haxpor.org/post/22264486013</guid><pubDate>Thu, 03 May 2012 01:17:00 +0700</pubDate><category>skydome</category><category>shading</category><category>blending</category><category>linear</category><category>smooth</category><category>scene</category><category>color blending</category><category>fog</category><feedburner:origLink>http://haxpor.org/post/22264486013</feedburner:origLink></item><item><title>Fog Fog Fog</title><description>&lt;p&gt;&lt;strong&gt;Begin with story&lt;/strong&gt;&lt;br/&gt;I remembered back in a day that I&amp;#8217;ve failed in adding &lt;em&gt;fog &lt;/em&gt;in my new ground deferred shading. So I decided to pursue another route just for survival alternative, and that was &lt;em&gt;particle fog.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/g66VN.jpg" target="_blank"&gt;&lt;img alt="Particle Fog" src="http://media.tumblr.com/tumblr_m3cr10t8t61qj5i9r.jpg" title="Particle Fog"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The time passed, and someone popped up a need to fully take control of fog system. Then that thing heads back and bangs me to the code!&lt;/p&gt;
&lt;p&gt;I have done fog in shading sense before. But that time with normal forward rendering technique. So it&amp;#8217;s quite straight forward as merely no other big stuff to be considered and would block out the way. It should be something, I always think to myself, that I miss it out in that time. Finally, I go back to &lt;a href="http://en.wikipedia.org/wiki/Return_to_Castle_Wolfenstein" target="_blank"&gt;Castle Wolfenstein&lt;/a&gt;!!&lt;/p&gt;
&lt;p&gt;In fact, it&amp;#8217;s a same same approach that be done inside effect file with shading programming. I would guess that because I saw everything shaded into white, then I suddenly gave up.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Wait! What&amp;#8217;s wrong with particle fog?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Particle system can be implemented in 2 major ways.&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Triangle or Quad-based&lt;/li&gt;
&lt;li&gt;Point sprite&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;My current particle system uses a 2nd approach.&lt;/p&gt;
&lt;p&gt;The resource needed for point sprite to represent one particle is one vertice compared to another way which may need 3 or 4 vertices based on technique of implementation. So it&amp;#8217;s ideal to have point sprite in place for particle system as number of particles surely will be high. But it comes into some costs as well.&lt;/p&gt;
&lt;p&gt;Firstly, Point sprite will be scaled up/down based on the distance to the camera. Thus whenever we go closer and closer, the particle (or point sprite) will be really small so we won&amp;#8217;t be able to see nice detail of the particle itself. Consider that a building catches on fire. Far away, you clearly see its effect and recognize that it&amp;#8217;s fire. But when you come closer, particles get smaller and smaller til you see the house itself which seems like nothing has done anything to it.&lt;/p&gt;
&lt;p&gt;Secondly, in fact both of the approaches, it&amp;#8217;s harder to control behavior of particle system although you have a good tool to simulate the behaviors and it acts like that in the real simulation. I believe for most hands-on code in purity, if it&amp;#8217;s not designed to be a tool, it will have to be manually adjusted in terms of particle&amp;#8217;s position, number of particles, direction it goes, size, randomness stuff, etc.&lt;/p&gt;
&lt;p&gt;It would conclude that I should stay away from point sprite (in case of fog effect), and use triangle / quad - based instead. Anyway, a better approach is to use shader. This way we gain all control for whenever to do shading, fog&amp;#8217;s settings in terms of density or anything else, and the most importantly, it&amp;#8217;s uniform on the whole screen buffer.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Side-note&lt;/em&gt;: Shawn Hargreaves stated in his &lt;a href="http://blogs.msdn.com/b/shawnhar/archive/2010/03/22/point-sprites-in-xna-game-studio-4-0.aspx" target="_blank"&gt;post&lt;/a&gt; that point sprite won&amp;#8217;t be supported in XNA 4.0. DirectX 10 and 11 will cut out its future from there as triangle / quad - baseds is proved to be as efficient and sometime better than point sprite approach.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Okay, here the things&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Each individual entity has its own effect (or shader) file that describes how to render itself on screen. Surely, every of my shader files include one common include-file where inside has basic operations in both terms of transformation, and pixel shading that they can use and adapt up on to more specific operation.&lt;/p&gt;
&lt;p&gt;Fog related variables lie inside that include-file. The following is &lt;a href="http://en.wikipedia.org/wiki/High_Level_Shader_Language" target="_blank"&gt;HLSL&lt;/a&gt; language declares fog related variables as shared ones across all shader files as I want fog to be globally effect. Just set its settings once, then every single entity, every mesh in simulation will be rendered with consideration of fog shading.&lt;/p&gt;
&lt;pre class="brush: cpp"&gt;// -- Fog properties --
// Linear Fog
shared float fogNear;
shared float fogFar;
shared float fogAltitudeScale;
shared float fogThinning;
// Exponential Fog
shared float fogDensity;
// Others
shared float4 fogColor;
shared bool fogEnabled;
shared int fogFormulae;	// 1 = LINEAR FOG, 2 = Exponential Fog, 3 = Exponential Fog ^ 2
shared const float E_CONST = 2.71828;
&lt;/pre&gt;
&lt;p&gt;To be more elaborate on the above variables, I researched through the Internet and found this &lt;a href="http://msdn.microsoft.com/en-us/library/bb173401%28v=vs.85%29.aspx" target="_blank"&gt;one&lt;/a&gt;. Its information dated back in time of DirectX 9, but the theory still holds. A notable graph comparison at the bottom is really nice and blowing benefit.&lt;/p&gt;
&lt;p&gt;I decided to implement them all for 3 types of fog which are Linear, Exponential 1 and 2. That graph tells everything! Whenever you want any other behavior of fog, you compare them and choose what&amp;#8217;s right for you.&lt;/p&gt;
&lt;pre class="brush: cpp"&gt;// Linear Fog
float4 LinearFogPS(float4 color, float3 worldPosition)
{
    float d = length(worldPosition - cameraPosition);    
    float l = saturate((d - fogNear) / (fogFar - fogNear) / clamp(worldPosition.y / fogAltitudeScale + 1, 1, fogThinning));
    
    return lerp(color, fogColor, l);
}

// Exponential Fog
float4 ExpoFogPS(float4 color, float3 worldPosition)
{
        float f = pow(E_CONST, length(worldPosition - cameraPosition) * fogDensity);
        f = 1.0 / f;
        return saturate(f * color + (1-f) * fogColor);
}

// Exponential 2 Fog
float4 Expo2FogPS(float4 color, float3 worldPosition)
{
        float f = pow(E_CONST, pow(length(worldPosition - cameraPosition) * fogDensity, 2));
        f = 1.0 / f;
        return saturate(f * color + (1-f) * fogColor);
}&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;saturate()&lt;/em&gt; is added for sane of color stability. Note &lt;strong&gt;&lt;em&gt;f*color + (1-f)*fogColor&lt;/em&gt; &lt;/strong&gt;that merely explains the essential of &lt;strong&gt;&lt;em&gt;f&lt;/em&gt; &lt;/strong&gt;by means of &amp;#8220;how much should &lt;em&gt;color&lt;/em&gt; should be seen after combined with fog color&amp;#8221;. This is why Maths is so lovely in hidden message, it won&amp;#8217;t directly speak in normal human language but instead purity of its own tradition.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;fogFormulae &lt;/em&gt;will be a key for us as I will allow users or whoever uses my framework to be able to instantly change the method to calculate fog on-the-fly. Thus I wrote a handy function just to check for which way to calculate for fog. This function will be used across shader files.&lt;/p&gt;
&lt;pre class="brush: cpp"&gt;float4 fogFormulaePS(float4 color, float3 worldPosition)
{
        if(fogFormulae == 1)
                return LinearFogPS(color, worldPosition);
        else if(fogFormulae == 2)
                return ExpoFogPS(color, worldPosition);
        else if(fogFormulae == 3)
                return Expo2FogPS(color, worldPosition);
        else
                return color;
}
&lt;/pre&gt;
&lt;p&gt;This means that caller has a sole responsibility to send-in &lt;em&gt;forFormulae&lt;/em&gt; value into shader file as well as other related fog variables. But as long as they don&amp;#8217;t frequently change the fog setting, they just have to do it once and for all.&lt;/p&gt;
&lt;p&gt;Now, we already set things up.&lt;/p&gt;
&lt;p&gt;Just a side-note for myself, an include-file is going bigger and bigger. Once only pixel shader model (PS Model) version 2 is a way to go, but as things go bigger, I have to change it to version 3. This is a two-sword decision. It would cut users who use PS v2 capable graphics card, and target only for those who use PS v3 and above. Anyway, think it in a positive way, as my framework is bandwidth hunger, setting it to PS v3 will told the requirement for any system to run it in the first place. Misunderstand and self-thinking would not happen.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Now, it&amp;#8217;saa bout time!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So it&amp;#8217;s time to make use of the things we already set up previously. I excerpted the code inside airport&amp;#8217;s shader file of pixel shader function to let you see how we take the code into a real production.&lt;/p&gt;
&lt;pre class="brush: cpp"&gt;RenderGBufferPixelOutput RenderGBufferPS(RenderGBufferPixelInput input)
{
        RenderGBufferPixelOutput output;

        //Color
        //Lerping base and target texture
        //get color from baseTexture
        float4 baseColor = tex2D(baseSampler, input.TexCoords);
        //get color from targetTexture
        float4 targetColor = tex2D(targetSampler, input.TexCoords);

        //lerp from baseTexture to targetTexture (the dTime must be set properly)
        float4 blendedColor = lerp(baseColor, targetColor, dtTime);
        
        // fog
        if(fogEnabled)
                blendedColor = fogFormulaePS(blendedColor, input.WorldPosition);

        ...
        // do whatever you like here
        ...
&lt;/pre&gt;
&lt;p&gt;Not to worry about why I do lerping here. I have 3 different weathers so there&amp;#8217;s some chance that some parts of airport would do lerping from normal weather texture to snow weather texture.&lt;/p&gt;
&lt;p&gt;Line to note is commented out with &amp;#8220;// fog&amp;#8221;. We just test it whether at the moment fog is enabled to apply or not, if so then we use our handy function to handle decision over calculating fog on each pixel whether it&amp;#8217;s Linear, Exponential 1 or 2. We plug in the color, and its world position.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;See the result&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;See the full gallery below of what the result may look like. I reserve the space to the next post for another simple technique I implemented in parallel to fog (as in my case) in order to make it looks much better along the edge of the ground map interfacing with skydome.&lt;/p&gt;
&lt;p&gt;&lt;iframe class="imgur-album" frameborder="0" height="550" src="http://imgur.com/a/HpZKE/embed" width="100%"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;p&gt;Til next time.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/eUwHKrt9K1s" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/eUwHKrt9K1s/22200963760</link><guid isPermaLink="false">http://haxpor.org/post/22200963760</guid><pubDate>Wed, 02 May 2012 00:37:00 +0700</pubDate><category>realko</category><category>fog</category><category>shader</category><feedburner:origLink>http://haxpor.org/post/22200963760</feedburner:origLink></item><item><title>Goodies!
Finished updating some enhancement to RealKo framework,...</title><description>&lt;iframe src="http://player.vimeo.com/video/41223708?title=0&amp;byline=0&amp;portrait=0" width="400" height="224" frameborder="0"&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Goodies!&lt;/p&gt;
&lt;p&gt;Finished updating some enhancement to RealKo framework, and this for April.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/zf_BZXSJiMA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/zf_BZXSJiMA/22044621212</link><guid isPermaLink="false">http://haxpor.org/post/22044621212</guid><pubDate>Sun, 29 Apr 2012 19:53:00 +0700</pubDate><category>realko</category><feedburner:origLink>http://haxpor.org/post/22044621212</feedburner:origLink></item><item><title>DLAA and do it in post-processing</title><description>&lt;p&gt;For a long time that I think to myself, the only way to add anti-aliasing ability into deferred shading renderer is to mess around among its steps which involve some kind of tedious tasks, rerouting and higher maths stuff. So I haven&amp;#8217;t taken a look at this seriously until someone popped up this issue again and I have an enough gap to make it done. Then it&amp;#8217;s time &amp;#8230;&lt;/p&gt;
&lt;p&gt;Anti-aliasing in normal rendering environment can be enabled via toggling a flag telling a hardware to do that for you. But when deferred shading is in place, that thing is not supported. You have to do it yourself.&lt;/p&gt;
&lt;p&gt;The whole idea I started with is &amp;#8220;how we can do this in &lt;strong&gt;post-processing&lt;/strong&gt;&amp;#8221;, if that&amp;#8217;s possible at all? The fact that I don&amp;#8217;t want to mess around among important steps of deferred shading to add another ability. If we could, do it outside the box separately is a good way to go. At least, if something happens we know where it comes from.&lt;/p&gt;
&lt;p&gt;I found a starting point &lt;a href="http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter09.html" target="_blank"&gt;here&lt;/a&gt;. I remember I went back and forth with that link for several times. A reason that S.T.A.L.K.E.R was the very first to implement deferred shading already prove for a gogo that AA would be possible. Nonetheless, I don&amp;#8217;t fully understand the code at the first read. It requires readers to assume something, and make something available before apply the code fully. Then I found &lt;a href="http://www.gamedev.net/topic/580517-nfaa---a-post-process-anti-aliasing-filter-results-implementation-details/" target="_blank"&gt;this&lt;/a&gt;. A very interesting idea came from the guy in forum named &amp;#8220;Styves&amp;#8221;. He seemed to found or create a new adaptation of AA as post-processing technique for deferred shading which works quite well with jungle environment with lot of short edges showing on the screen. The basic idea is to calculate the difference between color space of pixels around the center (in pattern). Then form normal to represent the direction that should be for the that particular position of edge. Finally, get the color samples up again with the perturbation of texture coordinate from newly calculated &amp;#8220;normal&amp;#8221; representing each pixel, in order to sum them up and give out a final color. Unfortunately, this technique don&amp;#8217;t work with my engine. It gave out not acceptable result, merely the same as NO AA.&lt;/p&gt;
&lt;p&gt;Continued searching, and I found this &lt;a href="http://www.gamedev.net/topic/594209-dlaa/" target="_blank"&gt;one&lt;/a&gt;. Another technique called DLAA (DirectionaL Anti-Aliasing) which is used in &lt;a href="http://www.eurogamer.net/articles/digitalfoundry-lucasarts-on-tfu2-tech-blog-entry" target="_blank"&gt;Star Wars&amp;#160;: Force Unleashed II&lt;/a&gt;. I personally think that the idea is similar for most of AA as post-processing here. The main differences come from how we approach to find edges, and additional specific steps. It may need more samples, with weird patterns, and some higher maths if need. I added DLAA as a post-processing into my &lt;a href="http://haxpor.org/post/11100912813/realko-3d-framework-back-in-2009" target="_blank"&gt;RealKo engine&lt;/a&gt;, the result is decent. Much better than previously, things get a little bit more blurry but jaggy edges are gone. But in a certain angle, it can&amp;#8217;t 100% solve the problem but just reduce it.&lt;/p&gt;
&lt;p&gt;DLAA takes 2 passes. &lt;em&gt;First pass&lt;/em&gt; is used to create edge representation image that will be used as input for the next pass.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/ZyqtZ.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2ya0c2WXE1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/5dHpH.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2ya0s9RhK1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In fact, the first pass just marked the edge of all pixel in the input image (which is the final combined with light resulting from deferred shading&amp;#8217;s process). The clever portion of code which I liked the most is that it actually &lt;strong&gt;marks &lt;/strong&gt;the edge for each pixel and stores that piece of information via alpha-channel of the input image itself. This cuts a need to temporary render target to hold a result from Pass 1. So we can draw the result direct to back buffer, and Pass 2 just continues using it as an input. Anyway, I don&amp;#8217;t use this benefit as I may have to use a result from deferred shading again. So I won&amp;#8217;t mess things up with it, and insist to create additional render target to hold the result.&lt;/p&gt;
&lt;p&gt;Then it comes the &lt;em&gt;second pass&lt;/em&gt;. This pass will operates on edge data produced from the first pass. It then measures for short edge, and (if need) long edge. It do several calculations to create data in order to get amount of blur to finally applies to result pixel.&lt;/p&gt;
&lt;p&gt;Short note: Due to its several instructions required, SM (shader model) version 3 (at least) is needed. Thus it breaks my SM 2.0 for this ability especially.&lt;/p&gt;
&lt;p&gt;See some shots below (click on image for original size).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/TlBbN.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2yaw8PAMX1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/6WSzI.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2yawtX4gU1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/mu3Z7.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2yaxoabJE1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/MAAz5.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2yaz43lhC1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/YUYDs.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2yazsiNid1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/2uuSC.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2yb0ntdMp1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/H8o7a.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2yb1gxtlg1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/aguO2.jpg" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2yb2bMSex1qj5i9r.jpg"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As mentioned, I doubt that there always will be some certain angles that AA can&amp;#8217;t solve? Please take a look at the first pair of screen shots. The position of camera is on the tower looking towards the runway in a far sight. We partially see some white swapping with gray color in both edge of runway, and it rather seems we can do something about this.&lt;/p&gt;
&lt;p&gt;Anyway, anyhow, at least a decent AA already did it jobs here: Reducing jaggies.&lt;/p&gt;
&lt;p&gt;Keep rolling &amp;#8230;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/82dYvmtalhs" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/82dYvmtalhs/21667688128</link><guid isPermaLink="false">http://haxpor.org/post/21667688128</guid><pubDate>Tue, 24 Apr 2012 04:22:11 +0700</pubDate><category>aa</category><category>anti-aliasing</category><category>dlaa</category><category>realko</category><category>deferred shading</category><feedburner:origLink>http://haxpor.org/post/21667688128</feedburner:origLink></item><item><title>Testing platform powered by #preprocessor</title><description>&lt;p&gt;Early in the time of yesterday night, I decided to follow along with the challenge &amp;#8220;On your own&amp;#8221; situation of OpenGL graphics programming.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;That was to create a pyramid with its sides rendered using TRIANGLE_FAN, and its bottom rendered using TRIANGLE_STRIP. Multiple vertex buffer or VBO can be used to accomplished with no limit in imagination or other implementations.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So it popped me up to enhance my own existing testing platform playing around with OpenGL to support additional (and separate) testing project.&lt;/p&gt;
&lt;p&gt;For sure, if you invested your effort in creating code-base that much to ensure a solid ground to build up on then there&amp;#8217;s no need to move away from that unless you have to. So that night, I come up with all-in-one testing platform which allows you (and me) to test your testing program without the time lost in creating a new project or re-add source files into it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;First thing first&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Firstly, I started the whole OpenGL testing with only basics and general in mind. I have several testing demo in place.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/tfdGF.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2tjigcX6l1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s not a full feature run once then select which demo you want to see, but rather it compensates me times to push in developing each pure testing demo instead, so I stick to select it at the compile time by change a number in &lt;strong&gt;#define&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Some of testing demos make use of the existing demo, so there&amp;#8217;s no need to write those code again but rather just add features into the existing one.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/lUXPF.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2tjphuWl21qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The original block was for &lt;em&gt;TEST_SUBJECT #4&lt;/em&gt;, but as time goes on I also added &lt;em&gt;TEST_SUBJECT #7&lt;/em&gt; on top of #4. So whenever you run &lt;em&gt;#7&lt;/em&gt; you will see anti-aliasing feature enabled for &lt;em&gt;#4&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Another alternative is to catch up keyboard event for particular key, then you can switch between enabling/disabling anti-aliasing feature of &lt;em&gt;#4&lt;/em&gt;. Anyway, it&amp;#8217;s not my purpose to involve keyboard event catching here, I would rather focus on pure rendering code direction.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Getting bigger&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now I need a separate project to better serve my another testing purpose. Instead of creating a new XCode project and re-do work you already have done previously, I rather add it to one place.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/vbMVL.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2tjyn5qCb1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Basics&lt;/em&gt; is what I have at first, &lt;em&gt;PyramidBasic&lt;/em&gt; is another I would like to spawn/separate the code for. Thus I organize the whole project with grouping folder here, finally the key part is main.cpp. &lt;/p&gt;
&lt;p&gt;By the way, &lt;em&gt;Haxek&lt;/em&gt;, a sub-project referenced from elsewhere, it&amp;#8217;s my slowly in-progress OpenGL game library and is used to power testing demos.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/WHR3o.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2tk2r0fE31qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;By using the power of &lt;strong&gt;preprocessor &lt;/strong&gt;you can get rid of unnecessary headers file you don&amp;#8217;t want to include as they&amp;#8217;re not part of the demo you will be running sooner or later.&lt;/p&gt;
&lt;p&gt;Anyway, it depends on your system design as well. In &lt;em&gt;main.cpp&lt;/em&gt;, you will have to create a right object from a right class (&lt;em&gt;HaxekGame1&lt;/em&gt; or &lt;em&gt;PyramidBasic&lt;/em&gt;) in order to correctly hook up the game loop and make function calls to the right place. To solve this, just use &lt;strong&gt;preprocessor&lt;/strong&gt; again.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/n9R03.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2tkctwCE01qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The fact that &lt;em&gt;game&lt;/em&gt; is a pointer to &lt;em&gt;Haxek &lt;/em&gt;class; my base game class, and &lt;em&gt;HaxekGame1&lt;/em&gt; and &lt;em&gt;PyramidBasic&lt;/em&gt; inherited it, and it exposes &lt;em&gt;virtual&lt;/em&gt; functions for derived class to make use of them. This way, we can ensure that hooking up for game look and making function calls are correct and in a good shape.&lt;/p&gt;
&lt;p&gt;What preprocessor does in the case of function &lt;em&gt;createGame() &lt;/em&gt;above is that it wipes out unwanted code so that the compiler doesn&amp;#8217;t have to look at it. For instance, I chose &lt;em&gt;TNO = 2&lt;/em&gt;, then only header I (and compiler) will know and have knowledge about only comes from &lt;em&gt;PyramidBasic.h, &lt;/em&gt;we don&amp;#8217;t know anything about &lt;em&gt;HaxekGame1&lt;/em&gt;. If preprocessor &lt;em&gt;#if&lt;/em&gt; statement is not used here, and we use actual C/C++ &lt;em&gt;if&lt;/em&gt; statement then things will get messy. Compiler won&amp;#8217;t know about it and will generate error telling you &lt;em&gt;HaxekGame1&amp;#160;&lt;/em&gt;is totally from nowhere&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In any case, yes, we can include all those headers and don&amp;#8217;t touch anything with preprocessor. But by doing that, we have unnecessary code and may lost memory into places we have no chance to use. We can do better than that right&amp;#160;? Yes, we can.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What we got&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/NsjLR.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2tl701NLr1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This one when I set &lt;em&gt;TNO = 1, &lt;/em&gt;&lt;em&gt;TEST_SUBJECT = 15&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/8zdcY.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m2tl7nt35U1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This one when I set &lt;em&gt;TNO = 2.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This approach would serve you for a quick and robust testing platform without time lost in managing or dealing with IDE stuff. Yeah, keep coding &amp;#8230;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/1BRuNDKHsmo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/1BRuNDKHsmo/21486515418</link><guid isPermaLink="false">http://haxpor.org/post/21486515418</guid><pubDate>Sat, 21 Apr 2012 15:19:00 +0700</pubDate><category>c++</category><category>preprocessor</category><category>opengl</category><feedburner:origLink>http://haxpor.org/post/21486515418</feedburner:origLink></item><item><title>Timing system. It's about my code!</title><description>&lt;p&gt;This post responds to my previous &lt;a href="http://haxpor.org/post/21204466051/60-fps-more-or-less" target="_blank"&gt;post&lt;/a&gt; about timing system in game, and issues I met during testing.&lt;/p&gt;
&lt;p&gt;I mentioned in that post about the issue of tearing / unsynced / jittering of the result graphics I met whenever running in full screen mode of GLFW application. In fact, the problem lies inside my timing system.&lt;/p&gt;
&lt;p&gt;The root cause is that in fixed mode, I sent in a wrong elapsed time into update() and render() function. So they all behave in unstable way. The correct value should be fixed elapsed time says 16.67&amp;#160;ms for 60 fps instead I sent in a value in the same way of non-fixed mode.&lt;/p&gt;
&lt;p&gt;Another cause that might hurt it more is about &lt;strong&gt;burst&lt;/strong&gt; elapsed time in startup. The way I hooked up and initialized time (or clock) in my system needed to be in concern. The start time is initialized outside working loop and before the window is created or showed up. Thus the starting gap produces large elapsed time that will hurt the internal timing system at the end, and make it to behave wrongly.&lt;/p&gt;
&lt;p&gt;Let see the code of my fixed and working game&amp;#8217;s timing system.&lt;/p&gt;
&lt;pre class="brush: cpp"&gt;/*
 ============
 Haxek::mainLoop
 ============
 */
void Haxek::mainLoop()
{
    // Timing
    clock_t cur_clock = clock();
    m_diffClock = cur_clock;
    m_diffClock = m_diffClock - m_frameClock;
    
    // Update frame clock
    m_frameClock = cur_clock;
    
    // Set time to elapsedTime
    float diff_secs =  m_diffClock * 1.0f / CLOCKS_PER_SEC;
    m_elapsedTime.secs = diff_secs;
    m_elapsedTime.ms = diff_secs * 1000.0f;
    
    m_fps.update(m_elapsedTime);
    
    if(!m_isFixedTimestepMode)
    {
        update(m_elapsedTime);
        if(m_elapsedTime.ms &amp;gt; m_target_fixed_timestep_ms)
        {
            m_isGameRunningSlowly = true;
            m_droppedFrames++;
            
            // Catch up
            update(m_elapsedTime);
        }
        else
        {
            m_isGameRunningSlowly = false;
            
            render(m_elapsedTime);
            postRender(m_elapsedTime);
            m_fps.incrementFrame();
        }
    }
    else {
        if(m_elapsedTime.ms &amp;gt; m_target_fixed_timestep_ms)
        {
            m_isGameRunningSlowly = true;
            m_droppedFrames++;
            
            // Catch up
            ElapsedTime fixedElapsedTime;
            fixedElapsedTime.secs = m_target_fixed_timestep_ms / 1000.0f;
            fixedElapsedTime.ms = m_target_fixed_timestep_ms;
            
            update(fixedElapsedTime);
        }
        else
        {
            m_isGameRunningSlowly = false;
            
            m_countingUpdateTime_ms += m_elapsedTime.ms;
            
            if(m_countingUpdateTime_ms &amp;gt; m_target_fixed_timestep_ms)
            {
                m_countingUpdateTime_ms -= m_target_fixed_timestep_ms;
                
                // fixed: major
                ElapsedTime fixedElapsedTime;
                fixedElapsedTime.secs = m_target_fixed_timestep_ms / 1000.0f;
                fixedElapsedTime.ms = m_target_fixed_timestep_ms;
                
                update(fixedElapsedTime);
                render(fixedElapsedTime);
                postRender(fixedElapsedTime);
                
                m_fps.incrementFrame();
            }
        }
    }
    
    // Post
    postMainLoop();
}

&lt;/pre&gt;
&lt;p&gt;I designed it to be portable and be able to easily and flexibly integrate with many of open source windowing library out there. At the current stage, it works with GLUT, FreeGlut, and GLFW. Anyhow, the code above should be independent of any libraries we decide to use as it&amp;#8217;s one of cores to game application.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In code&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I will base the precision and granularity from clock() function. It returns ticks, and we need to convert it back to seconds, and millisecond as if we need to. In the process, we need at least 3 clocks to make fixed/non-fixed mode happen.&lt;/p&gt;
&lt;p&gt;As well, I already mentioned that &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.isfixedtimestep.aspx" target="_blank"&gt;this&lt;/a&gt; inspired me much that let me keep what I&amp;#8217;m doing here. I added a flag to indicate whether the game is running slowly as well as the amount of dropped frame for performance monitoring purpose. If the game is running slowly, we will drop a call to &lt;em&gt;render()&lt;/em&gt; and catch it up by calling &lt;em&gt;update()&lt;/em&gt;. In fact, we could do it even better by setting a maximum amount of dropped frame to be accepted. So if it exceeds the limit, we can then take some responding actions or warn users.&lt;/p&gt;
&lt;p&gt;Note the code section at &amp;#8220;// fixed: major&amp;#8221; as well. That&amp;#8217;s a piece that I missed it at the first go, so it produces unstable of rendering result.&lt;/p&gt;
&lt;p&gt;A couple of places found in the code is a placeholder (function) for specifying callback function in the wrapper class or inherited class. So this function is as part of a core class.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/4ICqp3Uz6Og" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/4ICqp3Uz6Og/21211401615</link><guid isPermaLink="false">http://haxpor.org/post/21211401615</guid><pubDate>Mon, 16 Apr 2012 21:50:00 +0700</pubDate><category>timing system</category><category>timing</category><category>time</category><category>fixed</category><category>non-fixed</category><feedburner:origLink>http://haxpor.org/post/21211401615</feedburner:origLink></item><item><title>60 FPS ? More or less ?</title><description>&lt;p&gt;This is a continuing post for my OpenGL journey days.&lt;/p&gt;
&lt;p&gt;With the fact that I&amp;#8217;ve started with a bare-bone OpenGL then I have to hook other stuff manually. The first important stuff I need to pull it in is &lt;strong&gt;Windowing System&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Talk about Windowing System, there&amp;#8217;re plenty rather several out there readying libraries to be linked with in no time. I started the whole things with &lt;a href="http://www.opengl.org/resources/libraries/glut/" target="_blank"&gt;GLUT&lt;/a&gt;, a plain simple yet old and non-active development since several years ago but already found itself in Mac OS X platform since several updates and it&amp;#8217;s there and no more effort to download and brew thing again. So at least it guarantees to be a component which exists for wide (legacy and plain old) users and developers.&lt;/p&gt;
&lt;p&gt;I came across using GLUT with no pain, and easily integrate it with my OpenGL testing platform in no time. It&amp;#8217;s clean and fast readable and understandable. Not long that I progressed through the true understanding of the history of OpenGL and its way of working. The deprecation model, its compatibility and profiles pop up the need to properly create a correct OpenGL rendering context!&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s totally different if you use OpenGL 2.1 or 3.0. You just jump into another boundary world with (maybe) no turning back. Apparently upon the pile of research over Internet about OpenGL and its deep technical jargon history. OpenGL on Mac OS X seems to be very lag in progress, and staying late after other major platforms like Windows, or even Linux. OpenGL 3.x, if I can remember it correctly, seems to be supported in Mac back in its platform updates version 10.7 in July 2011. Yes, not only we should wait for it but also driver and extension updates from ATI as it&amp;#8217;s the main part of graphics card installed in Mac system. I understand the feeling of author of &lt;a href="http://www.amazon.co.uk/OpenGL-SuperBible-Comprehensive-Tutorial-Reference/dp/0321712617/ref=dp_ob_title_bk/277-2324751-3308648" target="_blank"&gt;OpenGL Super Bible 5th Edition&lt;/a&gt; in which it came out in the time of Mac didn&amp;#8217;t support OpenGL 3.x just yet.&lt;/p&gt;
&lt;p&gt;For OpenGL context creation, developers need to specify which version and whether they need the code to be compatible with older version or plain-through forward compatible context. This is done with its context creation, &lt;strong&gt;and it&amp;#8217;s the problem in using with GLUT.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;GLUT offers no context creation setting. It forces developers to use what&amp;#8217;s there automatically and compatibility in mind across all the platforms. I found this out when I wanted to know which OpenGL version it created for my testing application via &lt;em&gt;glGetString&lt;span class="s1"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;GL_VERSION&lt;/span&gt;&lt;span class="s1"&gt;) &lt;/span&gt;&lt;/em&gt;&lt;span class="s1"&gt;which returns &lt;em&gt;2.1 ATI-7.18.11. &lt;/em&gt;Darn, no way! With this set up, I can&amp;#8217;t even test the code with 3.x. So I turn it around finding a more customizable windowing library.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="s1"&gt;It comes &lt;a href="http://freeglut.sourceforge.net/" target="_blank"&gt;FreeGlut&lt;/a&gt;, a free version and open source alternative of GLUT. GLUT, in fact, is not an open source. Its license goes to Mark Kilgard. Any modified source code of the library must be shipped with the the product itself. It restricts some of limitation most developers won&amp;#8217;t apply. Then I have my hands on FreeGlut. It turns out that FreeGlut is not friendly with Mac OS X at all. Its user-based not land in Mac platform but spread throughout Windows, and Linux/Unix. Only a very small percentage of Mac users use it. I decided to use this because it&amp;#8217;s same same code to GLUT and its cleanness and approach in hooking function calls which I like the most but with additional ability to customized in OpenGL context creation!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="s1"&gt;At the time, its main website listed out 4 major stable packages to download. No pre-build available to download for Mac or any other platforms. So I have to manually compile and build it. Several failed attempts to compile and build come to desperate to find another solution. So I turn around again to another one, &lt;a href="http://www.glfw.org/" target="_blank"&gt;GLFW&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I successfully compiled and built GLFW and not much in effort to hook it up with my application. Everything is done but with one exception that my own timing system (implemented as part of testing OpenGL platform) doesn&amp;#8217;t fully work out cleanly with GLFW.&lt;/p&gt;
&lt;p&gt;To be more elaborate on timing system, I implemented it since my day one in testing OpenGL application. In game, we need not the ability to fully render all content of the game in full speed of 60 fps but it would be better to restrict it or even no limitation on fps at all. That comes with the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.isfixedtimestep.aspx" target="_blank"&gt;topic&lt;/a&gt; of Fixed Timestep and Non-Fixed Timestep. I am inspired by the notion of fixed timestep back in a day I have worked with XNA. Its definition and simple explanation raises the need to provide both options of rendering approach and timing in game. In fixed mode (with ability for you to set a target fixed time as well), your game will try (for my implementation, it will restrict!) to render the game in X fps in which X is what you can set. Not all games on different platforms need to be capped at 60 fps. Consider a simple game with slow paced rendered on low-powered mobile device, just 25 or 30 fps can do a trick. Even web-based game which goes for 25 fps for flash styled. It has its own purpose so timing system is (at least to say) a major part in game application.&lt;/p&gt;
&lt;p&gt;My experiment with GLFW only found an issue with my timing system. I found out that GLFW already capped the frame rate at its will automatically, so when I combine it with my timing system lied internally in game loop, the game will be double slow delayed in time! So things won&amp;#8217;t get smooth out as it seems to be. I fixed it by disabling a fixed mode, and let GLFW does its work on that restriction alone. It works fine but somewhat raises a question. How can I set a target fps of the game to run with GLFW? I filed out a question &lt;a href="https://sourceforge.net/projects/glfw/forums/forum/247562/topic/5198755" target="_blank"&gt;here&lt;/a&gt; on a main soureforge.net site of the project. I expect someone would come and answer it.&lt;/p&gt;
&lt;p&gt;In addition, I experimented with non-fixed mode as well. By setting &lt;em&gt;glfwSwapInterval(0) &lt;/em&gt;which means to disable v-sync mode, the application is told to be relied on the capability of software or hardware as it goes, no more restriction here. Also with non-fixed mode is enabled in my timing system, the things run out as expected. The fps goes beyond 8000 which is similar to what I have tested with GLUT. This goes well with fixed-mode enabled on my timing system, now I can cap it to run says 30 fps or 60 fps at will. But that result only shows in window mode, whenever I go to full screen mode the polygon drew is tearing / unsynced / and jittering. I truthfully think that it&amp;#8217;s because of v-sync is disabled by the result of calling to a mentioned function of GLFW. Another question raises again on how to prevent those effects with the software / hardware (graphics card) were already told to render the content as fast as possible with no restriction&amp;#160;? So I replied to my own earlier question and ask about this as well.&lt;/p&gt;
&lt;p&gt;A bit to mention that during a laboring test with GLFW, I even went back and tried to find a way to compile FreeGlut. Indeed, I found &lt;a href="http://lookass.ch/?id=4&amp;amp;area=art&amp;amp;art=221" target="_blank"&gt;one&lt;/a&gt;. Initially I don&amp;#8217;t care even if it does only compile with not latest version but rather 2.6.0, just give it a go. After successfully compiled and built the libraries, then hooked up with my code in action, I feel disappoint immediately. Why? FreeGlut uses old &lt;a href="http://en.wikipedia.org/wiki/X_Window_System" target="_blank"&gt;X11&lt;/a&gt; system to show up its window. I don&amp;#8217;t like this as it needs to open up X11 agent program first before it can even run your program. That&amp;#8217;s case bringing me back and forth and at best try to make GLFW works out!&lt;/p&gt;
&lt;p&gt;For now, I will use GLFW at least for testing purpose with my OpenGL stuff for a long while. It has potential to be my integrated windowing system for yet to come a game product (hmm? hopefully). It offers flexible integration with callback and specific context creation. Also with non-to-mention, it breaks out the loop design (remember &lt;em&gt;glutMainLoop()&lt;/em&gt;) and allows developers to hook up the function calls inside instead. At last, if I could find a solution to prevent those tearing / unsynced / jittering effect from uncapped rendering approach, I will definitely update here at my blog.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Updated&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;- See my updated &lt;a href="http://haxpor.org/post/21211401615/timing-system-its-about-my-code" target="_blank"&gt;post&lt;/a&gt; responding to the issues above.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/aV0pGNUJE50" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/aV0pGNUJE50/21204466051</link><guid isPermaLink="false">http://haxpor.org/post/21204466051</guid><pubDate>Mon, 16 Apr 2012 16:43:00 +0700</pubDate><category>fps</category><category>framerate</category><category>glut</category><category>freeglut</category><category>glfw</category><category>opengl</category><category>c++</category><feedburner:origLink>http://haxpor.org/post/21204466051</feedburner:origLink></item><item><title>Cease PongMaster, go wild with OpenGL</title><description>&lt;p&gt;The fact that I have lost my interest over &lt;a href="http://haxpor.org/post/18656911822/pong-master" target="_blank"&gt;Pong Master&lt;/a&gt;, the game currently in my development.&lt;/p&gt;
&lt;p&gt;That&amp;#8217;s bad, to be honest, that I can&amp;#8217;t finish in-progress project on iOS this time. Anyway I have another reason kicking in to put this down for quite some times before (maybe) heading back when it&amp;#8217;s possible.&lt;/p&gt;
&lt;p&gt;For a couple of weeks ago, I have continued working further for another addition of Airport model for &lt;a href="http://haxpor.org/post/19450166572/this-time-with-yangon-international-airport" target="_blank"&gt;RealKo&lt;/a&gt; and it&amp;#8217;s as part for my continuing of its phase I development back in a couple of years ago. Not only that I can brush up my graphics programming, but also feel that I should switch to 3D in full engagement from now on or at least several months to come.&lt;/p&gt;
&lt;p&gt;RealKo was developed with XNA (of course, it&amp;#8217;s on top of DirectX). Sure it will be running only on Windows system. That&amp;#8217;s not long ago when I have a plan to myself to port this stuff available on other platforms such as Mac OS X, Linux, or possible to include embed systems like mobile. So I started to look at OpenGL again. That also includes some personal interests watching &amp;amp; listening to detail of games, technology prediction, Id Software, and graphics programming from John Carmack. It totally blew me away!&lt;/p&gt;
&lt;p&gt;Days passed with lots of research on OpenGL vs DirectX, OpenGL history, deprecation dilemma, OpenGL implemented in Wolf3D / Doom / Quake, portable code on various platforms including consoles. I feel that those things truthfully kick me to be in front of computer and keyboard with no need to even rest. Hah, that means I may drag my soul back once more.&lt;/p&gt;
&lt;p&gt;To be more elaborate on OpenGL as why does it should be selected as a graphics API for from-scratch implementation or anything might be besides Id Software is &lt;a href="http://blog.wolfire.com/2010/01/Why-you-should-use-OpenGL-and-not-DirectX" target="_blank"&gt;Wolfire&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;From now on, I will be revisiting a lot of technical stuff of graphics programming from vertex forming, texture mapping, shadowing, lighting, to more advanced topic like ray tracing or whatever may placed there in research (or white) paper. I will target to work on it with OpenGL 3.x-3.2 as it&amp;#8217;s the best choice for me now and for preparation for the future to come. Intentionally, when it&amp;#8217;s saturated in topics and enough in stable I plan to create a game framework based on that beast in order to use for my own in-house game development, possibly in a right time to come.&lt;/p&gt;
&lt;p&gt;And for Pong Master, we may see each other again when the time is right, &amp;#8230;, but not yet, not yet &amp;#8230;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/8VLF3OF6wBg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/8VLF3OF6wBg/20899094415</link><guid isPermaLink="false">http://haxpor.org/post/20899094415</guid><pubDate>Wed, 11 Apr 2012 18:33:06 +0700</pubDate><category>opengl</category><category>graphics programming</category><category>graphics</category><category>pongmaster</category><category>john carmack</category><feedburner:origLink>http://haxpor.org/post/20899094415</feedburner:origLink></item><item><title>Re-submitted PongMaster for PlayBook</title><description>&lt;p&gt;Since I&amp;#8217;ve got an e-mail from BlackBerry app world dated back on 15 March stating below &amp;#8230;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m20q7jDIG41qj5i9r.png"/&gt;&lt;/p&gt;
&lt;p&gt;I just have a chance to start fixing it tonight.&lt;/p&gt;
&lt;p&gt;As I have no real PlayBook device, so the successful test on simulator won&amp;#8217;t guarantee anything. Back then I have posted asking for suggestion about this situation on &lt;a href="http://cocos2d-x.org/boards/16/topics/9372?r=10035#message-10035" target="_blank"&gt;&lt;a href="http://cocos2d-x.org/boards/16/topics/9372?r=10035#message-10035%C2%A0"&gt;http://cocos2d-x.org/boards/16/topics/9372?r=10035#message-10035 &lt;/a&gt;&lt;/a&gt;. I believe and thought to myself that the cause should be about custom .ttf file I used across scenes in the game. Although there&amp;#8217;s a high chance that it&amp;#8217;s the root cause of problem, but the same goes -&amp;gt; it won&amp;#8217;t guarantee anything. Anyway, just roll a dice and see what&amp;#8217;s happen!&lt;/p&gt;
&lt;p&gt;PlayBook &lt;strong&gt;don&amp;#8217;t&lt;/strong&gt; support custom .ttf file. It probably has a fail-safe on simulator. Apparently, this is a trap that lures me to think my game should be okay if it runs on a real device.&lt;/p&gt;
&lt;p&gt;Not at all. Rendering text font on simulator has not failed, it just returned back to normal vague font style. But if it runs on real device, the result goes the same way as stated in the e-mail above.&lt;/p&gt;
&lt;p&gt;I have two choices to solve this.&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Render a custom .ttf font with XCode, capture the screen, save it into an image file, and finally use it in the game on PlayBook.&lt;/li&gt;
&lt;li&gt;Use normal installed font specified via font-face name such as &amp;#8220;Time News Roman&amp;#8221; or &amp;#8220;Courier New&amp;#8221;. See the list &lt;a href="http://peterhansen.ca/blog/playbook-font-list.html" target="_blank"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;I know my time is tight and font style is another story according to my purpose playing around with PlayBook here. So I go on with number 2.&lt;/p&gt;
&lt;p&gt;In addition to that major fix, I also fixed a ball speed by adjusting a ball&amp;#8217;s mass with the observation on a simulator.&lt;/p&gt;
&lt;p&gt;By the way, my fellow &lt;span&gt;rahulbolia &lt;/span&gt;who I met on this thread &lt;a href="http://devblog.blackberry.com/2012/03/package-id-rejected-by-app-world/" target="_blank"&gt;&lt;a href="http://devblog.blackberry.com/2012/03/package-id-rejected-by-app-world/"&gt;http://devblog.blackberry.com/2012/03/package-id-rejected-by-app-world/&lt;/a&gt;&lt;/a&gt; about solving unsigned .bar but accidentally submitted to App World &lt;strong&gt;didn&amp;#8217;t seem&lt;/strong&gt; to get an e-mail asking about shipment address yet although his application was approved on 14 March and he already sent e-mail to ask them about it. If ones meet the same situation, you better check that link out.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/iST5ZN_qulY" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/iST5ZN_qulY/20537298874</link><guid isPermaLink="false">http://haxpor.org/post/20537298874</guid><pubDate>Fri, 06 Apr 2012 01:33:00 +0700</pubDate><category>pong master</category><category>playbook</category><feedburner:origLink>http://haxpor.org/post/20537298874</feedburner:origLink></item><item><title>Did this for you, Earth.</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m1r2e1JXFT1qkbepmo1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Did this for you, &lt;a href="http://www.earthhour.org/" target="_blank"&gt;Earth&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/d04EfSX8708" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/d04EfSX8708/20221707472</link><guid isPermaLink="false">http://haxpor.org/post/20221707472</guid><pubDate>Sat, 31 Mar 2012 19:51:37 +0700</pubDate><category>earth</category><category>earth hour</category><category>60+</category><feedburner:origLink>http://haxpor.org/post/20221707472</feedburner:origLink></item><item><title>Tank - Experimental Project back in Nov 2008</title><description>&lt;p align="center"&gt;&lt;img src="http://media.tumblr.com/tumblr_m1hrnnlkxR1qj5i9r.jpg" width="50%"/&gt;&lt;/p&gt;
&lt;p&gt;My mind is going to be miss-understood in myself, I can&amp;#8217;t decide whether to post this kind of stuff (old stuff) &lt;strong&gt;Now &lt;/strong&gt;or &lt;strong&gt;Dated back in time.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s kinda cheat in its own sense as a new post has gone through the blog without traces or even know about. That&amp;#8217;s initially my pure sense without knowing that it&amp;#8217;s actually true at the end.&lt;/p&gt;
&lt;p&gt;So then I investigated whether the &lt;strong&gt;Dated back in time&lt;/strong&gt; post will be seen in Archive / Search section&amp;#160;?&lt;/p&gt;
&lt;p&gt;No sir&amp;#160;! I can&amp;#8217;t find it, so the dilemma concluded and ended with the way I will select to post any &lt;strong&gt;Dated back in time&lt;/strong&gt; in &lt;strong&gt;Now&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&amp;#8212;- Let&amp;#8217;s jump into a topic &amp;#8212;-&lt;/p&gt;
&lt;p&gt;Before I even give some explanations, visual comes first.&lt;/p&gt;
&lt;p&gt;&lt;iframe frameborder="0" height="375" src="http://player.vimeo.com/video/39188964?title=0&amp;amp;byline=0&amp;amp;portrait=0" width="500"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tank &lt;/strong&gt;is an experimental project I did back in November 2008 to test out accessing model&amp;#8217;s structure, its manipulation &amp;amp; transformation and home-made physics for tank&amp;#8217;s movement on the ground.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m1hrys9PjM1qj5i9r.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s a small world that you can experiment things you want.&lt;/p&gt;
&lt;p&gt;Terrain was generated by height map with &lt;em&gt;procedural approach&lt;/em&gt;, so we got a natural scene as you might perceive.&lt;/p&gt;
&lt;p&gt;Tank model itself has some parts which we can interact and manipulate or transform (not only scale) with them.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m1hs4yHojA1qj5i9r.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;Its turret can be rotated as well as its cannon which can be lifted up / down. I just need to know which axis to do the work.&lt;/p&gt;
&lt;p&gt;From the experiment, I rendered 3 axises {Red, Blue, and Yellow} representing each part of the whole model in order to see whether it&amp;#8217;s properly manipulated or transformed.&lt;/p&gt;
&lt;p&gt;Well. As far as I concern, it did its job quite well.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m1hs9i0QQb1qj5i9r.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;Not only model I experimented with. The home-made simple physics for Tank&amp;#8217;s movement on the ground can be done as well. It gave out more realistic when Tank moved on across the different level of ground, yes, you&amp;#8217;re back in World War with this set up.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m1hscdabmn1qj5i9r.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve blended the test altogether and see if one effects another. You can see axises were slightly off, but that I believe it&amp;#8217;s because of rendering code of those axis which need to be more accurate than what it was now.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m1hsgyKBuz1qj5i9r.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;Apart from those, we could do a little bit more by playing with camera, and modes which could be available for Tank&amp;#8217;s driver.&lt;/p&gt;
&lt;p&gt;Camera is such an important puzzle to look at in order to boost the feeling of how we could achieve the word &amp;#8220;interesting&amp;#8221;.&lt;/p&gt;
&lt;p&gt;3 modes of camera were available&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Normal&lt;/li&gt;
&lt;li&gt;Followed-camera or fighting mode&lt;/li&gt;
&lt;li&gt;Bird-eye-view&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m1hsn2NnH01qj5i9r.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;For the scene, it&amp;#8217;s applied with simple shadow mapping (which in turns broken at the moment I found this project deep into sector of harddisk, I don&amp;#8217;t have time to fix it now though).&lt;/p&gt;
&lt;p&gt;Skydome was made into life by the approach of transitioning of cloud map over its mesh.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Fork / Clone / Download / &amp;#8230; you name it&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Well, well. I have made all source code available for anyone interested in those experiments. The code may not be optimized and may not represent the best I could offer as of now.&lt;/p&gt;
&lt;p&gt;So just head to &lt;a href="https://bitbucket.org/haxpor/tank/" target="_blank"&gt;&lt;a href="https://bitbucket.org/haxpor/tank/"&gt;https://bitbucket.org/haxpor/tank/&lt;/a&gt;&lt;/a&gt; or directly grab it at &lt;a href="https://bitbucket.org/haxpor/tank.git"&gt;https://bitbucket.org/haxpor/tank.git&lt;/a&gt; or git@bitbucket.org:haxpor/tank.git.&lt;/p&gt;
&lt;p&gt;Be sure to read license though. &lt;a href="http://sam.zoy.org/wtfpl/" target="_blank"&gt;WTFPL&lt;/a&gt; is what the best I could tag it for. Anything can happen right&amp;#160;? ;)&lt;/p&gt;
&lt;p&gt;Til next time.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/fbKNBxhN0sA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/fbKNBxhN0sA/19952501350</link><guid isPermaLink="false">http://haxpor.org/post/19952501350</guid><pubDate>Mon, 26 Mar 2012 20:46:42 +0700</pubDate><category>3.0</category><category>bitbucket</category><category>cloud</category><category>experimental</category><category>fork</category><category>generation</category><category>heightmap</category><category>homemade</category><category>model</category><category>physics</category><category>skydome</category><category>tank</category><category>terrain</category><category>transformation</category><category>transition</category><category>xna</category><category>clone</category><category>bitbucket</category><category>WTFPL</category><feedburner:origLink>http://haxpor.org/post/19952501350</feedburner:origLink></item><item><title>Doodling - Pixeling - Animating, "FatRobot"</title><description>&lt;p align="center"&gt;&lt;a href="http://i.imgur.com/lM347.gif" target="_blank"&gt;&lt;img align="middle" alt="FatRobat's Dancing" height="70" src="http://i.imgur.com/lM347.gif" width="70"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is a 2nd day since I jumped into the world of pixel art as a need to teach my coding hard self to be able to create art stuff and put it into a game. As far as I can tell you, I fell hard loving it already&amp;#160;!&lt;/p&gt;
&lt;p&gt;This time, I decided to create a few frames animation of pixel art. The reason is plain simple. Game uses spritesheet, and animation is somewhat a core to game creation. This will let me know more about pixel art&amp;#8217;s animation workflow and test exporting into spritesheet.&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://i.imgur.com/0JB5d.png" target="_blank"&gt;&lt;img align="middle" alt="FatRobot Spritesheet" height="70" src="http://i.imgur.com/0JB5d.png" width="280"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;All things went well, although it consumed my time. A dancing robot you see above is a result, I would call it &amp;#8220;FatRobot&amp;#8221;.&lt;/p&gt;
&lt;p&gt;So let me tell you a bit more about the starting point and the process I just did. It&amp;#8217;s a pure sharing experience as I am &lt;em&gt;&lt;strong&gt;no&lt;/strong&gt;&lt;/em&gt; expert in art but nonetheless I strongly believe it will benefit someone for something at the end (as well for those who use &lt;strong&gt;Aseprite&lt;/strong&gt;). Then read along &amp;#8230;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Conceptualizing&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m15d7tsPZA1qj5i9r.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;It would be not much fuss if I start with a simple geometry and shape. The first I can think of is Robot. Then only a few conceptual drawings are made and I decided to go with it.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m15dazXcyV1qj5i9r.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;As this is a practice for pixel art animation, so I planned a head of time for each frame I will use for this dancing (kind of aerobics action). It consists of just 4 frames. A few, probably 3-4 is a go, much more than this is merely not need at all. I just don&amp;#8217;t need it to be that much precise in movement.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Outlining&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="http://i.imgur.com/CHVTn.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m15dz25sOB1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;br/&gt;&lt;/strong&gt;The common commands you will use most are &amp;#8220;Line&amp;#8221; - L, and &amp;#8220;Pen tool&amp;#8221; - B. As I use this tool more and more on day-to-day work, those shortkeys will automatically digested into your brain in no time&amp;#160;!&lt;/p&gt;
&lt;p&gt;Titbits here for &lt;em&gt;Aseprite, &lt;/em&gt;when you create a new file, the program will ask about resolution, color type, and background. What you enter here is the &amp;#8220;Frame&amp;#8221; width and height not the entire spritesheet going to be exported later in time. Instead we will modify and draw each frame via layer.&lt;/p&gt;
&lt;p&gt;Another thing that it will ask is &amp;#8220;Background&amp;#8221; type. Mostly we will choose &amp;#8220;Transparent&amp;#8221; and this is a choice for me as well as cocos2d/cocos2d-x has no easy way (or at least to say not flexible) to mask the key color for transparency on the file for image. By choosing &amp;#8220;Transparent&amp;#8221; will reduce our work later on in code. So plan about this&amp;#160;!&lt;/p&gt;
&lt;p&gt;After things are all set, we will have an empty working space. You will see a crossing line in the background in which it indicates that it&amp;#8217;s transparent (mask). Personally I really don&amp;#8217;t like this distracting background while I&amp;#8217;m doodling my robot so I then create another &lt;strong&gt;layer &lt;/strong&gt;and paint the whole layer as white color (or black) just to give me some contrast before actually start draw. This will make me more focus on the subject&amp;#160;!&lt;/p&gt;
&lt;p&gt;*You create a new layer by pressing &amp;#8220;N&amp;#8221; (indicated as B on the lower right of the screen, if you click on the image it will direct you to the full quality image).&lt;/p&gt;
&lt;p&gt;**And when we export, we just press &amp;#8220;Tab&amp;#8221; and disable the visibility of layer B, so the whole things are normal the same as we start creating this robot&amp;#160;!&lt;/p&gt;
&lt;p&gt;So recap here,&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Layer A - just mask or transparent plane&lt;/li&gt;
&lt;li&gt;Layer B - contrast plane in white or black&lt;/li&gt;
&lt;li&gt;Layer C - the plane we will work on and do some drawing&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Coloring &amp;amp; Shading&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First before we go into coloring, we need to limit ourselves by select some colors to work with. As I&amp;#8217;ve read from Derek Yu&amp;#8217;s &lt;a href="http://www.derekyu.com/?page_id=219" target="_blank"&gt;tutorial&lt;/a&gt;, we should focus on a few color (2-3 colors) for the whole work we create. For pixel art, more colors mean distracting.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;#8220;Take Mario character as an example.&amp;#8221;&lt;br/&gt; I digested this from Derek Yu&amp;#8217;s tutorial.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I chose to shine out only 3 colors &amp;#8220;Red&amp;#8221;, &amp;#8220;Blue&amp;#8221;, and &amp;#8220;Flesh&amp;#8221;.&lt;/p&gt;
&lt;p&gt;But &amp;#8230;&lt;/p&gt;
&lt;p&gt;not just select some color as a main, we probably need other colors to support or to do gradient as well. So it&amp;#8217;s a better idea to create our own &lt;em&gt;&lt;strong&gt;palette&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/NqGBp.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m15f50PBUg1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The way to create a palette in Aseprite is as follows.&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Create a new file with arbitrary resolution.&lt;/li&gt;
&lt;li&gt;Use &amp;#8220;Line&amp;#8221; to isolate each color.&lt;/li&gt;
&lt;li&gt;Paint each vertical block with desire color.&lt;/li&gt;
&lt;li&gt;Click &amp;#8220;View&amp;#8221;-&amp;gt;&amp;#8221;Palette Editor&amp;#8221;.&lt;/li&gt;
&lt;li&gt;Click on &amp;#8220;+&amp;#8221; symbol and click &amp;#8220;save&amp;#8221;.&lt;/li&gt;
&lt;li&gt;Choose format of image file.&lt;/li&gt;
&lt;li&gt;Done, you have your palette in a formet that compatible with Aseprite program.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;In fact, there&amp;#8217;re number of possible ways to do this as per your own taste. From the image you see above, I listed out the possible colors I will use and limit myself to them (soft limit, as along the way I broke the rules and add more color later&amp;#160;!). The benefit of limiting in this way will keep you focus, and not be overwhelming by so many color to choose from appearing in the left-side palette.&lt;/p&gt;
&lt;p&gt;You may question that by limiting the colors going to be used. Will it reduce the file size of image as well&amp;#160;? No, as the color type you choose from the start will already determine it.&lt;/p&gt;
&lt;p&gt;Then we load the palette to work with our main workspace by open up &amp;#8220;Palette Editor&amp;#8221; and &amp;#8220;load&amp;#8221; it with our file saved earlier.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/88lPU.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m15eoqmK2u1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then you&amp;#8217;re free to engage in coloring.&lt;/p&gt;
&lt;p&gt;When you&amp;#8217;re done with coloring, then you go for shading to enhance the result of your work.&lt;/p&gt;
&lt;p&gt;Shading consists of the following.&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Normal shading&lt;br/&gt;Take a sun&amp;#8217;s direction into account and add darker color on top of your colored block. &lt;/li&gt;
&lt;li&gt;Soft shadows&lt;br/&gt;These are areas that indirectly lit. Or say, a second shade with lighter color than the previous one. This will give more realistic especially on curved surfaces.&lt;/li&gt;
&lt;li&gt;Highlights&lt;br/&gt;Areas that are directly hit by the sun, highlights will occur. &lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Please note that my work doesn&amp;#8217;t have highlights as when I added, it looks strange so I decided to cut it out.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Selective Outlining&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/jatma.png" target="_blank"&gt;&lt;img src="http://media.tumblr.com/tumblr_m15fvmTU1P1qj5i9r.png"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A near to finish work. But if we perform this step by eliminate some outline out from our drawing. It will look more realistic and all parts blend together better. Be sure to look the result from the actual size not the zoomed size to judge what&amp;#8217;s good for.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;At last&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Finally, just brush up your work add some more detail. See if anything is missing or feel right/not right. At last, what you&amp;#8217;ve done in a past (probably) couple hours will pay out at the end.&lt;/p&gt;
&lt;p&gt;By doing all of these, I believe that I found a reason why indie game developers or solo game developers out there are so tie to pixel art. Because it&amp;#8217;s the least cost to engage and require not much of learning curve. As well, its pixelated and retro look are quite attractive for game developers to come by and use this technique to create graphics putting into use in their game in no time. In addition, as not all game developers will have their own artists to help them create images as they need, so this way will help themselves out walking by their own legs&amp;#160;!&lt;/p&gt;
&lt;p&gt;After finished the past 2 days with pixel art discovery and hard but fun practicing, I strongly believe now that I can feed my own game with art resource and the boring times won&amp;#8217;t be easily pop up as when I&amp;#8217;m exhaust or bored on something (code or art) I can switch endlessly between the two and maintain my own motivation and energy for doing game projects.&lt;/p&gt;
&lt;p&gt;Good night&amp;#160;!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/NTNF1vbbhNw" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/NTNF1vbbhNw/19587351117</link><guid isPermaLink="false">http://haxpor.org/post/19587351117</guid><pubDate>Tue, 20 Mar 2012 03:55:00 +0700</pubDate><category>pixel art</category><category>fatrobot</category><category>aseprite</category><category>animation</category><category>spritesheet</category><feedburner:origLink>http://haxpor.org/post/19587351117</feedburner:origLink></item><item><title>Yeah !
I’m sure who knew me will be a little bit of...</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m13e21OTtf1qkbepmo1_400.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Yeah !&lt;/p&gt;
&lt;p&gt;I’m sure who knew me will be a little bit of surprise of why I did this art my self. The reason is that I need some art in my game and I can’t wait ! ha hah&lt;/p&gt;
&lt;p&gt;The most comfortable for me is “Pixel Art” and this one is a real start into this world even it’s just a practicing.&lt;/p&gt;
&lt;p&gt;Some time before I tried all by myself, and thought all alone that my approaches are not standard (kind of) and mostly I used feeling with unpolished result. So it’s time I decided to take a look at some guides over the Internet. Fortunately I’ve found a tutorial on notable steps doing pixel art from &lt;a href="http://www.derekyu.com/?page_id=219" target="_blank"&gt;Derek Yu&lt;/a&gt;. I found him in &lt;a href="http://www.tigsource.com/" target="_blank"&gt;TigSource&lt;/a&gt; as a reference to indie games he did.&lt;/p&gt;
&lt;p&gt;Instead of using Photoshop, I use &lt;a href="http://www.aseprite.org/" target="_blank"&gt;Aseprite&lt;/a&gt;. Now, as far as I can tell you, I fall in love with it !&lt;/p&gt;
&lt;p&gt;Enjoy my humble “Muddy Dragon” for the time being.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/V_NcDxhz9Js" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/V_NcDxhz9Js/19522551541</link><guid isPermaLink="false">http://haxpor.org/post/19522551541</guid><pubDate>Mon, 19 Mar 2012 01:01:00 +0700</pubDate><category>pixel</category><category>pixel art</category><category>derek yu</category><category>aseprite</category><category>tigsource</category><feedburner:origLink>http://haxpor.org/post/19522551541</feedburner:origLink></item><item><title>Continuing "Pong Master"</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m11bx4BT4z1qj5i9r.png"/&gt;&lt;/p&gt;
&lt;p&gt;Time to focus on creating this game more and more.&lt;/p&gt;
&lt;p&gt;Today, I have a chance to meet my sister coming back from Oman to visit me. I knew and planned about this, so a latest build was loaded up in my iPad and took out the playing test with my sister.&lt;/p&gt;
&lt;p&gt;There&amp;#8217;s a chance for this game to be fun. It eventually needs more features, and enhancement in terms of touching and gesture interactions. As time goes by, hopefully the issues won&amp;#8217;t be too large.&lt;/p&gt;
&lt;p&gt;Peace &amp;#8230;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/J7s_YsoHq3A" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/J7s_YsoHq3A/19454725042</link><guid isPermaLink="false">http://haxpor.org/post/19454725042</guid><pubDate>Sat, 17 Mar 2012 22:40:58 +0700</pubDate><category>pong master</category><category>pongmaster</category><feedburner:origLink>http://haxpor.org/post/19454725042</feedburner:origLink></item><item><title>This time with Yangon International Airport</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m116yuCXV21qj5i9r.png"/&gt;&lt;/p&gt;
&lt;p&gt;Now it&amp;#8217;s back with support of Yangon International Airport&amp;#160;!&lt;/p&gt;
&lt;p&gt;I implemented &lt;a href="http://haxpor.org/post/11100912813/realko-3d-framework-back-in-2009" target="_blank"&gt;RealKo Engine&lt;/a&gt; back in 2 years ago as part of a freelance job during University. Briefly the goal of this engine is to render airport model plus some features to use in training of officers in traffic control simulation.&lt;/p&gt;
&lt;p&gt;For Yangon airport model, it&amp;#8217;s still in early phase rather than final version but the point is that I&amp;#8217;m glad that the engine itself can prove to support multiple or custom made airport models. It used to render Suvarnabhumi Airport as a first model before, and now with another.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/-XGkap6LGQo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/-XGkap6LGQo/19450166572</link><guid isPermaLink="false">http://haxpor.org/post/19450166572</guid><pubDate>Sat, 17 Mar 2012 20:45:51 +0700</pubDate><category>realko engine</category><category>realko</category><category>yangon</category><category>yangon international airport</category><feedburner:origLink>http://haxpor.org/post/19450166572</feedburner:origLink></item><item><title>moosader:

rootstudio:

I was poking around on The Independent...</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_m0vz8xuZNP1qcy5tzo1_400.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;a class="tumblr_blog" href="http://moosader.tumblr.com/post/19347253822/rootstudio-i-was-poking-around-on-the"&gt;moosader&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a class="tumblr_blog" href="http://rootstudio.tumblr.com/post/19296835360/i-was-poking-around-on-the-independent-gaming"&gt;rootstudio&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I was poking around on &lt;a href="http://www.tigsource.com/"&gt;The Independent Gaming Source&lt;/a&gt; (which I haven’t done in like forever) and noticed they have a new feature…  The &lt;a href="http://daid2.mine.nu/~daid/tigsource_pics/"&gt;TIGForum Image Crawler&lt;/a&gt; programmed by Daid.  Basically it trawls the TIGSource’s forums for all manner of gaming/poly/pixel images for you to drink in with your eyeballs and more than lives up to it’s caveat…&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;&lt;em&gt;WARNING: Using this tool might waste many hours of your life. Do not forget to eat and sleep!&lt;/em&gt;&lt;/strong&gt;&lt;/h2&gt;
&lt;/blockquote&gt;
&lt;p&gt;Good for inspiration~!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Surely I will waste a ton with this !&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/e4oIDVZCvAU" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/e4oIDVZCvAU/19348571450</link><guid isPermaLink="false">http://haxpor.org/post/19348571450</guid><pubDate>Fri, 16 Mar 2012 00:03:22 +0700</pubDate><category>tigsource</category><feedburner:origLink>http://haxpor.org/post/19348571450</feedburner:origLink></item><item><title>PlayBook's Package ID mismatch after failing to submit a signed app</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m0wvnzOGpE1qj5i9r.png"/&gt;&lt;/p&gt;
&lt;p&gt;Frustrated at first when just got to know later I&amp;#8217;ve failed to sign the application before submitting to App World.&lt;/p&gt;
&lt;p&gt;They sent me back two links on how to resolve the issue.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devblog.blackberry.com/2012/03/package-id-rejected-by-app-world/" target="_blank"&gt;&lt;a href="http://devblog.blackberry.com/2012/03/package-id-rejected-by-app-world/"&gt;http://devblog.blackberry.com/2012/03/package-id-rejected-by-app-world/&lt;/a&gt;&lt;/a&gt;&lt;br/&gt;&lt;a href="http://supportforums.blackberry.com/t5/Testing-and-Deployment/How-to-sign-your-BAR-file-from-the-command-line/ta-p/944647%20" target="_blank"&gt;&lt;a href="http://supportforums.blackberry.com/t5/Testing-and-Deployment/How-to-sign-your-BAR-file-from-the-command-line/ta-p/944647%C2%A0"&gt;http://supportforums.blackberry.com/t5/Testing-and-Deployment/How-to-sign-your-BAR-file-from-the-command-line/ta-p/944647 &lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And yeah, it works but took some time to figure out this and that.&lt;/p&gt;
&lt;p&gt;When I re-submit it again, I got the very top result picture. It stated that my application&amp;#8217;s package id is mismatch with the original one submitted. The fact that you&amp;#8217;re fail to sign your application in the first time, and re-submit it again will not gonna make both package id be the same. Fortunately I found the solution (hopefully) &lt;a href="http://devblog.blackberry.com/2012/03/package-id-rejected-by-app-world/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Briefly I need to shoot an e-mail telling BlackBerry PlayBook offer Support about my case (most guys out there faced this case, so don&amp;#8217;t worry), and in the mean time just submit a new application to App World again with the hope that they will still give you a free device :/&lt;/p&gt;
&lt;p&gt;Nonetheless even the case seems to close, testing house reported back &amp;#8220;&lt;span&gt;When tapped the game it&amp;#8217;s closed by itself&amp;#8221; and it&amp;#8217;s faster than my issue e-mail seem to be replied. Yes, it&amp;#8217;s the fact that I don&amp;#8217;t have a real device to test, so even it works on Simulator it may not on the real device.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have to continue figuring it out &amp;#8230;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/Lepukfw-IJg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/Lepukfw-IJg/19334121921</link><guid isPermaLink="false">http://haxpor.org/post/19334121921</guid><pubDate>Thu, 15 Mar 2012 12:48:35 +0700</pubDate><category>blackberry</category><category>playbook</category><category>package-id</category><category>package id</category><category>signed</category><feedburner:origLink>http://haxpor.org/post/19334121921</feedburner:origLink></item><item><title>A panorama shot of my room.
Just have enough feeling recently...</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m0sbpnKIV71qkbepmo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;A panorama shot of my room.&lt;/p&gt;
&lt;p&gt;Just have enough feeling recently after read a post &lt;a href="http://arstechnica.com/gaming/news/2011/10/bedrooms-boardrooms-and-chicken-farms-where-the-worlds-best-indie-games-get-made.ars/" target="_blank"&gt;here&lt;/a&gt;. Then I believe I should share mine as well, it’s no faulty on anything.&lt;/p&gt;
&lt;p&gt;I has set this room up since about a week ago. Two main working environments for Mac and Windows side. Of course, currently I invest on cross-platform and open source game framework in which I can work on both side, nonetheless working on one will give more flexible on certain tasks and things relating to specific platform.&lt;/p&gt;
&lt;p&gt;At first, a humble netbook beside my rightmost PC used to serve as a gateway for that PC to connect to Internet as its WiFi adapter is broken and malfunction. But now, a new adapter was brought in and replace its temporary survival functionality.&lt;/p&gt;
&lt;p&gt;Apart from those, Roland TD-4KX, V-Drum Series is my beast on relaxing state and calm down my mind. It’s placed near iMac as I can plugged and hook up via Garage Band to record my play.&lt;/p&gt;
&lt;p&gt;The last stuff is reading side, several books I have collected since several years ago, most of them are un-finished in reading, some of them are finish.&lt;/p&gt;
&lt;p&gt;I don’t think there’s a better place than home. Don’t you think ?&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/Si0NR_aV9SI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/Si0NR_aV9SI/19187927682</link><guid isPermaLink="false">http://haxpor.org/post/19187927682</guid><pubDate>Tue, 13 Mar 2012 01:36:00 +0700</pubDate><category>panorama</category><category>shot</category><category>room</category><category>one man</category><feedburner:origLink>http://haxpor.org/post/19187927682</feedburner:origLink></item><item><title>3 days spent on Dynamic Content Building Tool</title><description>&lt;p&gt;I have spent the past 3 days on creating a tool used to build XNA content dynamically. In fact, this is a extended tool based on my creation of &lt;a href="http://haxpor.org/post/11100912813/realko-3d-framework-back-in-2009" target="_blank"&gt;RealKo framework&lt;/a&gt;. Back in that time the framework ties to configuration of XNA content (model and xml config files) at compile time, so when users have a new model they need to render in the engine, they have no choice as they need to recompile things up and run it again.&lt;/p&gt;
&lt;p&gt;This&amp;#8217;s probably not a good approach of flexibility. So it&amp;#8217;s time for me to revive things up creating a tool used in this circumstance.&lt;/p&gt;
&lt;p&gt;(&amp;#8230; and yeah, I just find a time swapping from my Pong Master project to this, and after this post is finished I&amp;#8217;ll back on route.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Dynamic Content Building with XNA&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;What&amp;#8217;s the approach I will use here&amp;#160;?&lt;/p&gt;
&lt;p&gt;I will let users select an arbitrary model file (mainly focus on .fbx file) to load, then the tool will render it with Deferred shading technique in the program. In fact, it&amp;#8217;s not quite fully deferred shading as although your rendering pipeline supports that but with the simple set up of directional lights coming from all 4 ways in 3d space. So it seems everything seems bright. This is a limit as if a timeframe to develop such a tool is not much, and users want just a visual aspect with no fancy so this set up is a fast way to come up with.&lt;/p&gt;
&lt;p&gt;Take a consideration into point lights, or spot light targeting at some areas not all area. Deferred shading would be perfectly beautiful for that. If time to creating a customization and set up of different light source is there, then this will leverage rendering pipeline and visualization even further.&lt;/p&gt;
&lt;p&gt;So back to the point. It seems like simple enough to just let users select a model file. &lt;strong&gt;Unfortunately&lt;/strong&gt; as I discover that the basic framework cannot identify and automatic discover &lt;em&gt;diffuse&lt;/em&gt; texture mapping to each mesh of the model. Although the artist already attached the diffuse texture for each mesh back in 3d tool, and export it nicely. Yes, the information is there in export file (as I examine it via normal text editor, the export file is in ascii format so it would be great to let artist exports it in this format for your ease in debugging) but the framework only can discover only one and the first diffuse texture assigned to any mesh of the whole model. Please note for the case prior I used &lt;em&gt;BasicEffect&lt;/em&gt; to read the texture out. I&amp;#8217;m not sure whether there&amp;#8217;s some ways to do.&lt;/p&gt;
&lt;p&gt;So I solved it with another approach by using configuration file to define which mesh maps to which texture. In this way, you can use ful textureset as they are diffuse texutre, normal texture, and specular texture if they are any and available to use. That would be a great choice of rendering in terms of this technique (of course even better with the customization of light source).&lt;/p&gt;
&lt;p&gt;In order to know which mesh is mapping to which texture. There&amp;#8217;s a need to also export model&amp;#8217;s structure. This method goes inside the model for each mesh, and print out its mesh index, bone index, or even do other calculations such as how big of the model, its radius, and number of polygons. Even more complicate ways to implement this is via &lt;strong&gt;ContentImporter&lt;/strong&gt; or &lt;strong&gt;ContentProcessor&lt;/strong&gt; in which these two I don&amp;#8217;t go with it with this project. For the case I used, only load a new model and process it manually from the interfaces provided to access of Model class. It&amp;#8217;s quite simple enough not to goes so complex.&lt;/p&gt;
&lt;p&gt;With the information of model&amp;#8217;s structure, users can take a look at the output file and see targeted mesh for its mesh index then go back to text editor to create an xml file that will be used for loading into a program later on.&lt;/p&gt;
&lt;p&gt;The following is the sample of the xml file described a model being load.&lt;/p&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;
&amp;lt;Model&amp;gt;
    &amp;lt;Name&amp;gt;Ship 1&amp;lt;/Name&amp;gt;
        &amp;lt;FilePath&amp;gt;ship1.fbx&amp;lt;/FilePath&amp;gt;
        &amp;lt;Scale&amp;gt;1.0&amp;lt;/Scale&amp;gt;
        &amp;lt;Meshes&amp;gt;
                &amp;lt;Mesh&amp;gt;
                        &amp;lt;Index&amp;gt;0&amp;lt;/Index&amp;gt;
                        &amp;lt;BoneIndex&amp;gt;-1&amp;lt;/BoneIndex&amp;gt;
                        &amp;lt;Textures&amp;gt;
                                &amp;lt;Diffuse&amp;gt;ship1_c.tga&amp;lt;/Diffuse&amp;gt;
                                &amp;lt;Normal&amp;gt;null&amp;lt;/Normal&amp;gt;
                                &amp;lt;Specular&amp;gt;null&amp;lt;/Specular&amp;gt;
                        &amp;lt;/Textures&amp;gt;
                &amp;lt;/Mesh&amp;gt;
        &amp;lt;/Meshes&amp;gt;
&amp;lt;/Model&amp;gt;
&lt;/pre&gt;
&lt;p&gt;At this point, we could have a config file being compiled as a XNA content. That is to say both config file along with model file and its texture files are in region of XNA content. If so they are in need to be built at compile time with Visual Studio. This is not an option here. So instead I just normally read an xml config file via normal I/O provided in .net framework. The flexible class I used is &lt;strong&gt;XmlDocument&lt;/strong&gt;. If you take a look at it, you will see how flexible to work with nodes, tags, and its value in xml file rather than messing up with serialization and parsing through the entire xml file. The great thing about XmlDocument class is that, it allows developers to access the target value in chain just like.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;node.GetElementsByTagName(&lt;/span&gt;&amp;#8220;Book&amp;#8221;)[&amp;#8220;Author&amp;#8221;][&amp;#8220;Name&amp;#8221;][&amp;#8220;FirstName&amp;#8221;]&lt;/p&gt;
&lt;p&gt;And that&amp;#8217;s it about the approach I used to create this simple humble tool.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Things to note, erros to note&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;MSBuilder is a core builder used to compile content into .xnb in runtime. It&amp;#8217;s different from ContentManager as appears in the Game1 class of normal XNA game project. MSBuilder is at another region different of ContentManager, so when you call Load() via MSBuilder it actually does on a temporary directory. A little bit more about it is that, the stable and safe version that has worked since XNA version 3.0 is MSBuilder version 2 which consists of the following&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Microsoft.Build.BuildEngine - version 2&lt;/li&gt;
&lt;li&gt;Microsoft.Build.Framework - version 2&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;It has 2 versions which are 2, and 3.5. Mostly when you add their reference into a project, the default one is version 3.5, and when compile the project and run, things go error and error stating something weird. So we better stick to version 2.0.&lt;/p&gt;
&lt;p&gt;There&amp;#8217;s also a file called &lt;strong&gt;App.Config&lt;/strong&gt; used as a trick to bind reference conflict for Build.Framework. Its content is as follows.&lt;/p&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;
&amp;lt;configuration&amp;gt;
  &amp;lt;runtime&amp;gt;
    &amp;lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&amp;gt;
      &amp;lt;dependentAssembly&amp;gt;
        &amp;lt;assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/&amp;gt;
        &amp;lt;bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/&amp;gt;
      &amp;lt;/dependentAssembly&amp;gt;
    &amp;lt;/assemblyBinding&amp;gt;
  &amp;lt;/runtime&amp;gt;  
&amp;lt;/configuration&amp;gt;
&lt;/pre&gt;
&lt;p&gt;If you download your base project from somewhere to further develop on such as from App Hub, and found out that you found an error. This might be one of the cause. Please check if this file is exist in your project.&lt;/p&gt;
&lt;p&gt;Another big chunk lies inside &lt;em&gt;ContentBuilder &lt;/em&gt;class which provided by Microsoft for convenient in development involving with content builder. The things to note about this file is firstly the version of XNA to build against. If you switch to another version of XNA, make sure to change this line to match XNA version.&lt;/p&gt;
&lt;pre class="brush: c#"&gt;        // What importers or processors should we load?
        const string xnaVersion = ", Version=3.0.0.0, PublicKeyToken=6d5c3888ef60e27d";&lt;/pre&gt;
&lt;p&gt;If you build your own custom Importer/Processor, and you found an error stating that the system cannot find your custom content class while it&amp;#8217;s reading, then you might not include the reference of those content class to your main project just yet. &lt;/p&gt;
&lt;p&gt;*From above, there&amp;#8217;s a high chance that you will create another library project just to hold your content information and be referenced by other projects in development. For my case, once I tried, I have at least 4 projects to hook.&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;XNA game project&lt;/li&gt;
&lt;li&gt;Winform project&lt;/li&gt;
&lt;li&gt;ContentShared (just to hold content information, it&amp;#8217;s XNA library project.)&lt;br/&gt;Inside, it will be a data class and a ContentTypeReader class corresponding for each data class.&lt;/li&gt;
&lt;li&gt;ContentPipeline&lt;br/&gt;Inside, it will be ContentTypeWriter class to write data out into .xnb file. &lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;So ContentShared project is a central of data information for your content.&lt;/p&gt;
&lt;p&gt;To note, I use XNA game project instead of implement a rendering inside winform application. If I do that, I have to mess up with GameTime, the controls and things will got messy. I found the solution on how to hook up render each frame of XNA project into a picture to draw on PictureBox control on winform. It requires about 10 lines of code, and it works like a charm, please check it &lt;a href="http://royalexander.wordpress.com/2008/10/09/xna-30-and-winforms-the-easy-way/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So back to reference things. You may need to try to add a reference to make the ContentBuilder knows via code by doing the following.&lt;/p&gt;
&lt;p&gt;1.) Add a direct code into &lt;em&gt;pipelineAssemblies &lt;/em&gt;at the very first of the code in ContentBuilder class.&lt;/p&gt;
&lt;pre class="brush: c#"&gt;        static string[] pipelineAssemblies =
        {
            "Microsoft.Xna.Framework.Content.Pipeline.FBXImporter" + xnaVersion,
            "Microsoft.Xna.Framework.Content.Pipeline.XImporter" + xnaVersion,
            "Microsoft.Xna.Framework.Content.Pipeline.TextureImporter" + xnaVersion,
            "Microsoft.Xna.Framework.Content.Pipeline.EffectImporter" + xnaVersion,
            "E:/somepath_base/somepath_sub/bin/Debug/ContentShared.dll"
        };
&lt;/pre&gt;
&lt;p&gt;But note that this is not so elegant as it&amp;#8217;s fixed. A better is to determine the current working directory via &lt;em&gt;Path &lt;/em&gt;class and get into a correct directory.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sample Screenshot&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m0m665FbOA1qj5i9r.png"/&gt;&lt;/p&gt;
&lt;p&gt;&amp;#8230;&lt;/p&gt;
&lt;p&gt;I guess that&amp;#8217;s all about what I would like to say.&lt;/p&gt;
&lt;p&gt;Happy coding and hacking&amp;#160;!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/iLOGMmjaSBU" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/iLOGMmjaSBU/18997064479</link><guid isPermaLink="false">http://haxpor.org/post/18997064479</guid><pubDate>Fri, 09 Mar 2012 17:19:00 +0700</pubDate><category>content builder</category><category>contentbuilder</category><category>dynamic</category><category>xna</category><category>msbuilder</category><category>assemblies</category><category>assembly</category><category>reference</category><category>Path</category><category>importer</category><category>processor</category><category>App.config</category><category>xmldocument</category><category>mesh</category><category>texture</category><category>diffuse</category><category>normal</category><category>specular</category><feedburner:origLink>http://haxpor.org/post/18997064479</feedburner:origLink></item><item><title>Pong Master - Progress</title><description>&lt;p&gt;I&amp;#8217;m quite happy with my progress over this small game I have made so far.&lt;/p&gt;
&lt;p&gt;Now, it&amp;#8217;s modified to be in universal application in which I inserted the adaptive content scaling into the game. Please don&amp;#8217;t be too amazed with that word, may be I&amp;#8217;m not sure which word to use :P&lt;/p&gt;
&lt;pre class="brush: cpp"&gt;void Utility::SetUp() { 
// get the current device's window size 
CCSize winSize = CCDirector::sharedDirector()-&amp;gt;getWinSizeInPixels(); 
// precompute values (must call this after CCDirector is created) 
_precomputed_adaptedContentScaleFactor = fminf(winSize.width / 1024, winSize.height / 768); 
// set device active use 
if(winSize.width == 480) 
    _deviceActiveUse = DEVICE_IPODIPHONE_3; 
else if(winSize.width == 960) 
    _deviceActiveUse = DEVICE_IPHONE_4; 
else if(winSize.width == 1024) 
    _deviceActiveUse = DEVICE_IPAD; } 
&lt;/pre&gt;
&lt;p&gt;&lt;br/&gt;See &lt;strong&gt;SetUp() &lt;/strong&gt;function above, it&amp;#8217;s not that elegant that I use the very basic method to detect which device currently runs the game. Yes, you may use macros or any functions specific to platform you&amp;#8217;re developing for. But this approach works, and I tested it on iPhone (simulator) and iPad (simulator / device). Anyway please note that, I use &lt;em&gt;&lt;strong&gt;cocos2d-x&lt;/strong&gt;&lt;/em&gt; here.&lt;/p&gt;
&lt;p&gt;I learned about the formule from reading in this link &lt;a href="http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_does_cocos2d-x_support_multi-resolution" target="_blank"&gt;&lt;a href="http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_does_cocos2d-x_support_multi-resolution"&gt;http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_does_cocos2d-x_support_multi-resolution&lt;/a&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So by knowing which device users&amp;#8217; using, then I route things up and multiply the &lt;em&gt;scale factor &lt;/em&gt;to values that needed to be scaled especially in positioning code. So I made this game once and give it a little effort on modifying a positioning / scaling code for objects appeared in the game.&lt;/p&gt;
&lt;p&gt;See iPhone version below (captured from Simulator).&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m0e6t6G2fQ1qj5i9r.png"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m0e6tiBsNi1qj5i9r.png"/&gt;&lt;/p&gt;
&lt;p&gt;One interesting piece of information from my testing is that whenever you modified the size of sprite then its physics properties you hooked up with Box2d may needed to be adapted as well. The ball is the case. As original, its size is bigger and one fixed value of &lt;em&gt;density &lt;/em&gt;is fixed as well. But then you resized the ball (to smaller) then it&amp;#8217;s previous value of density mapped to the sprite is too low, and it makes the ball moves really fast&amp;#160;!&lt;/p&gt;
&lt;p&gt;Again with a benefit to detect which device is running, I can set different values of density to a ball for different device running it. See snippet code excerpted from this project below.&lt;/p&gt;
&lt;pre class="brush: cpp"&gt; 
// Create shape definition and add to body 
b2FixtureDef ballShapeDef; 
ballShapeDef.shape = &amp;amp;circle; 
// ** selective depends on device active use 
// set density depends on device active use (affecting physics properties) 
int deviceActiveUse = Utility::Instance().GetDeviceActiveUse(); 
if(deviceActiveUse == DEVICE_IPAD) 
{ 
   ballShapeDef.density = 1.0f; 
} 
else if(deviceActiveUse == DEVICE_IPODIPHONE_3) 
{ 
   ballShapeDef.density = 10.0f; 
} 
else if(deviceActiveUse == DEVICE_IPHONE_4) 
{ 
   ballShapeDef.density = 5.0f; 
} 
ballShapeDef.friction = 0.0f; 
ballShapeDef.restitution = 1.0f;&lt;/pre&gt;
&lt;p&gt;&lt;br/&gt;I will be thinking what&amp;#8217;s more to be added into a game, what&amp;#8217;s I&amp;#8217;m missing now and then. More to be come.&lt;/p&gt;
&lt;p&gt;{&lt;strong&gt;Edited}&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Fixed that actually my code has a flaw, changed CCDirector::sharedDirector()-&amp;gt;getWinSize() to CCDirector::sharedDirector()-&amp;gt;getWinSizeInPixels()&lt;br/&gt;This will take into account retina enabled for both iPhone 4 and new iPad as well.&lt;br/&gt;You can find more information about this at &lt;a href="http://www.cocos2d-x.org/boards/7/topics/4025?r=9559" target="_blank"&gt;&lt;a href="http://www.cocos2d-x.org/boards/7/topics/4025?r=9559%C2%A0"&gt;http://www.cocos2d-x.org/boards/7/topics/4025?r=9559 &lt;/a&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/Haxpor/~4/vFcJj9A9mNI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/Haxpor/~3/vFcJj9A9mNI/18772870651</link><guid isPermaLink="false">http://haxpor.org/post/18772870651</guid><pubDate>Mon, 05 Mar 2012 10:32:00 +0700</pubDate><category>pong master</category><category>cocos2d-x</category><category>box2d</category><category>detect</category><category>screen</category><category>resolution</category><feedburner:origLink>http://haxpor.org/post/18772870651</feedburner:origLink></item></channel></rss>

