Announcement

Collapse
No announcement yet.

[Community Project] WIP Weather & Ocean Water Shader

Collapse
This topic is closed.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

    You should be doing the opacity masking in the ocean material by the way you will not be able to mask the ocean out from the post process (unless there is a scene texture before translucency that I'm not aware of).

    Btw, I did a few tests yesterday to see if I could do something on my end to allow for easy masking but unfortunately you cannot use the stencil buffer for opacity masking and underwater masking at the same time (they interfere with each other).
    However, in the case of a submarine it should be easy to simply use a capsule mask in the ocean material instead of the stencil buffer, you would need to drive the start and end point of the capsule via material parameter from the submarine blueprint (the material function for the capsule mask is called DistanceField_Capsule or something like that if you wanna give that a shot).

    If you do not care about the underwater masking as much then you can use the stencil, I tried to mask the opacity when on the inside of a box and it works well.

    4.10 Update! -> [Community Project] WIP Weather & Ocean Water Shader
    WIP Interactive Water Shader, WIP 2D Water Sim
    WIP FFT Ocean w/ Foam, Quad-tree Infinite Ocean LOD

    Comment


      No matter what I did to the material I could not get it opaque (the roof is still here, and interestingly renders ABOVE everyhthing) and the green is coming from no where as far as I can tell nothing green is hooked up ATM.

      I never thought about applying these into the materials themselves.

      Will do some more playing around! Thanks TK!



      This is what ahppens with an ocean applied... it blends the original material (matte pink) with the ocean blue. Very interesting learning alot.



      Regarding the capsule masking, I never learned how to use that node, put it into a graph once and said, now what. Hence why Ineed to do the material courses for ue4.

      Edit:

      Although this does mask the ocean out thats right int he middle of the "room", but only allows color shading cartoon style.

      Learned what I'm sure will comein useful will play with tihs more than when I learn more about materials, theyre still pretty foreign to me. ThanKs TK



      This really excites me cause it feels so close to getting proper masking so that I can build my sub interior inside my sub exterior mesh so that I can start creating a scene instead of just driving a submarine around the ocean blowing up other ships from the ship orperiscope point of view. This will give a third or first person view. Very good feeling
      Last edited by Nsomnia; 02-24-2016, 02:05 PM.
      Tek LLC a personal Candaian Company running BlenderTek & UnrealTek is currently looking for help to bring back submarine simulator gaming with a new genre of sub sims: Cold War! (1945-1991) Operation: Trident SubSim Dev Diary Thread - Donations

      Comment


        Any thoughts on how to reduce the jitter/artifacts in the reflections and distant ocean? I would love to pitch in and help but I'm still just starting to take a look at the project and not sure yet what is causing some of the visual issues.
        \\VANGUARD INTERACTIVE

        Marketplace - Action RPG Inventory System | Multiplayer TopDown Kit | Advanced Social System
        Multiplayer TopDown Kit Tutorials - Merging The Action RPG Inventory System | Removing the Fog of War
        Action RPG Inventory Tutorials - Merging Into Your Project | Adding New Items | FPS Controls w/ UI Mode Toggle

        Comment


          Yeah the reflections is definitely the biggest issue that I have with the ocean at the moment.. screen space reflections are not gonna cut it here, you can improve them a bit by increasing the ray count in one of the .usf files but it comes with a cost and the result will be still far from accurate or clean.
          Not really that much that we can do right now, it's up to Epic to implement a better reflection system (it has to happen eventually but the question is when).

          Anyways, I think I'm just about finished with the post process material:

          It looks better in motion with the distortion and all
          There are still many things I wanna add (like god rays and lens splashes) but this will have to do for now.

          I still need to fix a few things in the ocean material and plugin code before the release but it shouldn't take too long, maybe Friday.

          4.10 Update! -> [Community Project] WIP Weather & Ocean Water Shader
          WIP Interactive Water Shader, WIP 2D Water Sim
          WIP FFT Ocean w/ Foam, Quad-tree Infinite Ocean LOD

          Comment


            Originally posted by TK-Master View Post
            Yeah the reflections is definitely the biggest issue that I have with the ocean at the moment.. screen space reflections are not gonna cut it here, you can improve them a bit by increasing the ray count in one of the .usf files but it comes with a cost and the result will be still far from accurate or clean.
            Not really that much that we can do right now, it's up to Epic to implement a better reflection system (it has to happen eventually but the question is when).

            Anyways, I think I'm just about finished with the post process material:

            It looks better in motion with the distortion and all
            There are still many things I wanna add (like god rays and lens splashes) but this will have to do for now.

            I still need to fix a few things in the ocean material and plugin code before the release but it shouldn't take too long, maybe Friday.

            Is this for the PP -> waterplane -> horizon issue most water planes suffer from?

            I noticed on the bug tracker on github you said FFT based wave forms are in the works eventuallly. Arnt gerstner waves FFT based?

            If not theres alot of code floating around working with FFT's It looked similar when I glanced over it to the 8 sin sum gerstner setup though.
            Tek LLC a personal Candaian Company running BlenderTek & UnrealTek is currently looking for help to bring back submarine simulator gaming with a new genre of sub sims: Cold War! (1945-1991) Operation: Trident SubSim Dev Diary Thread - Donations

            Comment


              Originally posted by TK-Master View Post
              Yeah the reflections is definitely the biggest issue that I have with the ocean at the moment.. screen space reflections are not gonna cut it here, you can improve them a bit by increasing the ray count in one of the .usf files but it comes with a cost and the result will be still far from accurate or clean.
              Getting the fog right seems to help clear up most of the distance scattering. I'm working on blending the fog with the sun position to get a smoother looking transition.
              I still need to find the right values, it's hard to blend with the skybox and not kill the color/brightness of the water in the process



              Also do you know what might be causing FXAA to create the dark spots on the ocean? I would like to avoid using Temporal AA so it's on my list of things to see if I can figure out and fix.



              Also The new underwater PP looks great
              Last edited by Pirate; 02-24-2016, 08:19 PM.
              \\VANGUARD INTERACTIVE

              Marketplace - Action RPG Inventory System | Multiplayer TopDown Kit | Advanced Social System
              Multiplayer TopDown Kit Tutorials - Merging The Action RPG Inventory System | Removing the Fog of War
              Action RPG Inventory Tutorials - Merging Into Your Project | Adding New Items | FPS Controls w/ UI Mode Toggle

              Comment


                Originally posted by Nsomnia View Post
                I noticed on the bug tracker on github you said FFT based wave forms are in the works eventuallly. Arnt gerstner waves FFT based?

                If not theres alot of code floating around working with FFT's It looked similar when I glanced over it to the 8 sin sum gerstner setup though.
                A Gerstner wave is basically a modified sine wave to be less round, more choppy it's a relatively simple algorithm.

                FFT on the other hand is a really complicated algorithm (I doubt there are any people who can write the thing from scratch) which is far more physically correct.
                It's what they used in black flag, gta5 (etc.) and pretty much every movie where there is cgi ocean.

                Luckily for us we already have 2 FFT implementations in UE4, WaveWorks and VaOcean.
                Both of them are incomplete atm but the base is there and it's enough for me to build on, there is an updated VaOcean branch in my github repo. but there are performance problems with the FFT readback that I haven't solve yet but I'm close.


                Originally posted by Pirate View Post
                Also do you know what might be causing FXAA to create the dark spots on the ocean? I would like to avoid using Temporal AA so it's on my list of things to see if I can figure out and fix.
                SSR is not supported with FXAA unfortunately.. Anti-aliasing and reflections are the top things rendering-wise that I wish Epic improves upon (don't we all?).

                4.10 Update! -> [Community Project] WIP Weather & Ocean Water Shader
                WIP Interactive Water Shader, WIP 2D Water Sim
                WIP FFT Ocean w/ Foam, Quad-tree Infinite Ocean LOD

                Comment


                  @TK-Master - that post process looks gorgeous, do want
                  Storyteller - An immersive VR audiobook player

                  Dungeon Survival - WIP First person dungeon crawler with a focus on survival and environmental gameplay ala roguelikes

                  Comment


                    Originally posted by TK-Master View Post
                    A Gerstner wave is basically a modified sine wave to be less round, more choppy it's a relatively simple algorithm.

                    FFT on the other hand is a really complicated algorithm (I doubt there are any people who can write the thing from scratch) which is far more physically correct.
                    It's what they used in black flag, gta5 (etc.) and pretty much every movie where there is cgi ocean.

                    Luckily for us we already have 2 FFT implementations in UE4, WaveWorks and VaOcean.
                    Both of them are incomplete atm but the base is there and it's enough for me to build on, there is an updated VaOcean branch in my github repo. but there are performance problems with the FFT readback that I haven't solve yet but I'm close.
                    .
                    I knew how a gerstner wave looks but say this code snipper from FFT based waves from unitys "ShaderExperiments" off github theyre using FFT (from a library it looks like ive seen it a few times) surely we could do this in c++?
                    Code:
                    void EvaluateWaves()
                        {
                            //Debug.Log("Evaluating Waves at " + Time.time * 1000);
                    		float kx, kz, len;// lambda = -1.0f;
                            int index;
                            for (int m_prime = 0; m_prime < TextureResolution; m_prime++)
                            {
                                kz = Mathf.PI * (2 * m_prime - TextureResolution) / OceanSize;
                                for (int n_prime = 0; n_prime < TextureResolution; n_prime++)
                                {
                                    kx = Mathf.PI * (2 * n_prime - TextureResolution) / OceanSize;
                                    len = Mathf.Sqrt(kx * kx + kz * kz);
                                    index = m_prime * TextureResolution + n_prime;
                    
                                    ComplexDisplacementMap[index] = hTilde(n_prime, m_prime);
                    
                                    SlopeX[index] = ComplexDisplacementMap[index] * new ComplexF(0, kx);
                                    SlopeZ[index] = ComplexDisplacementMap[index] * new ComplexF(0, kz);
                                    if (len < 0.000001f)
                                    {
                                        DisplaceX[index] = new ComplexF(0, 0);
                                        DisplaceZ[index] = new ComplexF(0, 0);
                                    }
                                    else
                                    {
                                        DisplaceX[index] = ComplexDisplacementMap[index] * new ComplexF(0, -kx / len);
                                        DisplaceZ[index] = ComplexDisplacementMap[index] * new ComplexF(0, -kz / len);
                                    }
                                }
                            }
                            //Debug.Log("Beginning FFT at " + Time.time * 1000);
                            Fourier.FFT2(ComplexDisplacementMap, TextureResolution, TextureResolution, FourierDirection.Backward);
                            Fourier.FFT2(SlopeX, TextureResolution, TextureResolution, FourierDirection.Backward);
                            Fourier.FFT2(SlopeZ, TextureResolution, TextureResolution, FourierDirection.Backward);
                            Fourier.FFT2(DisplaceX, TextureResolution, TextureResolution, FourierDirection.Backward);
                            Fourier.FFT2(DisplaceZ, TextureResolution, TextureResolution, FourierDirection.Backward);
                            //Debug.Log("Finished FFT at " + Time.time * 1000);
                            ApplyComplexMapToHeightMap();
                    Tek LLC a personal Candaian Company running BlenderTek & UnrealTek is currently looking for help to bring back submarine simulator gaming with a new genre of sub sims: Cold War! (1945-1991) Operation: Trident SubSim Dev Diary Thread - Donations

                    Comment


                      I just implemented the landscape modulation part in the ocean manager so that the buoyancy matches but the performance hit is huge .. I'm currently using a single ray trace per point to detect the landscape height but for some reason it costs way more than I thought.. it could be an issue with landscapes in general or tracing is simply that expensive(?) I don't know.

                      There is one last thing that I can try.. read the heightmap pixels rather than tracing, I could load the pixels into a float array on begin play which should hopefully be a lot faster to access but the downside is that I will have to replicate the same math as the heightmap modulation material function (I was hoping to completely avoid that by tracing).

                      Originally posted by Nsomnia View Post
                      I knew how a gerstner wave looks but say this code snipper from FFT based waves from unitys "ShaderExperiments" off github theyre using FFT (from a library it looks like ive seen it a few times) surely we could do this in c++?
                      That looks like the part where it reads the displacement, it doesn't compute the FFT there.


                      Originally posted by n00854180t View Post
                      @TK-Master - that post process looks gorgeous, do want
                      Yup it looks even better now with animated wet lens effect:


                      I have also modified a couple .usf files so that GaussianDOF works with the ocean plane properly.

                      4.10 Update! -> [Community Project] WIP Weather & Ocean Water Shader
                      WIP Interactive Water Shader, WIP 2D Water Sim
                      WIP FFT Ocean w/ Foam, Quad-tree Infinite Ocean LOD

                      Comment


                        Originally posted by TK-Master View Post
                        I just implemented the landscape modulation part in the ocean manager so that the buoyancy matches but the performance hit is huge .. I'm currently using a single ray trace per point to detect the landscape height but for some reason it costs way more than I thought.. it could be an issue with landscapes in general or tracing is simply that expensive(?) I don't know.


                        There is one last thing that I can try.. read the heightmap pixels rather than tracing, I could load the pixels into a float array on begin play which should hopefully be a lot faster to access but the downside is that I will have to replicate the same math as the heightmap modulation material function (I was hoping to completely avoid that by tracing).
                        Couldn't you look into the terrain vertex structure instead?

                        Yup it looks even better now with animated wet lens effect:

                        I have also modified a couple .usf files so that GaussianDOF works with the ocean plane properly.
                        Looks awesome!

                        I wonder how games like Crysis do the "thick line" on the ocean plane when the camera is half-submerged. Maybe altering the normals on the edge where it intersects the camera frustum?
                        Storyteller - An immersive VR audiobook player

                        Dungeon Survival - WIP First person dungeon crawler with a focus on survival and environmental gameplay ala roguelikes

                        Comment


                          Originally posted by n00854180t View Post
                          Couldn't you look into the terrain vertex structure instead?

                          Looks awesome!

                          I wonder how games like Crysis do the "thick line" on the ocean plane when the camera is half-submerged. Maybe altering the normals on the edge where it intersects the camera frustum?
                          So far it doesn't look like the vertex data is easily accessible.. I can't find any information about this either (the only relevant topics in answerhub are about traces).

                          I'm still searching for a way to do the water line but so far I have managed only a very ugly rough mask I thought I could use the stencil buffer for this as well but I can't seem to be able to match a small water line mesh exactly where it needs to be.

                          4.10 Update! -> [Community Project] WIP Weather & Ocean Water Shader
                          WIP Interactive Water Shader, WIP 2D Water Sim
                          WIP FFT Ocean w/ Foam, Quad-tree Infinite Ocean LOD

                          Comment


                            Originally posted by TK-Master View Post
                            I just implemented the landscape modulation part in the ocean manager so that the buoyancy matches but the performance hit is huge .. I'm currently using a single ray trace per point to detect the landscape height but for some reason it costs way more than I thought.. it could be an issue with landscapes in general or tracing is simply that expensive(?) I don't know.

                            There is one last thing that I can try.. read the heightmap pixels rather than tracing, I could load the pixels into a float array on begin play which should hopefully be a lot faster to access but the downside is that I will have to replicate the same math as the heightmap modulation material function (I was hoping to completely avoid that by tracing).


                            That looks like the part where it reads the displacement, it doesn't compute the FFT there.



                            Yup it looks even better now with animated wet lens effect:


                            I have also modified a couple .usf files so that GaussianDOF works with the ocean plane properly.
                            How did you go about creating this half-in-half-out water effect? That's not implemented in the GitHub project files is it? I've been trying to do this exact effect for my current Oculus Rift project but I can't figure it out for the life of me. I've just been using a post-process effect, which obviously doesn't give the desired effect when there's relatively large waves. Some guidance on this would be much appreciated.

                            Comment


                              I know there are other noobs like me following this thread too embarrassed to speak up ... this community project would benefit from a more detailed Readme file or Version Description Document with the GitHub download, describing the differences in the various branches and example maps, and which BPs are mutually exclusive. The Trello board is great, but the "completed" actions does not tells us which BP, branch, or ExampleMap has the new feature.

                              For example, caustics is in the complete row, yet OceanExampleMap_01 is the only map with caustics. It is also the only example with translucent water for a coastal level, and buoyancy actors that work and don't pop up into the air or sink below the surface. But of all the example maps, it is the only one that uses BP_Sky for accurate sun and moon positioning, but I can't find an animated day/night check box. I would like to use the BP_Skydome from OceanExampleMap_02 but that then causes problems with the translucent water.

                              Why does the buoyancy work so much better in Map_01? In which BP is caustics implemented in 01 so I can make adjustments? Don't know.

                              A lot of this I can do myself, even as a noob...swimming, no problem:

                              Click image for larger version

Name:	Swimming.PNG
Views:	1
Size:	93.2 KB
ID:	1101313

                              One button switch between 1st and 3rd person with 2nd camera attached to root bone to avoid excessive bobbing, no problem:

                              Click image for larger version

Name:	Camera.PNG
Views:	1
Size:	80.2 KB
ID:	1101314

                              Add a flashlight:

                              Click image for larger version

Name:	Flashlight.PNG
Views:	1
Size:	143.0 KB
ID:	1101315

                              1. Smooth inverse kenematics for character's feet
                              2. Where to find treading and swimming animations
                              3. Landscape Height modulation to control waves encroaching up the shoreline
                              4. Good looking Water line like that in Dying Light
                              5. Character buoyancy only when treading or swimming at the surface so it bobs with waves and goes prone when swimming
                              6. Swash, backwash, and wet sand
                              7. Function changing water color based on z depth, like seen in Black Flag
                              8. Working drivable sea-doo to enjoy the beautiful SSS enhanced waves!

                              These are my priorities, I would take them on if I could, but beyond my abilities.

                              Comment


                                Its impressive how far you people have come

                                Comment

                                Working...
                                X