Jump to content

Of water and waves


wraitii
 Share

Recommended Posts

Ah ok. My thought was to calculate the wave positions/directions in Atlas and insert polygons at those locations with the appropriate rotation.

Then we create a material that moves one or more textures across the polygon surface and transforms them as needed to look wave-like. Alternatively, we create the animation in Blender and it could work just as well (but is probably less efficient).

This material draws to two buffers simultaneously (look up MRT), one being a normalmap that is combined with the water normals and maybe an additional buffer for diffuse foam or such.

The extra buffers are passed into the water shader and combined with the usual water effect.

Link to comment
Share on other sites

The hardest part here is that the geometry must take into account the convexity of the map (to avoid overlapping). If you look at page 6/7 (can't recall which) you'll see I had that for some times, but it felt unsatisfactory. I could retry with your system.

Link to comment
Share on other sites

I see what you mean. We don't need to have one looong wave all across the beach, it can be a lot of small waves here and there moving independently. Also, we might use several triangles to deform the shape of the waves as needed (this would need to be made a special case, though).

Either way, it's doable!

Link to comment
Share on other sites

It's harder to do a lot of small waves properly in some cases. I'll have to give a look at some sort of wind direction.

Anyway I'll retry with the mesh thing.

Given my current timetable, this would probably push waves to after Alpha 11, though.

Edited by wraitii
Link to comment
Share on other sites

Myconid, I've implemented a way to do waves using render-to-textures. I think for waves I'll focus on using the "wind direction" and all waves will follow that (so I've got to take into account protection from wind. Should be okay.), and I'll use the alpha channel for the foam (which is all-right because it's already only one channel). So that should work. I'll just have to actually go through with it.

Link to comment
Share on other sites

Myconid, I've implemented a way to do waves using render-to-textures. I think for waves I'll focus on using the "wind direction" and all waves will follow that (so I've got to take into account protection from wind. Should be okay.), and I'll use the alpha channel for the foam (which is all-right because it's already only one channel). So that should work. I'll just have to actually go through with it.

Ok, looking forward to seeing it in action. What sort of look are you aiming for? Something like the AoE3 video that Mythos_Ruler posted perhaps?

Link to comment
Share on other sites

Myconid, I've implemented a way to do waves using render-to-textures. I think for waves I'll focus on using the "wind direction" and all waves will follow that (so I've got to take into account protection from wind. Should be okay.), and I'll use the alpha channel for the foam (which is all-right because it's already only one channel). So that should work. I'll just have to actually go through with it.

AFAIK, though wind adds the energy that indirectly creates waves, shore waves generally flows towards the shore, not in the wind direction.

Non-shore waves are another matter, though.

Link to comment
Share on other sites

Yeah, but this is a fairly big constraint. I think a good effect can be achieved by using waves that go only in one direction (that is to say, you'd get breaking waves near some part of the beaches, the rest would get regular ocean stuff). Around small islands, it looks weird to have waves "morphing around" in the obviously wrong direction. On bigger islands, I'd have to check if some system can't be made to sort of follow the slope of the island, but I fear it might be complicated to do efficiently, nicely, and easily enough.

Link to comment
Share on other sites

Okay, so I've tried using the ground directions for the wave... And the answer is no, it looks bad.

I think I'm going to stop being dumb and start being clever instead, so I'll probably resort to some sort of fancy geometry stuffs that will allow for wave discontinuity, because hey, waves can be. Should work anyway.

On the upside, this is really helping me work on my hatred for restarting from scratch.

Link to comment
Share on other sites

Some news that, for once, aren't "This failed".

So I've switched back to geometry, and to render-to-buffer, which helps nicely against depth problem and conflicts.

Here's an early WIP:

post-9128-0-53231600-1343642834_thumb.pn

It looks promising enough that I should be able to get it to work, so that's something.

Link to comment
Share on other sites

Some news that, for once, aren't "This failed".

So I've switched back to geometry, and to render-to-buffer, which helps nicely against depth problem and conflicts.

Here's an early WIP:

It looks promising enough that I should be able to get it to work, so that's something.

Ah yes, that looks like the sort of thing I had in mind. Nice work! :D

Link to comment
Share on other sites

Yeah, I hadn't thought at all of rendering the meshes to texture, but that eliminates quite a few issues. I had code leftovers from my many tries, too, so it took very little time.

I've switched working from git to svn because I figured it would be easier in the end, and here's a patch for the current SVN version (12240 I believe).

The wave effect is shown, it's not really clear in all orientations because it affects the normals, and not so much the foam (only a little). it's not really synched up or cleaned up, take that as a proof of concept and tell me how it feels.

I intend to: make it so the squares are more aligned to the shores, so you won't get waves that start way too early/feel too weird. i'll try to make waves wider too, once that is done. Have some sort of pseudo-wind strength effect affect the amount of foam/waves.

I'd need a wave texture (in the same spirit as the one I included, only way nicer. Basically, only one wave and some "blank space"), it should ultimately be animated, it'd be much nicer. Also, I'd need the same texture only in the form of a heightmap to help with the foam. If somebody could do that, it'd come in very handy.

edit: patch update below

(I'm not sure I can add files to the patch, so I've linked the two textures below. They have to be put in " binaries/data/mods/public/art/textures/terrain/types/water/ ")

post-9128-0-02537100-1343660341_thumb.pnpost-9128-0-73183900-1343660343.png

Since it's my first svn patch, it might not work, please report then :)

Link to comment
Share on other sites

First, some compilation errors:


../../../source/renderer/TerrainRenderer.cpp: In member function ‘bool TerrainRenderer::RenderFancyWater(const CShaderDefines&, ShadowMap*)’:
../../../source/renderer/TerrainRenderer.cpp:912:43: error: ‘glGenFramebuffersEXT’ was not declared in this scope
../../../source/renderer/TerrainRenderer.cpp:913:59: error: ‘glBindFramebufferEXT’ was not declared in this scope
../../../source/renderer/TerrainRenderer.cpp:925:108: error: ‘glFramebufferTexture2DEXT’ was not declared in this scope
../../../source/renderer/TerrainRenderer.cpp:1022:45: error: ‘glDeleteFramebuffersEXT’ was not declared in this scope

You need to add "p" to the front of the function names, due to how they are imported in glext_funcs.h.


../../../source/renderer/WaterManager.cpp: In constructor ‘WaterManager::WaterManager()’:
../../../source/renderer/WaterManager.cpp:73:23: warning: converting to non-pointer type ‘GLuint {aka unsigned int}’ from NULL [-Wconversion-null]

Use "0" not "NULL" (better), or use an explicit cast (should work, but kinda funky).

And then, there's this:


ERROR: CCacheLoader failed to find archived or source file for: "shaders/glsl/waves.xml"
ERROR: Failed to load shader 'glsl/waves'
Segmentation fault

You have to use "svn add" on any unversioned files you want to include in your patches.

Please use git in the future, it's much easier to test from.

Link to comment
Share on other sites

Thanks for the report. Forgot about those files, that's pretty dumb of me. The "p" stuff didn't bother my compiler so i didn't notice, neither did the "NULL" stuff, that's fixed.

Yeah, git is easier for testing but porting the commits to SVN is something I'm really uncomfortable with, so for that it'll be SVN (furthermore, I've had a few problems with git, and my fork is a huge mess right now which I can't bother fixing).

I'll try to repost a (slightly newer) a bit later.

Link to comment
Share on other sites

I'd need a wave texture (in the same spirit as the one I included, only way nicer. Basically, only one wave and some "blank space"), it should ultimately be animated, it'd be much nicer. Also, I'd need the same texture only in the form of a heightmap to help with the foam. If somebody could do that, it'd come in very handy.

Just to see if I follow you correctly... you would like an animated height & normal map of a full (single) wave cycle - from it's rise, then crest, then break?

Wikipedia has some cool info (and animated images): http://en.wikipedia....iki/Water_waves

Link to comment
Share on other sites

That would probably be too complicated and would most likely not give the best results... I'd need some sort of "cruising" wave, ie no rise, no breaking, just at its crest phase. Only to simulate some sort of movement in the water, it could have some turbulences in the front or something.

Animation is therefore mostly a plus, but even a proper normal map and heightmap for a single wave would be very handy.

Link to comment
Share on other sites

That would probably be too complicated and would most likely not give the best results... I'd need some sort of "cruising" wave, ie no rise, no breaking, just at its crest phase. Only to simulate some sort of movement in the water, it could have some turbulences in the front or something.

Animation is therefore mostly a plus, but even a proper normal map and heightmap for a single wave would be very handy.

Try this - Sorry I didn't convert them to a normal (maybe somebody else could?). CrazyBump kept crashing for some reason.

I came across this which I thought was interesting:

http://www.gamedev.net/blog/715/entry-2249487-ocean-rendering/page__st__5

http://www.outerra.com/forum/index.php?topic=544.0

Waves.zip

Link to comment
Share on other sites

Looks a lot like what we have now (in the method), actually, which is pretty nice. The difference is that he apparently uses a pretty high-scale texture of the distance to the shore for each shore pixel to have the waves crash nicely, and it seems the terrain in that simulation was more linked to the tiles when in 0 A.D.

I figured, while I can't use an actual animated texture to have breaking waves, I could use a 3D texture. Is that supported by the game?

Wijitmaker, thanks for the waves. To clarify what I needed, I needed mostly an image like your "wave_17" one. The animation could be used to introduce slight perturbations on that particular image (I don't need the wave to move in the texture, because of the system I use).

I can do the conversion to normal myself.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...