Announcement

Collapse
No announcement yet.

Tidal Water Foam

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Tidal Water Foam

    I have a pretty nice shader going for a large lake in my scene, but I can't figure out how to have foam appear at the edges. This is killing the look. Is there a certain material node that can put textures on the edge of my material? Thanks!

    #2
    Hey Allen,

    There are a few ways of creating this effect depending on how the lake is set up.

    The simplest approach would be to paint on a foam texture, the Vehicle Game example project uses this for it's lake and Tim Hobson responded on this thread explaining how it was done.

    Is your material translucent? If so I can provide an example of how I went about this in my material as well, but it will not work with an Opaque material.
    Last edited by DotCam; 11-05-2014, 11:48 AM.
    Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap

    Comment


      #3
      Originally posted by DotCam View Post
      Hey Allen,

      There are a few ways of creating this effect depending on how the lake is set up.

      The simplest approach would be to paint on a foam texture, the Vehicle Game example project uses this for it's lake and Tim Hobson responded on this thread explaining how it was done.

      Is your material translucent? If so I can provide an example of how I went about this in my material as well, but it will not work with an Opaque material.
      Thanks for the reply. Yes, it is reflective. Painting is fine, but is there another way to have foam on the edges via material node? If not, totally fine, just wondering. Also, my transparent material is not reflecting well at all. Any idea how to do both? Thanks again!

      Comment


        #4
        Originally posted by AllenGingrich View Post
        Thanks for the reply. Yes, it is reflective. Painting is fine, but is there another way to have foam on the edges via material node? If not, totally fine, just wondering. Also, my transparent material is not reflecting well at all. Any idea how to do both? Thanks again!
        There is no single node to do this, however an automatic approach to adding foam around the edge of the (translucent only! will not work with opaque) water surface is by using a DepthFade node like this (see image 1). This outputs the results shown in image 2.

        To make this work with your own material, you want to replace the Red color lerp input (in the first image) with your foam texture. The second lerp & DepthFade is not necessary, but allows you to use a second foam texture to help blend even further (replace the Green color lerp input). Your original water material nodes would be plugged in to the first lerp where the blue color is connected.

        Using this technique I get the results shown in the final image (which it won't let me post, giving me a database error... will upload it when I can). The reflection issue you mention is the real problem with using a translucent water shader at the moment, but is something Epic has said will be addressed in future updates by implementing Forward Rendering + Planar Reflections for translucent surfaces. Increasing the specular (to 1) and the metallic (to like 0.35) with a SkyLight present in the level will give you some basic sky color reflections, but to go further you would want to use a ReflectionVector node with a cubemap (either created live with a SceneCaptureCube, or texture) but it depends on your level setup. Also make sure you use TLM_Surface in the translucency settings of the material.

        You can download the project linked below in my signature if you want to play around with this as well, I left in the reflection vector node mentioned above for reference.
        Attached Files
        Last edited by DotCam; 11-05-2014, 03:40 PM.
        Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap

        Comment


          #5
          Excellent idea dot.
          VFX Artist
          Portfolio: Here

          Comment


            #6
            Nice idea DotCam, almost solved one of my problems also! I need to check how is working!

            Comment


              #7
              One thing to bear in mind is that using this Depth based technique, you don't get any foam unless the pixels of the intersecting object shares the same screen space as the water object. You can see the problem that occurs looking at the image below.

              Click image for larger version

Name:	ShoreBlend2.jpg
Views:	1
Size:	145.4 KB
ID:	1060677

              This also means that as you get closer to a top-down perspective, your foam will start to disappear. There is a way around that though. If you're water doesn't move very much and you don't want the effect to be dynamic, you can export your scene as an .OBJ into a modelling program (though I use Houdini for this process), and create an intersection mask. You can then apply this grayscale mask texture to the entire ocean object, and the foam will always appear no matter what your viewing angle.

              Comment


                #8
                Originally posted by TheJamsh View Post
                One thing to bear in mind is that using this Depth based technique, you don't get any foam unless the pixels of the intersecting object shares the same screen space as the water object. You can see the problem that occurs looking at the image below.

                This also means that as you get closer to a top-down perspective, your foam will start to disappear. There is a way around that though. If you're water doesn't move very much and you don't want the effect to be dynamic, you can export your scene as an .OBJ into a modelling program (though I use Houdini for this process), and create an intersection mask. You can then apply this grayscale mask texture to the entire ocean object, and the foam will always appear no matter what your viewing angle.
                Yeah this is the big problem with this approach, I'm testing out some ideas for a better method at the moment as my water moves quite a bit, so far without any luck. It looks just fine for a shore foam (especially from a distance) however objects placed in the water get the hard edges as you pointed out, breaking the illusion.

                Do you have any ideas for an ocean with more movement? I would like to stay away from vertex paint if possible, an automated approach would be ideal if it can be done. Thanks James!

                BTW: Allen, I finally got this image to upload, this is what it looks like:
                Click image for larger version

Name:	ocean1.PNG
Views:	1
Size:	733.3 KB
ID:	1060688
                Attached Files
                Last edited by DotCam; 11-06-2014, 11:14 AM.
                Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap

                Comment


                  #9
                  Originally posted by TheJamsh View Post
                  This also means that as you get closer to a top-down perspective, your foam will start to disappear. There is a way around that though. If you're water doesn't move very much and you don't want the effect to be dynamic, you can export your scene as an .OBJ into a modelling program (though I use Houdini for this process), and create an intersection mask. You can then apply this grayscale mask texture to the entire ocean object, and the foam will always appear no matter what your viewing angle.
                  there's an easier way to fix the problem of top-down perspective: you modify the 'spreading' values of your foam based on the camera vector looking down. I came up with this fix a while ago and works wonders for the case of camera going top-down.
                  for the foam disappearing 'behind' the rock instead of going around it, I'm afraid there's no better way at the moment. eventually I'd like to research capturing the sea from a top-down view and blurring the contact outlines, but it might be expensive to do as well
                  Follow me on Twitter!
                  Developer of Elium - Prison Escape

                  Comment


                    #10
                    hi there - this texture looks great, i would love to use it for a personal project - is it available per chance?

                    Originally posted by DotCam View Post
                    Yeah this is the big problem with this approach, I'm testing out some ideas for a better method at the moment as my water moves quite a bit, so far without any luck. It looks just fine for a shore foam (especially from a distance) however objects placed in the water get the hard edges as you pointed out, breaking the illusion.

                    Do you have any ideas for an ocean with more movement? I would like to stay away from vertex paint if possible, an automated approach would be ideal if it can be done. Thanks James!

                    BTW: Allen, I finally got this image to upload, this is what it looks like:
                    [ATTACH=CONFIG]16396[/ATTACH]

                    Comment


                      #11
                      Originally posted by eoghank View Post
                      hi there - this texture looks great, i would love to use it for a personal project - is it available per chance?
                      I believe this is from DOTCam's community project: WIP Weather & Ocean Water Shader

                      Comment


                        #12
                        Y'know, this is pretty much the perfect use case for the new distance field sampling node.

                        When the distance field reports the ocean is within a few meters of the environment, start blending in the foam.

                        Comment


                          #13
                          Yup, I was thinking the same thing zalo, it'd be great for clouds going through mountains and tall buildings as well.

                          Comment


                            #14
                            Originally posted by zalo View Post
                            Y'know, this is pretty much the perfect use case for the new distance field sampling node.

                            When the distance field reports the ocean is within a few meters of the environment, start blending in the foam.
                            It samples from distance fields which is the only issue, if you're landscape or whatever the water is brushing up against doesn't have a distance field, you get nout.

                            Comment


                              #15
                              Originally posted by TheJamsh View Post
                              It samples from distance fields which is the only issue, if you're landscape or whatever the water is brushing up against doesn't have a distance field, you get nout.
                              Works Like a charm. Here.

                              Click image for larger version

Name:	material.JPG
Views:	1
Size:	76.9 KB
ID:	1103752

                              Click image for larger version

Name:	result.JPG
Views:	1
Size:	42.0 KB
ID:	1103753
                              YouTube:Coruja Games
                              Twitter:@_corujagames
                              Facebook:@corujagames
                              Instagram:@_corujagames

                              Comment

                              Working...
                              X