So I made a Gerstner Water Shader, from this video: https://www.youtube.com/watch?v=_y7Z0MbGOMw, and made some modifications to it.
The thing is, near the shore the water waves are visible and makes it look unnatural:
Another Picture:
So this is what I’ve tried in the material blueprint, but it doesn’t seem to help that much. How do I get this shoreline to look natural?
Water should have specular of 0.255. Roughness should be lot closer to zero. Metalness should be 0. You should add refraction or simulate it by yourself with scene color. Using scene color is better because you can make colored transmission, chromatic aberration and you can take account distorted pixel depth.
Opacity should be calculated from fresnell using water specular.(multiply specular with 0.08 for normalizing specular to physical based range). Opacity is also modified by distance from water surface to bottom. Simple formula for transmission is exp(-(scatteringRGB + absorption )* distance).
For base color I calculate inscattering thickness but this is not very important for start. But deeper the water more light is scattered.
So I played around with it for a while but couldn’t get the opacity and refraction to work right. Could you please send a picture of how to do it or something?
Check this out. Unreal Engine 4.13 Released! “NEW: IMPROVED REFRACTION SHADERS”
This should fix that bug. Also depth fade should be used only for small scale effect to hide triangle intersections. Try value like 10cm.
You also need depth based transmission. Longer path that ray goes underwater more light is outscattered. Beer–Lambert law - Wikipedia
Ok, so refraction works great with the Pixel Normal Offset, but the opacity thing is a little tricky. So I didn’t change the depth fade, since if I do the waves are visible on the shore. And at 250 it looks alright , not too bad but if more could be done, it’d be nice. Also, the opacity for all of the water not near a shore, or in the distance, is too low, I don’t want to be able to see through the water so far away. How do I fix that?
Opacity is inverse of transmission. So you calculate how much light can pass through and then calculate opacity = 1 - transmission. So you first calculate how much you can see under surface with fresnel. Then you calculate how much you can see bottom of sea.(exp(-thickness * distance). You multiply those and you get transmission.
Take Worldposition node and WorldPositionBehindTrancluency node. Calculate distance between those. Multiply that with -density.(use value like 0.005). Plug that to Pow node Exponent. Plug constant 2.71828182846 to Base. This is value how much you can see underwater.
Hello, everyone!
[MENTION=37019][/MENTION]: mind if i ask, how would one approach foam at the wave crests? I’ve been struggling with this for awhile, here’s how my water looks like now:
I have Gerstner’s Waves in WPO, displacement from heightmap, opacity as per your earlier advice and i use fresnel to lerp between 2 colors for Base Color. There is actually some foam i managed to get but they look ugly and unrealistic:
[MENTION=37019][/MENTION]: Oh, sorry, i forgot to mention this already uses planar reflections. Still, quality at glancing angles seems lacking to me. Like how the individual waves sort of blend with each other and barely distinguishable.
@Zarkopafilis: You’ve linked the whole book, i assume you ment Gerstenr’s Waves which i already said i use? There is nothing i can find about foam though.
the reason your waves are barely distinguishable is because you are not recomputing your normals. so while your gerstner waves are offsetting the vertices, the normals are all still pointing upwards
there’s a few threads that mention this subject but it’s not easy to implement
@: Well actually i am recomputing them. I’m not sure i do it right, but they look more-or-less correct to me. Here’s a screenshot of just Gerstner’s Waves:
[MENTION=37019][/MENTION]: do you mean what’s discussed here: Ocean shader normal issues! - Rendering - Epic Developer Community Forums! ? I’ve tried that and came to the same conclusion as in the last post, that manually calculating normals should look better. If i do that trick i get either faceted mesh (if using WorldPos with Offsets) or an almost flat surface (without offsets). Maybe you mean something different?