Pavel Krajcevski's blog

Author(s): 21

2008-08-01

Fully Loaded

The watermesh now has a working loader. The tags that the factory accepts within the <params> tag are as follows:

<length> The number of units long the mesh is along the z-axis.
<width> The number of units long the mesh is along the x-axis.
<gran> The number of vertices per unit length/width
<murk> The murkiness of the water
<isocean> Boolean value saying whether or not the mesh is an ocean.

The object accepts only the factory and material tags. Note that the proper material needs to be set in order for the watermesh to function properly.

2008-07-25

Oceanography

The past few weeks I've been experimenting different ways to get the little quad of water mesh I had into an ocean. My initial approach was to implement some sort of geometry as described in this paper, but I ran into a good number of problems. First off, after constructing the near patch, it wasn't too easy to integrate it into CS with a moving camera. I had to index the texture and wave generation coordinates in world space from the shaders, and that sometimes had bad effects. Also, the far patch gave me a number of problems, most of which was that it was almost impossible to find the correct transform to paste it in front of the camera. I'm not too sure how the conics in the paper mentioned above would have proved useful.

So, I decided on a new approach. A better approach. I got my idea from this paper, which employed the use of different ocean "cells," each with their own geometry. This way I was able to do some LOD calculation at the same time as I was generating the ocean waves. Since the wave generation is still based on world-space coordinates, it was easy to tile the cells and maintain a seamless ocean surface. Currently the only problem with this approach is that the texture coordinates are not accurately being set so there is noticeable "popping" when you move the camera up away from the ocean because you can see the different texture coordinates changing. I hope to get that fixed over the weekend.

2008-07-05

Fresnel articulation

So, after reading about tangent space and realizing that my normal maps were in it, I figured out where my lighting equations were going wrong. Consequently I was able to put all the necessary vectors into tangent space to do my lighting equations, and now we have a water that has a proper (approximated) Fresnel term and goes translucent at the correct angles, as can be seen here.

2008-07-04

Water you up to?

I've been working on adding a water mesh plugin to CS for the past month, and I haven't really been letting the community keep up with my progress. So, I'd like to tell you all what I've done so far!

First, I started to build off of the protomesh plugin that's already in CS. This gave me a great framework for having a general factory with all of the necessary information: vertex locations, color, normals, etc. The great thing about the protomesh is that it doesn't have too much clutter in the code so it was relatively simple to figure out how everything worked with SCF and implementation details. Hence, it was fairly easy to get *some* sort of mesh going, and the next step would be to add water-like attributes to it.

This is where things started getting tricky since this is my first time doing a water effect and I had to do a lot of reading regarding reflection, refraction, Fresnel values, wave generation, fluid dynamics, etc. Finally, after I settled on this paper, I started learning about the shader system in CS.

In my Graphics course here at the University of Chicago, the term "shader" was used to mean the vertex and fragment programs that are loaded for the specific rendering step. Unfortunately this created a bit of confusion when reading the documentation for shaders in CS, so it wasn't immediately obvious how everything worked. It wasn't too long, however, until I finally realized how to define shader variables, add shader programs, and generally define a mechanism for rendering a simple water mesh.

So, with the help of sueastside, I got some ideas (and normal maps) to create a preliminary water effect. Unfortunately, after reading a few different methods for looking up or approximating the Fresnel value, it isn't terribly clear what the best way to go about implementing it in CS is. I have a few ideas that involve tactics from the aforementioned paper, but I want to have a working version of everything before I start making it all better.

So, I present to you what I have so far in the form of screen shots (or you can go check out my SVN branch). These are using the same hard coded directional light with different normal maps. =)