21.2.13

Lazy Evaluation

If you've ever worked with Flex Components you will know by heart what lazy evaluation is, as it is a big dogma streching across all components. But lazy evaluation is pretty common and usefull in all kinds of applications. The idea is to delay calculations/operations till the moment you actually need them done.

A simple example is instantiating when accessing the object:
public function myObject():Object
{
 if ( this.myObject == null ) this.myObject= new Object();
 return this.myObject;
}

Output as Argument

Considere a simple mathematical function like add() or multiply() for a simple 2D point object. How would you implement it in case you cannot overload operators?

Do you manipulate the values of the caller with those from the argument, like a += b?
Do you make it a static methode and require 2 argumets? Do you instantiate and return a new object?

3.11.12

Voxel Performance

In my previous post about the voxel prototype  performance was not a concern but this time I'd like to share a brief explaination about the two basic optimizations I did to boost performance significantly:
  • y-buffer: only draw visible pixels
  • setPixels and direct memory access

31.10.12

Image Partitioning

Image compression and compression in general is a really interessting topic and although the algorithm I'd like to talk about goes into that direction the algorithm is not meant to be a compression in terms of memory but has been born out of the idea to reduce drawing calls by drawing as big rectangles as possible instead of each pixel on its own.

The problem to find as big same colored rectangles as possible in an image quickly became so interessting, that I decided to try it, even though I didn't know whether it would be faster or not.

result, heuristic and source

30.10.12

Isometric Voxel Terrain Prototype

I'm currently prototyping a voxel based isometric renderer (for terrain) and it was suprisingly painless to get some neat looking results but it is far from fast and scaleable. But the performance issues are topic for another post and would require further investigations and coding sessions. For now I'd just like to share the results and give and explain a bit how I've done it.

voxel and normalmapping rendering results with different lightning and maps

The renderer works just like a combination of displacement and normal mapping but 2D.
It takes a grayscaled heightmap and uses it to look up how much each pixel needs to be moved up. It also uses a normalmap to calculate the intensity for each pixel based on the current light-direction.

20.10.12

"Fullscreen" for HTML

In my previous post I wrote about how I encountered a few issues implementing a very basic stage setup for my Haxe library and explained how I solved a particular type error. In this post I'm going to show how I made a "fullscreen" HTML application, using the normal compile process NME provides.

The NME compiler uses a *.nmml document for various target settings, including the window size of your applications. So my first guess to make my HTML programm fill the entire browser was to specify the width and height in the application.nmml to 100% like I would do in CSS/HTML.
<window width="600" height="480" if="flash" />
<window width="???" height="???" if="html5" /> <!-- how 100%? only INT allowed ... -->
But using the % character causes errors when compiling for HTML. Another way would be to simply change the generated index.html but although the index might not need to be generated, it will be every time you compile and replaces any change you might have made. Not so cool :|
<div id="haxe:jeash" 
     style="background-color: #FFFFFF; width: 100%; height: 100%" 
     data-framerate="60">
</div>
Maybe there is a way to prevent the compiler from replacing your index.html but ideally I would be able to change the dimesion at runtime anyway. 

Jeash StageQuality; Enum or String?

The last day's I've been playing with Haxe and NME without any specific goals. Now I'm starting to code myself a very basic library, similar to my AS3 one. But already after a few lines I encountered some problems regarding the stage setup for HTML.

In this post I'm going to write about a minor jeash specific type error "String should be StageQuality" I got while implementing the basic stage setup and its solution. Although its really simple I felt like sharing.

16.10.12

Haxe + NME: First Steps

I'm currently looking for a smart way to carry all my practice and experience with ActionScript over to other platforms. Haxe, a powerful language able to cross compile into several languages and even mobile platforms seems to be just that. The syntax is similar to ActionScript but with lots of sugar on top. It also supports the main targets I'm interessted in: Flash, Android and HTML/JS/PHP. 

NME:
At first I thought I would be able to use the same API for all languages, but with Haxe alone you need to use quite a lot of language specific packages in order to compile to your target correctly. I also hoped I would be able to generate and manipulate HTML directly, but unfortunatly it does not provide a convenient way to do so ... unless you use it with NME.