Modelling things out of water

So I’m taking a graphics course and what I would like to do for my final project is a chess game but I’d like to model the pieces out of water. Basically if any of you have played God of War 3, that’s kind of how I want it (here is a link to what I’m thinking of: http://www.youtube.com/watch?v=6sS6U7pTrvs).

When the piece gets taken I’d like the piece to explode into a shower of water possibly leaving puddles on the board (I have an idea how to do this). But I’m not exactly sure how I’d get the pieces to be modelled out of water (and if I time, fire as well).

I was thinking of simply modelling the pieces in Maya and applying a ‘water’ texture map, and to make it look like the water is flowing, I’d have like 10 texture maps I cycle through, all of which are water but in different states. I could do it more dynamically but I have no idea how. Any help is appreciated.

That made me smile. :slight_smile:

That’s actually a valid concept. The simplest way is to bind a different image every frame.



// frame i
glBindTexture(GL_TEXTURE_2D, tex_one);
// draw piece(s)

// frame i + 1
glBindTexture(GL_TEXTURE_2D, tex_two);
//draw pieces 

// a.s.o.


The obvious drawback is that your textures will “fly” or “crawl” through depending on your frame rate (or better put frame time).

The better approach is to run a timer and change the texture in a defined interval. Coarsly this will look like this in pseudo-code:



// start timer somewhere, keep old time
if(current_time >= old_time + interval)
{
   if(current_texture < textures_size)
     ++current_texture;
   else
     current_texture = 0;
   
   glBindTexture(GL_TEXTURE_2D, texture_object[current_texture]);
}

//draw pieces 
// a.s.o.


What you see in most games is a simple “scrolling” texture approach done by offsetting the texture coordinates. This can be done using one or more textures, which can be transformed at different speeds.

The fixed-function approach using the texture matrix is described here:
http://glprogramming.com/red/chapter09.html#name8

Inside a shader it’s merely manual offsetting like this:


// for a waterfall you'd want to offset in t direction only
vec4 WaterColor = texture{2D}(WaterSampler, vec2(TexCoord.s, TexCoord.t - speed * time)); 

Thanks a lot! Had no idea iterating through was actually valid. Would I hardcode the x textures or dynamically do it using just one texture? I actually have no idea how I’d draw x water textures to make it look like the water is flowing, I’m a pretty terrible artist.

Why not? Playing back a movie is essentially nothing else. Iterating over a number of still images to create the illusion of movement.

Regarding the creation of the textures I can’t help you. :slight_smile: