I'd like to know how to do two things with materials related to the Ocean Modifier:

1) Change the color depending on the depth of the water, and

2) Create some believable foam.

Both of these features should change as the ocean modifier plays back.

The attached image shows what I mean pretty well, methinks—you can see how the water changes to a darker blue where the water is a bit deeper, a lighter blue where it's shallower, and blends to a white where the foam should be. I also believe that this image was made with Blender's ocean modifier [EDIT apparently it's not, but the point still remains]. I'd like this to be possible regardless of lighting conditions.

Does anybody know how to create these effects with materials that use the ocean modifier?

enter image description here

  • $\begingroup$ You could go to this tutorial and follow the material setup, adding the desired colors for the "foam" youtube.com/watch?v=6G1W3iRitjA, or you could use a texture $\endgroup$
    – cgperfect
    May 4, 2018 at 22:02
  • 1
    $\begingroup$ The image is not from Blender, it is a Houdini simulation by the looks of it. A bit more searching led me to the Houdini Ocean Toolkit for Cinema 4D v0.3. The image is an Ocean Test 01 by Helge Kiehl $\endgroup$ May 16, 2018 at 19:24
  • 1
    $\begingroup$ The part with " how the water changes to a darker blue where the water is a bit deeper, a lighter blue where it's shallower" depends on material and lighting, Ocean modifier has nothing to do with that. Volumetric material and proper lighting should give that effect. $\endgroup$
    – Mr Zak
    May 16, 2018 at 19:45
  • $\begingroup$ I meant all this to be done with a material anyway—the article is clarified to make that clearer. $\endgroup$
    – Legoman
    May 17, 2018 at 18:56

1 Answer 1




I've exaggerated a bit difference between deep and shallow water to present it better.

Node setup and overview.


Most important thing here is to separate generated texture coordinates on Z axis and assigned to it Color Ramp with our colors of choice representing deep and shallow water. You can add here more colors, not only two of them and/or change interpolation between color stops - I've used default (Linear).


First of all you will need to choose Foam Data Layer Name. I used... 'foam' and use it in Attribute node. I've also added a Math node with Power to fine tune mix between water and foam shader.


You can now mix shaders by 'foam' factor and use any other shader for materials. I've used simple Glossy for water and Diffuse for foam.

Nodes and Ocean setup.


  • 2
    $\begingroup$ thanks for this, was wondering how to do this the last little while to get nice ocean/waves without having to do a fluid sim $\endgroup$
    – Derek Eden
    Apr 18, 2020 at 6:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .