Sign in to follow this  
coollofty

bump waves, headache...

Recommended Posts

Who has water effect demo or tutorials that developing with bump map, I really can not find a good-looking bump map create arithmetic, such as the d3dsamples bump waves demo, its effect is too bad to directly used it in a game. I like the HL2 water effect, and I know it is do with the bump map, but I don't know how to do. Who can give me some sutff? Thanks for help.

Share this post


Link to post
Share on other sites
On thing I did was to create simple perlin noise texture - I used Texture Maker ( great program, btw ), and then mapped it onto my water.

The thing that really made it work was to scale the axis perpendicular to the flow direction up by like 8 or 10 or so. That stretches the noise texture out and makes it look like waves.

You can certainly do more than one noise layer, but just one worked for my purpose...

Share this post


Link to post
Share on other sites
I've played around recently trying to create such an animated normal map (because I liked HL2, too!)
This is the result:

Normal maps in action (AVI)
Zipped normal maps

I'm quite happy with it, but since I don't have implemented a water shader yet, I can't really test it.
If you like, you may use this normal maps. I'd love to see them in action, so if you could generate some AVI, I'd be very happy.

Lutz


Share this post


Link to post
Share on other sites
Oh, it is cool! I like this effect!
But I don't how to generate these pictures. and an other thins is: How do you use them? these pictures must used one by one. Would you make them into a volume texture? or other methods?

Share this post


Link to post
Share on other sites
You could put them into a 3D texture.
Or you just load them into different 2D textures and bind one each frame, that is
In frame 1, bind normal map texture 1
...
In frame 32, bind normal map texture 32
In frame 33, bind normal map texture 1 again
and so on.

That wouldn't be framerate independent, but by far the easiest way.
Note that 2D textures must have the wrap modes set to GL_REPEAT.

I've made a C++ program generating these normal maps. I'll put it online soon.

Share this post


Link to post
Share on other sites
Lutz, that looks great! Can you tell me how you managed to make a seamless looping animation? I can make Perlin noise animation, but I fail to make the animation loop, ie the transition from the last to the first frame to be smooth.

Share this post


Link to post
Share on other sites
Here is the source and Windows executable (300Kb). The program reads some grayscale image and generates a normal map animation out of it. The resulting images are stored in Images/. The file format is tga, but you can change it to anything corona (the imaging library) can deal with (e.g png or bmp).

So how does it work?
I basically solve the wave equation
D^2/Dt^2 H = D^2/Dx^2 H
in 2D. H is some height map. The gradient of H gives me the normal map later on.
As initial condition, I use some sort of seeding image. Instead of solving the wave equation, you can also take Perlin noise, that doesn't matter. However, since the wave equation simulates water waves, it should be better for water surface normal maps.

Every say 10 computation steps I take a snapshot of H and store it. In total, I generate say 128 images that way. You can imagine these 128 images as heightmaps of some wavy surface at 128 successive times.

Each image sequence is tiling in X and Y direction. This is because I use periodic boundary conditions for my wave equation solver. However, the images are not "tiling in time", that is, there is no smooth transition from the 128-th image to the 1-st image. Thus, I simply blend them smoothly. I basically specify some number of images I want to blend - say 10 - and then I overwrite the first 9 images like this:

New #1 = 0.1*(old #1) + 0.9*(old #(128-10+ 1))
New #2 = 0.2*(old #2) + 0.8*(old #(128-10+ 2))
New #3 = 0.3*(old #3) + 0.7*(old #(128-10+ 3))
New #4 = 0.4*(old #4) + 0.6*(old #(128-10+ 4))
New #5 = 0.5*(old #5) + 0.5*(old #(128-10+ 5))
New #6 = 0.6*(old #6) + 0.4*(old #(128-10+ 6))
New #7 = 0.7*(old #7) + 0.3*(old #(128-10+ 7))
New #8 = 0.8*(old #8) + 0.2*(old #(128-10+ 8))
New #9 = 0.9*(old #9) + 0.1*(old #(128-10+ 9))

And then I throw away the last 10 images. The rest (118 images) are "tiling in time" now.
Makes sense? I hope so...

Anyway, I'd really like to see the normal maps in action...

Lutz

Share this post


Link to post
Share on other sites
Quote:
Original post by mikeman
Very good man. I'm doing some work in Raduprv's Eternal Lands and that's exactly what I was looking for water animation. Do you mind if I alter the source to do other effects(smoke,fog...)?


Not at all.
But please show me what kind of effects you created with it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this