PDA

View Full Version : Animating 2D water tiles



udawos
12-01-2016, 04:23 PM
I'm animating water tiles in Java. My code takes a 32x32 tile and makes it move across the screen. It relies heavily on the REPEAT function.

I'd show an example but the 'insert image' button seems to think every png, gif or jpg I give it is an invalid image file. Every file from the internet is also somehow too large...:confused:

What can I do with tiles other than making them repeat endlessly?
How can I blend two textures?
What is some good reference material to read that will tell me more about using OpenGL to animate water tiles?
Does anyone have any source code examples that might show me more ways I can animate water tiles?

I look forward to someone helping me get started in OpenGL! I am an OpenGL baby :o

GClements
12-01-2016, 06:16 PM
I'd show an example but the 'insert image' button seems to think every png, gif or jpg I give it is an invalid image file. Every file from the internet is also somehow too large

You may be running into limitations which are imposed upon new accounts in order to mitigate spam. But aside from that, the "insert image" feature hasn't been particularly reliable lately, and the image size limits are rather small IMO.



What can I do with tiles other than making them repeat endlessly?

Use multiple tiles with different grid resolutions and orientations.



How can I blend two textures?

- Multiple passes with blending (glEnable(GL_BLEND), glBlendFunc(), etc).
- Multitexturing (glTexEnv() with a mode of GL_COMBINE)
- Blend multiple textures in the fragment shader.

I wouldn't recommend the second option. Compared to the third, it's less flexible, harder to use, and information is harder to come by.



What is some good reference material to read that will tell me more about using OpenGL to animate water tiles?

This paper (http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.161.9102&rep=rep1&type=pdf) and these slides (http://evasion.imag.fr/~Fabrice.Neyret/images/fluids-nuages/waves/Jonathan/articlesCG/waterslides2001.pdf) describe using the inverse FFT to efficiently sum around a million sinusoidal waves of varying frequencies and phases to generate plausible ocean waves. Another set of slides covering the same technique can be found here (http://www-evasion.imag.fr/~Fabrice.Neyret/images/fluids-nuages/waves/Jonathan/articlesCG/NV_OceanCS_Slides.pdf). However, this is a relatively advanced technique.

udawos
12-01-2016, 09:20 PM
This is, hands down, the most useful reply I have ever received from anyone on the internet, for anything. This paper is excellent- it never would have occurred to me to even search for something like this.