I wanna make water and waves for my little 2D PC game like in this video: http://www.youtube.com/watch?v=ooU6cTeirlQ I don't know how to write a similar shader. Does anybody know how to write a similar shader? Or is it possible to do the waves without shaders?
-
3\$\begingroup\$ People, please don't downvote without explanation, it's against the rules of the site (and rude). \$\endgroup\$– HouseCommented Oct 23, 2012 at 21:08
-
1\$\begingroup\$ It doesn't look too complicated. Looks like the waves are made with some kind of spline and the dolphin passing by the spline makes it bend. Though I'd have no idea how to make it look nice like that. Perhaps a blurring technique like this one: patrickmatte.com/stuff/physicsLiquid. There may be more hints here or someone might have a better answer for you. \$\endgroup\$– HouseCommented Oct 23, 2012 at 21:13
-
1\$\begingroup\$ To me this seems like a 3d mesh. kind a box to be specific. The top-front vertices seem to follow some sort of math function (a sin or cos function with some pizzazz if you will), the top of the box then has just some generic "wave" texture, and the front has a texture that uses the tops "wave" texture and a clear blue quickly faded together. If you look carefully you see that the front's "wave" portion of the texture never moves, the UV's on the top-front corner just go up and down with the wave. The dolphin has some sort of effect on the top as well (but I have no idea how to compute it.) \$\endgroup\$– Benjamin Danger JohnsonCommented Oct 23, 2012 at 22:07
-
\$\begingroup\$ a quick correction, the UV's on the vertices don't actually change, that is why the texture is being "mushed" (for lack of a better word) as the wave rises and falls. The bottom texture never seems to move so I believe there are also vertices defined at the fade line (since the fade line's position does not change the texture part between the bottom and fade line UV's wont deform, but the texture part above will.) \$\endgroup\$– Benjamin Danger JohnsonCommented Oct 23, 2012 at 22:12
-
1\$\begingroup\$ Not sure, but for me it looks like a array of springs drawn as quads, but with the default state of each spring modified by some kind of senoidal function. Here's an explanation of how to make water with a spring model: gamedev.tutsplus.com/tutorials/implementation/… \$\endgroup\$– Gustavo MacielCommented Oct 24, 2012 at 0:54
1 Answer
It's hard to tell how this is made exactly (except by the developer), but let me summarize what has already been said in comments, with some additions:
This is a 3D mesh seen from the edge, probably a simple grid
Each vertex of the grid is following spring physics affected by:
- A sine wave
- The dolphin diving in and out
- Their depth
Backface culling is disabled, and different textures/shading are used on both faces (tips)
The textures might be animated (animated UVs?), but this isn't really visible
There's some kind of alpha blending involved on the last row(s) of vertices
Additionally, to perfect the illusion, you have some animated sprites for the dolphin splashes, and a trail that seems to be a textured quad strip.