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: