Saturday, June 19, 2010

Water shader

    Up until a month ago I had been from time to time wondering how the great effects are done, especially the water. Thanks to the indie game group I joined, I finally had a reason to implement that myself. So the code was based on Riemer's XNA Tutorial, which has lots of resources regrading shader programming. The initial goal is to generate ripples on the water surface where the ship passes.



    However the organizer decided to have our prototype redone in an open source XNA game engine, for a more reliable environment of content creation, so the development is paused temporarily (i.e. summer vacation :p).

Friday, June 18, 2010

Wide-angle image straightening

This is by far the trickiest energy-based optimization I have ever implemented. The idea is quite similar to the spectral conformal parameterization algorithm I have used for the model viewer, however, it requires more energy terms and hence more tune-ups to work properly. The main purpose of the paper is to let the user identify straight lines that are bent by the wide-angle photography, especially fish-eye lens, to preserve certain content. It makes some good use of stereographic projection to help converge to the final result, and especially the smoothing terms that prevent distortion. Let's look at a few examples:

Original images:

Straightened images(user specified lines in purple):


   As you could probably tell either I didn't pick the right pictures or I had not idea which parts to straighten, so this method works best if the user knows what he is doing.

Seamless blending


   When it comes to blending of 2 images, the simplest way is to construct a Laplacian pyramid, and then choose an alpha ratio to sum the images at all the levels. But the resulting image would have color disparity and unnatural boundaries. However by introducing the Laplace operator and a linear system to solve for the desired image, the artifacts are much reduced.

Image to paste to:


Image to cut from:



After computation:

Mor results:

Sunday, June 13, 2010

Anyone can make games

If you have never heard about Global Game Jam, it's an indie game making event hosted in dozens of countries and span more than a hundred locations worldwide, starting 2009.
There is basically no rule at all regarding how a team is made or what genre a game must be, except for a few topics that one should keep in mind while building the game. Although anybody is welcome to join, a required property of each person is "Passion", since it only lasts 48 hours from the beginning to the end, and there is no prize other than honor itself, so to speak.
In 2009 we had a game developed in XNA, because back then we had 2 programmers already knowing the basics of it, thanks to the class. So the idea is you have a pendulum dangling from above with an object attached to its end, and you only use one button to release the object, in order to form a barricade to shield the poor human beings from harm. But during the course you might kill them if it hits them.


Although we got very close to the mechanics we had wanted, there was no time left for fine-tuning the physics elements, which was one of the uncertainties that one must face.

And yes in 2010 I returned to the game jam and of course had a good time. This time we chose Flash as the platform that the game runs on, simply for its ubiquity on everybody's computers. The central concept is to use all sorts of sound effects to torture a prisoner, without telling the player what to do, hence I would rather call it a gadget rather than a video game.



Finally in hindsight, the lessons I learned from them is that the most successful teams would not make things from scratch, given how short the duration is, and should also stick with tried-and-true concepts. But being less adventurous, on the other hand, does not manifest the spirit of GGJ.

Thursday, June 10, 2010

Games for grades

  If you are not fortunate enough to get matriculated into CMU's ETC or USC's Gamedev program, and you still want to feel what it's like to do game projects in a course, there are lots of schools/developments that offer similar courses now.
I will simply embed a youtube video about what I have helped make here:



  According to my previous experience if you don't have dedicated artists in your group(like us), it's a lot easier to just "borrow" some assets from other sources, and remember it's always the idea that counts but the degree of polish(especially when you don't have too much time to finish the work).
  The first game was made for an individual homework, to test how fast one can familiarize himself with XNA environment from zero understanding. It turned out to be a smooth experience(a couple days). But the 2 more ambitious group games following that weren't as easy to implement, because XNA is nowhere close to being a game engine, but rather just a loosely coupled toolset itself (A reason my current project is being redone with a game engine instead of built from scratch).

Tuesday, June 8, 2010

Simple model viewer with automatic UV unwrapping

   Years ago while I was struggling with Maya, having to do UV mapping myself, which I hated to, I was thinking perhaps there would be a less dumb approach to tackling this problem. Then years later when I took a geometric modeling course at NYU, one of the assigned readings happened to be addressing this specific topic, namely, 3D/2D parametrization. Simply put, if we have a 3D mesh, we want to find a way to explain where a particular vertex's 2D position is(texturing) by only looking at the 3D data itself. 
Enough talk, let's look at a simple case:

And its corresponding 2D parametrization(UV mapping), which is done quite well:

The goal here is to preserve the shapes of the triangles as much as possible(regardless of the sizes). 
So you could expect a situation when it doesn't work quite as well:


And its UV map, which doesn't look quite good:


Now you can get a sense that although the shapes are well-preserved, the sizes could go crazy. So it's really a problem of striking the balance between the size and shape of each triangle, and the subjective view of the artists who have to paint it. I would say that if the future hardware supports per-polygon texturing, people won't need to find a good explanation for 3D to 2D anymore(there will never be one).