Single layer water foam

Before the single layer water shading model,I always use translucent blend mode to make forward shading water,so it can use depthfade node and screencolor node to make foam effect.But now the single layer water ask to use opaque blend mode.How can I make foam without these nodes only can be used in translucent blend mode?

Heh, that’s so funny. I just came here to post exactly the same question.

I just watched this great video:

And I am very curious about this as well. I tried to play with the Single Layer Water model, and it’s looking great, but likewise, I also fail to figure out how to make foam around shoreline without depth fade :slight_smile:

Hi, you could use a virtual texture were you write the height of the landscape to (or you could even create a static texture from it, depending on the resolution you need vs performance cost). Then the water material could sample the height and you could use the distance from the water height to the landscape height instead of depth fade.

Decals / SDF.

distance to nearest surface and/or gradient distance fields?

Well, it’s not about what you guys think was used (both approaches come with drawbacks. SDF would need to be enabled on projects that otherwise don’t use them, and decals would have to be placed manually). I am curious what actually was used in that video. I have a few ideas of my own on how to do it, but the issue is that none of them are nearly as simple and intuitive as using depth fade shader. So I wanna know what they actually used on Fortnite, so that I can rest in peace knowing if there’s some better solution (than these obvious workarounds) or not.

SDF does not mean that you have to use global distance field. Generate 2d one just for this purpose, either offline or on the fly.

Same as above, nothing says that they need to be placed manually.

You can use depth fade with single layer water shading for foam.


Using depth fade with that Shading Model throws following:
[SM5] Only transparent or postprocess materials can read from scene depth.

Making shading mode trasparent with Single Layer Water Model throws following:
[SM5] SingleLayerWater materials must be opaque.

Yes,2d SDF will be a solution. But how to depth fade with single layer water shading?:eek:

Edit: He mentions later that they have a “water depth texture

He also notes that they’re rendering a “combined water texture atlas that includes all of the water information for a single terrain, this includes water velocity, water height, and terrain height. This unified texture is very useful to have for water simulation and material purposes

Is there a way to make Deffered Decals work with this shader?

Won’t be able to do that from material editor alone, as it needs a bit of wild magic with the shader.

Well, that’s not really useful solution then. Especially given how unspecific you are. I guess I will just bite the bullet and deal with the performance implications of translucent shader when I actually need a foam, and keep SingleLayerWater for the cases where I don’t.