Jump to content

Of water and waves


wraitii
 Share

Recommended Posts

That thing is password protected. Can you copy it somewhere?

Ah, I forgot - sorry. Here it is and in a zip instead. Unfortunately it is just an .exe no source code - so I'm not sure how much help it will be (and it looks pretty poor on this computer - maybe a driver issue). Florian Brede (aka Daywalker) was the programmer. It looks like he could be contacted here.

WaterTest.zip

Link to comment
Share on other sites

Well, my understanding of the "murkiness" factor was that it did not represent actual murkiness, but rather was an abstraction of how clear a water was. The "tint" being the color of the water (so if you'd want a muddy water, you'd set murkiness high and the tint would be brown).

Color extinction is simulated in that the refraction color gets more tinted (sunColor*tint) as the depth increases, with murkiness as the parameter (see my first sentence). I could mingle with the parameters to make it happen earlier, but I'm not sure it's necessary, I think this decision should be up to the team's artists anyway.

Edited by wraitii
Link to comment
Share on other sites

Well, my understanding of the "murkiness" factor was that it did not represent actual murkiness, but rather was an abstraction of how clear a water was. The "tint" being the color of the water (so if you'd want a muddy water, you'd set murkiness high and the tint would be brown).

Fair enough. Will oceans on existing maps be blue? Or will they need a murkiness tweak?

Link to comment
Share on other sites

I dunno. I fear all maps would have to be reworked: since waviness has been completely changed, all oasis maps for example look quite wrong. The different murkiness means that tint also looks differently on some map, it may be darker/lighter than expected.

I'll try to make sure that all settings give out about the same expected result for water tint, and more generally murkiness (I might put the depth buffer trick even in the regular fancy shader, it's not that expensive and it looks so right). But I think most maps would have to be redone. Again, I'd ask some of the game mapmakers/artists.

base specular strength may also need to go from 0.4 to something like 0.6/0.7.

Edited by wraitii
Link to comment
Share on other sites

Here is an idea for waves and whitecaps ('whitecaps' probably being a better term than 'foam' for what we are trying to achieve):

Looking at the (gorgeous I might add) screenshots of the tower, it looks like you guys are using dynamic distorting (for both refraction and reflection)? In that case I would say a wave texture isn't needed. Likewise, if possible you guys could scale the distorting near the shore (using the depth texture), you would get bigger waves near the shore (somewhat realistic, especially with bigger waves like tsunamis). Lastly, if the amount of distortion exceeds a threshold (per pixel), the pixel can be tinted white to simulate whitecaps.

Link to comment
Share on other sites

Indeed. I didn't bother researching the right word (we say "sheep" in French). The problem with that is that the top of waves (where whitecaps usually are) are the less distorted. I could easily do that if I knew where the top of waves are, but the texture has no heightmap in its current form.

Link to comment
Share on other sites

Okay, so I've added a few other things to clean the result up. Changed the way refraction works a bit: as depth increases, the water will get more tinted. That way, on the surface, the sunColor will have a great influence, but as depth increase it will start losing it.

I've changed the murkiness for the fancy shader to approximate what the super fancy shader does using the water depth (vertically and not from the depth buffer, which is a huge approximation and disregards objects in the water) and the angle of view.

In effect, this makes the fancy and the super fancy shader look quite the same, which I believe is good. The basic shader is unchanged, I'd like to make it completely opaque when too deep, but I'm not too sure how to do that.

Committed here. Note that I have a bug on some maps with the "distance to shore", such as Nile River where for some reason the texture is too small. Also note that for now, the game will compile the texture once, and never redo it, so if you choose a new map, expect it not to work correctly.

I've added a checkbox in the options to activate/deactivate the super fancy water, so it's easier to compare.

In this screenshot, fishes are barely visible, and the bottom of the tower is visible but not the top (artifact from using a wrong depth). Also, while the sun has a small influence, it's not very visible.

post-9128-0-86159000-1342258112_thumb.jp (click to enlarge)

On the super fancy shader, the tower is right, you can see the fishes, and the sun color seems to have more influence. And of course, the foam (here on a medium waviness setting).

post-9128-0-30601100-1342258115_thumb.jp (click to enlarge)

Link to comment
Share on other sites

Ah, I forgot - sorry. Here it is and in a zip instead. Unfortunately it is just an .exe no source code - so I'm not sure how much help it will be (and it looks pretty poor on this computer - maybe a driver issue). Florian Brede (aka Daywalker) was the programmer. It looks like he could be contacted here.

Hi,

I have a video of the "Wave Test" I created about 9 years ago at the age of 16 or 17 ;).

No fancy shader stuff by then, each wave is a quad stretched and faded smoothly and not even texture animation involved.

Position and direction are simply calculated by selecting the terrain quads which intersect the water plane and determining their slope and averaging their normals projected to the water plane.

I definitely have the source somewhere, but that's still from a time where I made backups to hundreds of CDs without printing labels on them with my quad-speed cd writer :yes3:.

If I happen to find the source, I'll post it here.

Anyway, here is a video of the demo.

Skip to 00:25 to see the wave quads without rendering the water:

https://docs.google.com/file/d/0B1TfEz4GUYOmSUp4b3JtR1ZPMjQ/edit#

Greetings,

Florian

Link to comment
Share on other sites

Indeed. I didn't bother researching the right word (we say "sheep" in French).

