Jump to content

Water Rendering


Recommended Posts

I've been working on water rendering and mostly figured out how it works. It isn't yet screenshot worthy (and screenshots are terrible for conveying water effects) but I have made some definite progress already.

 

Thus far:

-I reduced the refraction displacement by half, which looks a lot better

-I reduced the reflection distortions by more than half, which also looks a lot better (although it still needs some tuning for distance effects)

 

--Currently I'm working on tuning the intensity of reflections and the fresnel factor used for intensity scaling.

 

To Do:

-Shore waves need more foam, and should produce foam trails when receding as well as when advancing.

Also: shore waves seem to be recalculating the shoreline every frame, which may be contributing to the expensiveness. The shoreline really should only need recalculating if the terrain is modified or if you change maps entirely (ie in atlas), and should additionally be cheap to cache. It seems like someone was aware of that at one time but it just never got done.

  • Like 4
Link to comment
Share on other sites

I found a weird bug with ocean waves. If you set the wind direction north (or move the slider to the left in atlas) at some point it starts producing weird black patches where the waves should be. Moving the wind slider to the right gets rid of the artifacts, and they don't seem to appear if you rotate the camera around the waves, only when changing wind angle.

  • Like 1
Link to comment
Share on other sites

1 hour ago, aeonios said:

I found a weird bug with ocean waves. If you set the wind direction north (or move the slider to the left in atlas) at some point it starts producing weird black patches where the waves should be. Moving the wind slider to the right gets rid of the artifacts, and they don't seem to appear if you rotate the camera around the waves, only when changing wind angle.

I confirm this bug.

  • Like 1
Link to comment
Share on other sites

6 hours ago, niektb said:

When it's ready I want to cross-compare it with this one :D

 

@render glitches: Yes, happened here too more than often. I also have some red water at certain camera angles.

Another thing I found out was that the refraction map is super low res, which apparently was an aesthetic decision. :huh:

 

Can also confirm the red water artifacts. There was a horrible hack in the shader to try to prevent it but that didn't work. It mostly seems to occur around map edges when facing the center of the map, but I have no idea where it's getting the red from. Ultimately it's an issue with how the refraction map is rendered, with the relevant part being in renderer.cpp. I'm not really sure where the black waves issue is coming from since I haven't tracked down exactly where the normal map is applied (which is the likely culprit). The fact that it depends on wind direction is the biggest clue in any case, and I'm pretty sure it's not shader side (although I need to recheck that).

 

EDIT: Ok it's definitely in the shader. It seems to be related to some issue with CosSin, which might explain why it fails over half of angles, but I don't understand why it only happens with ocean waves.

Edited by aeonios
Link to comment
Share on other sites

13 hours ago, aeonios said:

EDIT: Ok it's definitely in the shader. It seems to be related to some issue with CosSin, which might explain why it fails over half of angles, but I don't understand why it only happens with ocean waves.

Could it be relate to the pathfinding map? For example, water is red in Atlas if I choose a pathfinder overlay.

Link to comment
Share on other sites

I don't think the red water issue is related to any special overlays since it appears even when they're disabled. I think the red/black water issues should be moved to bugs, which I'll do shortly.

 

I got everything cleaned up fairly well and made a PR. I also got specular reflections cleaned up and working. (I don't know if they were but they are now!)

screenshot0004.thumb.png.64392a2d1a0d92a

Also notice the foam caps in the screen shot. Code for drawing them has been around for a while but it was set to only show them from certain narrow camera angles. Now foam caps are visible from all directions (as they should be).

Edited by aeonios
  • Like 8
Link to comment
Share on other sites

The patch is here. The refraction texture is higher resolution in the new shader (requires a C++ recompile) and reflections are toned down quite a bit. Specular reflections might be tunable further, but I'd need to find some good reference photos to see what I need to aim for.

 

EDIT: I dunno about black and red fish. I've seen fish get discolored in weird ways, but usually by the water's colors.

Edited by aeonios
Link to comment
Share on other sites

On 2/8/2016 at 3:22 PM, aeonios said:

EDIT: I dunno about black and red fish. I've seen fish get discolored in weird ways, but usually by the water's colors.

 

Yes it seem like fish are renered as a transp[arency? I can see the coral through the fish models for some reason, but not through the water (because of depth rendering).

Link to comment
Share on other sites

46 minutes ago, aeonios said:

Is that an alternative to making a diff file or just extra? :P

Depends :P If you really hate making diffs we can content ourselves with the link, but in both cases it's nice to know where your work is!

  • Like 1
Link to comment
Share on other sites

17 minutes ago, Itms said:

gameboy, please stop harassing people, that doesn't make things easier to program...

Plus that makes us all uncomfortable when you target newcomers who already do their best and who don't know you yet. :( 

I say before, his acts needs a punishment 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...