Question about making water

Started by
18 comments, last by adam17 20 years, 4 months ago
i have one more question reguarding all of this. i have not been able to figure out a *good* way to make the waves animated. any ideas? sine waves?
Advertisement
I found this quite useful in a water effect I found a while ago..

Its really fast because it doesnt use trigonometric functions.
Also the ripples will reflect on the edges too...

The only downside is that the ripples seem to be slightly diamond shaped.

This can be fixed by altering the weighting on the neighbouring verticies ( 1/distance for each point works best)

http://freespace.virgin.net/hugo.elias/graphics/x_water.htm
If you want realism, use a 2D wave eq.
The world isn't unpredictable. It's CHAOTIC.
two questions for you Intamin:
1. i have read articles on creating cube maps. i cant figure how to store them. you wouldnt know how to store them with ipicture or DevIL would you? ipicture doesnt work to well (at least from my experience) for making cubemaps because it uses GL_TEXTURE_2D. anyway none of the articles really explain how to call the cube maps or how to use them. how do you get the components for glTexCoord3f()?
2. what would be a 2D wave equation? sin waves in both the x any z planes?

[edited by - adam17 on October 15, 2003 1:30:39 AM]
You can render the cube map each frame without using an image library. If you do a search for "dynamic cubemaps", I'm sure you'll find whatever you're looking for.

It's basically just rendering your scene to a texture 6 times for each cubemap (use a 90 degree perspective and rotate for each face of the "cube").

Nehe has a tut about rendering to a texture that should help you out. I think I have some code that does it, that I could post... if you still can't figure it out.

[edit] I'm feeling especially nice tonight

Set up for rendering:
glPushMatrix();    //Set viewport (doesn't have to be 256 x 256)    glViewport(0, 0, 256, 256);    glMatrixMode(GL_PROJECTION);    glLoadIdentity();    //Set the perspective to 90 degrees    gluPerspective (90, 1.0f, .01, 100);	glMatrixMode(GL_MODELVIEW); 


Now, to store each "face" of the cubemap:
//do your rendering code for each face here glEnable(GL_TEXTURE_CUBE_MAP_ARB);//Bind the cube map.glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, CubeMap);glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, 0, 0, 0, 0, 256, 256);glFlush();//Disable cube mapping.glDisable(GL_TEXTURE_CUBE_MAP_ARB);


Where it says GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, you need to change that for each face (so that you update the entire texture each frame and not just 1 side) to its coresponding angle.

GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB

Now all you need to do is reset your viewport and perspective to whatever it was before.

That should help some. You have to initialize the cubemap before you can start rendering to it, but I'll let you figure that one out.




[edited by - Halibut on October 15, 2003 4:47:55 AM]
thanks alot Halibut. i have one quick favor to ask. can you give me the address(ex: 0x4f37) for GL_TEXTURE_CUBE_MAP_ARB. my card is a gf4ti4600 so i know it supports it.
Copy and pasted straight from my code:
#define	GL_NORMAL_MAP_ARB				0x8511#define	GL_REFLECTION_MAP_ARB			        0x8512#define	GL_TEXTURE_CUBE_MAP_ARB			        0x8513#define	GL_TEXTURE_BINDING_CUBE_MAP_ARB			0x8514#define	GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB		0x8515#define	GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB		0x8516#define	GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB		0x8517#define	GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB		0x8518#define	GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB		0x8519#define	GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB		0x851A 


Hope that helps.
quote:Original post by Halibut

That should help some. You have to initialize the cubemap before you can start rendering to it, but I''ll let you figure that one out.


quote]

Could you tell me how to init it ? Im realy enw Coding Wise and want to kniow a bit moe on this cube mapping

Hey guys. This is not meant as a troll or an attack or anything, just a clarification.

Ray tracing is not "inefficient". It produces mathematically correct images, and can be quite fast if implemented properly.

That being said, it still isn''t appropriate for realtime rendering of anything useful...yet. :-)
You should read this:
http://www.andyc.org/lecture/viewlog.php?log=Realistic%20Water%20Rendering,%20by%20Yann%20L

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement