Announcement

Collapse
No announcement yet.

Under water / above water split view, is this possible?

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

    #46
    Can anyone confirm if this method still works with UE 4.20.3 ?
    For some reason, stopped working for me, bad positions

    Comment


      #47
      That method indeed stopped working after the addition of dynamic resolution and temporal upscaling to the engine. I ran into this for FNBR and I tried to get the old approach working, but was having issues getting something that worked on all platforms.

      Due to time constraints, I ended up using the simpler method of just looking up WorldPosition (which in the post process material is calculated correctly for you), and then doing masking based on Z. Now obviously this only works for either:

      1) A flat water plane
      2) A water plane where you render either an opaque underside material to get the worldposition value solved directly for you or
      3) You can use a custom depth render plane that includes your displacements, but then you have to calculate the worldposition of the custom depth in your material manually.

      It is on my list to figure out how to get proper screen position world coordinates on all platforms but I am not sure when I will get it it.
      Ryan Brucks
      Principal Technical Artist, Epic Games

      Comment


        #48
        Hello,

        I have found two solutions one for PC and the second for mobile.

        It is not very elegant but works for me so maybe it will help somehow to figure out something better

        I'm using this solution in my Aquatic Surface:
        https://www.unrealengine.com/marketp...quatic-surface

        Last edited by ImaginaryBlend; 10-06-2018, 02:50 PM.
        Fast Stylized Procedural Sky
        Anime Toon Shading
        SDF Robo Progress Bars
        Aquatic Surface

        Comment


          #49
          Ahh interesting! What's the Nearplane node?

          Comment


            #50
            Just "View.NearPlane" , known as magic constant = 10

            You can find more shader parameters here: https://api.unrealengine.com/INT/API...ers/index.html
            Last edited by ImaginaryBlend; 10-06-2018, 03:13 PM.
            Fast Stylized Procedural Sky
            Anime Toon Shading
            SDF Robo Progress Bars
            Aquatic Surface

            Comment


              #51
              That looks pretty good! For the PC one, the divide by vector length could just be simplified the a normalize, but its basically the same thing.

              Also for the next version of the engine, doing that bias scale on the screen position should not be necessary on mobile anymore since that was unified in code finally.
              Ryan Brucks
              Principal Technical Artist, Epic Games

              Comment


                #52
                I am actually having severe complications with underwater splitscreen. Normally I would render water surface stencil with front faces only. Logic becomes simple. If stencil matches, the pixel is above water, underwater otherwise. There is a small inconvenience that stock engine does not allow separate IDs for front and back faces and not allowing to write front faces only into stencil from a two-sided material. But in my case the approach is not suitable for seeing backface does no guarantee being underwater due to overlapping waves.

                Comparing fragment world position Z at near plane vs displacement Z is complicated by XY displacements, namely the fact those are several orders of magnitude larger than view frustum section at near clip plane and approximating intersection does not yield enough precision at sane number of steps. Needless to say that sampling displacements per pixel at full screen several times is not something I'd ever would like to do.

                What maneuvers do I have remaining, before calling it not feasible?

                Comment


                  #53
                  That looks pretty good! For the PC one, the divide by vector length could just be simplified the a normalize, but its basically the same thing.
                  Yes, that is true. This normalization only had a sense during my testing/debugging the mobile. This fragment can be even replaced by CameraVector that is already normalized.

                  Also for the next version of the engine, doing that bias scale on the screen position should not be necessary on mobile anymore since that was unified in code finally.
                  The screen position in the WebGL version will be unified too? In the current version I'm using a custom node for flipping Y:

                  #if WEBGL
                  return float2(UV.x,1.0 - UV.y);
                  #else
                  return UV;
                  #endif


                  I am actually having severe complications with underwater splitscreen. Normally I would render water surface stencil with front faces only. Logic becomes simple. If stencil matches, the pixel is above water, underwater otherwise. There is a small inconvenience that stock engine does not allow separate IDs for front and back faces and not allowing to write front faces only into stencil from a two-sided material. But in my case the approach is not suitable for seeing backface does no guarantee being underwater due to overlapping waves.
                  You should consider splitting into two materials. It will probably work faster anyway because you will be able to optimize it for custom conditions.

                  Comparing fragment world position Z at near plane vs displacement Z is complicated by XY displacements, namely the fact those are several orders of magnitude larger than view frustum section at near clip plane and approximating intersection does not yield enough precision at sane number of steps. Needless to say that sampling displacements per pixel at full screen several times is not something I'd ever would like to do.
                  Maybe just render the screen waterline into small texture and use the results in the z comparison?
                  Last edited by ImaginaryBlend; 10-07-2018, 06:25 AM.
                  Fast Stylized Procedural Sky
                  Anime Toon Shading
                  SDF Robo Progress Bars
                  Aquatic Surface

                  Comment


                    #54
                    Originally posted by ImaginaryBlend View Post


                    You should consider splitting into two materials. It will probably work faster anyway because you will be able to optimize it for custom conditions.
                    That is counter-performant and does not address waves folding on themselves.


                    Originally posted by ImaginaryBlend View Post
                    Maybe just render the screen waterline into small texture and use the results in the z comparison?
                    Yes, as an option. I've considered it. It is a tradeoff. Lowering resolution increases the region, that will have have to be no-see through to account for error and adds additional overhead of setting the rendering.

                    Comment


                      #55
                      Hi everyone! I've been working on a quick and easy method to achieve this effect for some time now - my approach is very similar to Ryan's original method, with a couple of small modifications for windowed view.
                      Here are my results so far:
                      Click image for larger version  Name:	W61920x10807619b9d6c3c30fb9c963971ee2ffdbc9.jpg Views:	1 Size:	271.5 KB ID:	1605727Click image for larger version  Name:	T1.jpg Views:	1 Size:	458.7 KB ID:	1605728Click image for larger version  Name:	FFF.jpg Views:	1 Size:	544.0 KB ID:	1605729 Click image for larger version

Name:	image_161785.jpg
Views:	1
Size:	116.1 KB
ID:	1605730
                      There are currently some slight limitations ie. if the wave frequency is extremely high on screen, but all in all it's been pretty stable.
                      With my limited experience it took me several months to get it running so I decided to make an asset pack to save others a ton of time:
                      https://www.unrealengine.com/marketp...slug/waterline

                      First time posting so any feedback and comments are super welcome

                      Comment


                        #56
                        Originally posted by ChesherZ View Post
                        Hi everyone! I've been working on a quick and easy method to achieve this effect for some time now - my approach is very similar to Ryan's original method, with a couple of small modifications for windowed view.
                        Here are my results so far:
                        Click image for larger version Name:	W61920x10807619b9d6c3c30fb9c963971ee2ffdbc9.jpg Views:	1 Size:	271.5 KB ID:	1605727Click image for larger version Name:	T1.jpg Views:	1 Size:	458.7 KB ID:	1605728Click image for larger version Name:	FFF.jpg Views:	1 Size:	544.0 KB ID:	1605729 Click image for larger version

Name:	image_161785.jpg
Views:	1
Size:	116.1 KB
ID:	1605730
                        There are currently some slight limitations ie. if the wave frequency is extremely high on screen, but all in all it's been pretty stable.
                        With my limited experience it took me several months to get it running so I decided to make an asset pack to save others a ton of time:
                        https://www.unrealengine.com/marketp...slug/waterline

                        First time posting so any feedback and comments are super welcome
                        That looks really nice! Would this work with my own displaced water material that uses gertsner waves?

                        Comment


                          #57
                          Originally posted by WixZ View Post

                          That looks really nice! Would this work with my own displaced water material that uses gertsner waves?
                          The current version - probably not. I haven't done much tests with gertsner waves - the focus with this was more on sea/lake water as opposed to an ocean.
                          I do suspect that with some additional work you might be able to get it to work with some changes to the shaders, but generally assume that they are not supported for now

                          Comment


                            #58
                            @ImaginaryBlend
                            The truth is very good, a long time ago we got a very similar method, but unfortunately it does not work with displacement, we have used a classic method but with displacement, waves in
                            storm state etc.

                            Click image for larger version  Name:	Z16djsdLpM.jpeg Views:	1 Size:	87.9 KB ID:	1663797

                            Comment


                              #59
                              Just set up a post process material and make the water with a custom stencil - then you can mask above and below the stencil using the stencil itself as the separation.
                              this way it doesn't matter what kind of deformation the water takes.

                              alternatively, you can try to make the same gerstner math inside the PP, it's more accurate, but costs more processing wise as you will now have likely 3 sets of math functions that are identical or nearly identical.
                              all solving for the same time, and similar locations...

                              Comment

                              Working...
                              X