Eh, don't worry about it. You've got better things to do than research that. Foam isn't wrong at all. (in fact, I'd also say the white that is left over after the wave breaks is more correctly called foam that whitecaps).

The problem with that is that the top of waves (where whitecaps usually are) are the less distorted. I could easily do that if I knew where the top of waves are, but the texture has no heightmap in its current form.

I picked the most distorted on the crude analogy that distortion was proportional to wave height (which is probably more true for breaking waves than normal ones, if ever true at all.) Anyways though, in this case i think realism is less important than finding a metric that somehow makes the whitecaps in look related to the distortion effect (which I believe is realistic), even if that relation is bogus.

Link to comment
Share on other sites

Everything's about that in shaders anyway.

@DayWalker: thanks for stopping by (what a dedication!). I think for shore waves I'll follow a fairly similar approach, as it's the most practical/easy to do.

I've also considered splitting the water meshes in two: one for every "non-coastal" area, and one for every coastal area, but that would probably introduce many other problems... So for waves, I'll probably create quads with a wave shader, and those would slightly move in height over the land. I'l see about that, but it should be all-right.

Edited by wraitii
Link to comment
Share on other sites

Hi,

I have a video of the "Wave Test" I created about 9 years ago at the age of 16 or 17 ;).

No fancy shader stuff by then, each wave is a quad stretched and faded smoothly and not even texture animation involved.

Position and direction are simply calculated by selecting the terrain quads which intersect the water plane and determining their slope and averaging their normals projected to the water plane.

I definitely have the source somewhere, but that's still from a time where I made backups to hundreds of CDs without printing labels on them with my quad-speed cd writer :yes3:.

If I happen to find the source, I'll post it here.

Anyway, here is a video of the demo.

Skip to 00:25 to see the wave quads without rendering the water:

https://docs.google....JtR1ZPMjQ/edit#

Greetings,

Florian

Thanks for the update. That looks pretty decent, and it could probably be done cheaply with vertex shaders today.

Link to comment
Share on other sites

Okay, I've committed a quick fix that solves a problem around objects above the water (I dunno if it was there from the start, but it definitely is out now), reintroduced the wave scaling effect, which I had lost at some point. Also fixes the shore blending issue, it now looks smooth, and it still fixes the "see far underwater" problem when you looked at the right angle at a slope.

Could somebody report on performance?

I still have to fix the issue on some scenario maps where the texture is created completely wrong and it results in bugs (such as Saharan Water Holes).

Edit: that seems to be a power of two issue.

Edited by wraitii
Link to comment
Share on other sites

Myconid's improvement with normal's blending is what really cuts it when animated, it looks so smooth and watery like. The rest is just eye-candy (though I'm fairly happy with the foam.)

I'm fiddling with the refraction/reflection settings again. I think I'll aim for more realism, so water will always be fairly dark when it's deep, even if the water tint is light (murkiness being the limiting factor once more). I'll have water tint color the objects below, and I'll probably lower the amount of sky reflection, it's too high right now (case here, there or even here).

Edited by wraitii
Link to comment
Share on other sites

Finished fiddling... This should be customizable and good-looking enough. Under this system, the water refraction is modified by depth and murkiness. The deeper/murkier, the more tinted toward "Water Colour", and the more the objects underwater are tinted toward "Water Tint" (! both colours can be very different).

Usually, the ground will begin being tinted by Water Tint, and then Water Colour will take over at higher depths. By adjusting murkiness, the depth where the water is completely "Water Colour"-ed can be changed, so you can simulate very muddy water or very clear waters. Furthermore, sky reflection is less visible (at higher angles. In the distance, it's still basically the same).

Had a little fun with the scenario editor... Here's the real thing, and here's the fake:

post-9128-0-06632500-1342359539_thumb.jp

(Still have to change the normal fancy water shader to sort of emulate this, though).

@Zoot: should be able to.

Edit: Sigh, now I want to make a "Polynesia" random map.

Edited by wraitii
  • Like 1
Link to comment
Share on other sites

Had a little fun with the scenario editor... Here's the real thing, and here's the fake:

post-9128-0-06632500-1342359539_thumb.jp

Nice :wink2: From a purely artistic point of view, I would probably leave a bit of the sky reflections on just to capture the atmosphere of 'being at the ocean' (because a military commander in ancient times would not hover around in a helicopter above the ground ^_^).

Edited by zoot
Link to comment
Share on other sites

On 'Tropical Island' with your latest commit, I get about 5 FPS with fancy water on and 8 FPS with fancy water off. The performance impact of superfancy water is less than 1 FPS.

On 'Mediterranean Coves', enabling superfancy water sometimes causes the game to segfault or hang with this message in the console:

*** glibc detected *** ./pyrogenesis: malloc(): memory corruption: 0x000000000e60f530 ***

post-14658-0-16538200-1342366090_thumb.p

post-14658-0-47883800-1342366118_thumb.p

Edited by zoot
Link to comment
Share on other sites

I'll have to look into that, I get segfaults but only in Atlas and it seems unrelated to what I'm doing.

I've updated on my local repo the fancy shader, but I don't think I've committed that yet.

I'm moving on to waves, and per Mythos' advice, will have to give a thorough look at the decal code.

BTW, since this is really a complete modification of how refraction worked in the water, I believe every map would need an update. The good thing is that Water Color is now not only used for the fixed function water, so there is a lesser chance of map makers forgetting to change it from the normal blue.

Edited by wraitii
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...