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

    Hey what's up everyone

    Reply train ahead!

    Code:
        o o o o o o o . . .    ______________________________ _____=======_||____
       o      _____            |                            | |                 |
     .][__n_n_|REPLY[  -=_____  |                            | |                 |
    >(________|__|_[_________]_|____________________________|_|_________________|
    _/oo OOOOO oo`  ooo   ooo  'o!o!o                  o!o!o` 'o!o         o!o`
    -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-


    Originally posted by OnlyHorrorOnlyHardcore View Post
    will you port this to 4.11?
    Eventually..


    Originally posted by n00854180t View Post
    Is there a way to go from a calm one-wave-set ocean to the stormy style, and back?
    You can but it will need some work unfortunately basically you will have to interpolate between different wave set parameters (both in material and in bp ocean).

    Eventually we will have a Beaufort scalar parameter to do this more easily but for now it is what it is
    The stormy ocean material was something I added at the last minute as a demonstration of what is possible with Gerstner waves and it's something I plan to work on and improve (probably not anytime soon though).


    Originally posted by Korablev View Post
    Hello! Please tell me, where is the parameter that is responsible for the angular water resistance? I can not find ... Just wanted to weaken it in some cases, for some models. Because sometimes it felt that the boat moves as if on rails. And in fact, the ship must drift a little bit in the corners. Thank you in advance!
    If you are using my buoyancy component then sorry but there is no such thing xD I have not implemented realistic water resistance or anything like that yet.
    You can try using Nubtron's BuoyantMesh component which has a more advanced buoyancy but for now you will most likely have to implement your own physics to get exactly what you want.

    Realistic ship and sailing physics is definitely on my to-do list but I have no time frame atm.


    Originally posted by BigaC View Post
    hi, sorry for noob question/probably already mentioned somewhere, tough tried read the topic.
    can I somehow see water waving reflection on metallic surfaces?
    I have reflection capture sphere added, but dont see any difference

    http://imgur.com/5sCbplc
    Hi, are you talking about caustics reflected on the ship hull? if so then this is not currently implemented, caustics are only shown underwater.
    You could try faking it in the ship's hull material or edit the caustics material in order to be shown a bit above water.

    I have a better and more accurate caustics system in the works but I don't know when it will be ready atm.


    Originally posted by Mr Briteside View Post
    hi I'm new to unreal engine and i was wondering if anyone was going to make a tutorial about how to use the blueprints in this project as assets to their own or something as i want to make a game where i can sail around on a ship i build myself but the ocean doesn't even render on my computer for some reason. it keeps saying that this sample thing i think it was is over 16 samples and it can't process it, please can someone make a video on how to use it I'm so confused with how all this works.
    If you are getting the 16 samples error then you must be on mac or linux which are currently not supported out of the box (sorry!).


    Originally posted by DamirH View Post
    Heya,

    Do the two shaders play nicely with 4.11?

    Edit:

    Welp, answered my own question (They don't). I got the deferred common one re-patched but the DOF one needs a bit more work, gonna do that tomorrow. (Had to zip the file since the attachments won't let me upload .usf)
    Yeah.. the .usf files will need to be updated for each engine version for sure since they change all the time (especially the DeferredShadingCommon one I would imagine).
    And there will be more of these at some point.

    I'm planing to implement custom BRDF models for better speculars and whatnot, also fixes for anything that uses the scene depth such as exponential height fog.


    Originally posted by DamirH View Post
    Now, is it possible to use this to mask out underwater interiors?
    Yes but there are limitations (for example half-in half-out interiors will be difficult or impossible).

    You will need two meshes, lets say boxes..

    Box #1: enable Render CustomDepth Pass and stencil value = 1
    Box #2: same thing but stencil = 0

    Make box #2 slightly smaller (or set one-sided materials to the boxes and invert the normals of box #2 in your modeling software so it only shows from the inside) and fit it exactly inside box #1.

    (Note: only opaque materials write to the depth buffer, don't use translucent ones).

    You should now not be able to see the underwater pp when the camera is inside box #2.

    Alternatively you could just use a volume's overlap event to toggle the post process on/off (not gonna be as accurate most likely).

    Originally posted by DamirH View Post
    Hey guys, another question from me - has there been any work done on a more advanced underwater post process effect? Namely there are two features I'd love to see and I'd gladly take a stab at implementing them myself, just want to make sure that I am not redoing work that's been done already:

    1. More advanced underwater visibility. Currently it uses the distance fog standard thing, but I want to make it so that the visibility in shallow water is far greater than in the depth, obviously due to sunlight coming in greater amount.
    2. Light rays coming in from the surface that can be seen inside the shallow water. I suppose there will most likely have to be faked but they'd look awesome.

    If anyone has done anything similar or knows perhaps a paper that dealt with the issue let me know.
    Feel free to implement these, that would be great

    About #1, accurate light absorption is something I plan to work on but it might end up being expensive (the exponential fog is already a bit too costly if you ask me).
    Have you tried messing around with the settings in M_Underwater_PP_Inst ? you can adjust the visibility and quite a few parameters there.

    God rays is also something I have planned but I have not worked on this yet.

    I would start with something like this
    https://forums.unrealengine.com/show...c-Light-Shafts


    Originally posted by joplin66 View Post
    Cool! I have seen quite a few videos which are using the project since the 4.10 update, glad you guys find it useful

    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


      I have updated the DeferredCommons usf as that one only has those two functions added at the bottom. The DOF one has more extensive changes and needs to be merged carefully one function at a time manually so it will take some time and care.

      Thanks for the masking info I will give it a shot.

      I am not TOO worried about performance because the underwater is literally everything there will be, I will not have that many objects rendered. I did mess with the underwater PP but the problem is that the visibility distance is the same at different depths, which is something I need to have. However it's not a huge deal, I will simply make a depth lerp and multiply the coloration with that.

      Lastly, for the God Rays, yeah I was looking into that as well and will try to get them implemented eventually. The sunshaft BP is very easy to set up but I will have to figure out how to use the same masking that you use for the underwater post process to also mask out the sunshafts.

      Since my last post one more thing came to mind - is it possible to have the terrain heightmap blending work with streaming levels and tiled landscapes? Could I perhaps switch out the landscape actor and heightmap at runtime as the player enters a new level?

      Best regards,
      Damir H.
      Last edited by DamirH; 03-31-2016, 10:43 AM.

      Comment


        Fish Avoidance

        Hey everybody,

        Since interest in this project has picked up.... a LOT, I've been getting a lot of messages relating to fish avoiding obstacles. I was never able to get this feature quite working how I wanted it to. Let's look at the code:

        Code:
        FVector AFlockFish::AvoidObstacle()
        {
        	FVector actorLocation = this->GetActorLocation();
        	FVector forwardVector = (this->GetActorForwardVector() * AvoidanceDistance) + actorLocation;
        
        	FHitResult OutHitResult;
        	FCollisionQueryParams Line(FName("Collision param"), true);
        	bool const bHadBlockingHit = GetWorld()->LineTraceSingleByChannel(OutHitResult, actorLocation, forwardVector, COLLISION_TRACE, Line);
        	FVector returnVector = FVector(0, 0, 0);
        	float distanceToBound = distanceToBound = (this->GetActorLocation() - OutHitResult.ImpactPoint).Size();
        	if (bHadBlockingHit)
        	{
        		if (OutHitResult.ImpactPoint.Z > this->GetActorLocation().Z + FishInteractionSphere->GetScaledSphereRadius())
        		{	
        			returnVector.Z += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * -1;
        		}
        		else if (OutHitResult.ImpactPoint.Z < this->GetActorLocation().Z - FishInteractionSphere->GetScaledSphereRadius())
        		{
        			returnVector.Z += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * 1;
        		}
        
        		if (OutHitResult.ImpactPoint.X > this->GetActorLocation().X)
        		{
        			returnVector.X += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * -1;
        		}
        		else if (OutHitResult.ImpactPoint.X < this->GetActorLocation().X)
        		{
        			
        			returnVector.X += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * 1;
        		}
        
        		if (OutHitResult.ImpactPoint.Y > this->GetActorLocation().Y)
        		{
        			returnVector.Y += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * -1;
        		}
        		else if (OutHitResult.ImpactPoint.Y < this->GetActorLocation().Y)
        		{
        
        			returnVector.Y  += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * 1;
        		}
        
        		returnVector.Normalize();
        		FVector avoidance = returnVector * AvoidanceForce;
        		return avoidance;
        	}
        	return FVector(0, 0, 0);
        }
        I think I was getting close to a solution, so I'll write my thoughts out here and if anybody wants to give it a shot, or attempt another method then by all means please do it!

        I basically set up a line trace on each AFlockFish that is created from the front of them, forward. I believe the distance they see in front of them is a modifiable value. When the line detects a collision, I attempt to add a vector to the fish's current rotation.

        Code:
        	// Set Rotation 
        	FVector targetRotation = (Fish->getSeekTarget() - Fish->GetActorLocation() + Fish->AvoidObstacle());
        	FRotator leaderRotation = FRotationMatrix::MakeFromX(targetRotation).Rotator();
        	leaderRotation = FMath::RInterpTo(Fish->GetActorRotation(), leaderRotation, delta, Fish->turnSpeed);
        	Fish->setRotation(leaderRotation);
        What this should do is, when the fish detects an object in front of it, it should take into account the x,y, and z value differences between itself and the location of the hit, and the distance from the object. The fish will then flip all of the points of the hit location in relation to itself as its seeking target for the next tick. So say the fish is swimming downwards, it notices it's about to hit a rock. The rock is -Z downwards from the fish, +X in relation to the fish, and -Y in relation to the fish or (+Xi, -Yi, -Zi) where i is the actual numeric value of the offset. This means the fish will seek (-Xif, +Yif, +Zif) the next tick, where f is the force value determined by the distance to the object, and the modifiable AvoidForceMultiplier set by the user. What this SHOULD achieve is a state where the fish will only lightly avoid obstacles in the distance, but veer strongly away from obstacles right in front of it.

        Anyway there was the gist of how it was supposed to work. I can't remember where I left off - I did have moderate success, but I was never able to get it fully working.

        Hope one of you can figure it out ,
        Komodo

        Comment


          Yup, it's possible to change the heightmap at runtime, check out the Set Global Parameters function in the ocean bp.

          For tiled landscapes you could potentially make a single heightmap for the whole thing since it doesn't always need to be that accurate (but then you will probably have to modify OceanManager.cpp in order to be able to pass custom landscape location and scale.

          Also keep in mind that the landscapes must have no rotation (I have not implemented the rotational math needed since you normally don't have to rotate a landscape anyway).

          Edit:

          Oh I just thought of a problem.. you will need to also re-read the heightmap pixels in OceanManager.cpp which is definitely going to cause a hitch since it's a slow operation that is best done at beginplay only.
          You could potentially load multiple heightmaps at beginplay but obviously this will need to be implemented in C++ side and it might increase memory usage a lot.

          Unless of course you don't need accurate buoyancy in which case you can skip the OceanManager.cpp part.
          Last edited by TK-Master; 03-31-2016, 11:14 AM.

          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


            Yeah I am most likely skipping the heightmap stuff alltogether since most of the game is taking place under water. Should the need arrise I will see what can be done in that respect.

            Chances are I will be contributing quite a bit on this project since I am using it in an undersea exploration games (will also have islands and boats and whatnot) so chances are I will be extending it quite a bit.

            Will post updates once I have them!

            Comment


              Originally posted by DamirH View Post
              Yeah I am most likely skipping the heightmap stuff alltogether since most of the game is taking place under water. Should the need arrise I will see what can be done in that respect.

              Chances are I will be contributing quite a bit on this project since I am using it in an undersea exploration games (will also have islands and boats and whatnot) so chances are I will be extending it quite a bit.

              Will post updates once I have them!
              I'm working on something similar obviously will be watching for anything from you, and I'm working towards the same goals, picking up more cpp, unreal4 api and cryengine cpp everyday.

              I played with quantams buoyancy setup but never got a working setup, im still particular to the old structure setup with a test point structure. I had a great setup using that, I may revert when I need it, or create my own setup when my skills increase, although I'm not worries about above water dynamics as much as underwater obviously.


              I've got a great algae particle system setup, just dont have time to draw a sprite sheet or even just a decent texture, if anyone has a cool one like in silent hunter 4 thats public domain I can use it and we can add in a boolean algae system that follows the player.
              ;
              Edit: I've got a shader only radar setup and also the same for a bearing and depth indicators although those use textures obviously. If you'd like them let me know, they are in early stages, but not ready formpublic release.


              In regards to the depth I just decreqase the brightness/gamma and increase the vignette as the depth gets deeper till a totally uninhabitable area thats black.

              Biggest issue from makign me work full time on my game is also making a earth sized game IE

              if(GetFirstPlayerController()->GetPawn()->GetLocation().x,y / mapsize/2 does not touch land) {OpenLevel(water)} else {openLevel(whatever coastline or port needs to be loaded.umap) } and a minimap to go along with that... very tough and gaurenteed unblueprintable.
              Last edited by Nsomnia; 04-01-2016, 05:46 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


                My issue with the decrease of brightness is that, if you want a high visibility in the shallows you will paradoxically be able to better see a deep part from high above than when you dive down to it.

                Comment


                  [MENTION=5640]DamirH[/MENTION] I dont understand can you describe that better?


                  I finally downloaded 4.11 and will be porting the plugin as well as the shaders (with the above guys help hopefully) and adding in the other buoyancy setup and any changes I see fit, to my fork, will keep updated.
                  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


                    Well let's say for example you make your visibility on the surface 100 meters. So you just dive down and you can see the ground 100 meters in front of you. But you visibiliyu down 50 meters is only 30 meters so in total you can now see 80 meters down - less than what you could see from the surface.

                    I suppose this can be fixed with some math but it's still somewhat of an annoying problem.

                    Comment


                      Originally posted by Senitelty View Post
                      I thought you might want to know.

                      MIXAMO TERMS.

                      Have the Terms of Service changed?
                      Yes. By signing up for an Adobe ID you must agree to the Adobe Terms of Use and Privacy Policy. Be sure to carefully read them as they may be different from the previous Mixamo terms of service.
                      Can I continue to use Mixamo for my graphic design, video game, film or print project?
                      Yes. Adobe provides services intended for professional use. Mixamo content can be used for both commercial and non-commercial projects, and you retain full rights to your works. For details, refer to Adobe’s Terms of Use and Privacy Policy.
                      Can I use Mixamo royalty free or in commercial projects?
                      Yes. Mixamo is available for a limited duration as a technology preview and is available free, without license or royalty fees, for unlimited use in both commercial and non-commercial projects.
                      Will I still be able to download assets in file formats that are compatible with game engines and 3D software?
                      Yes. Current download types include FBX, BVH and DAE.
                      I would think twice about sharing licensed content. If you look at their terms of use, it does tell you this:

                      5. User Conduct.

                      5.1 Responsible Use. The Adobe communities often consist of users who expect a certain degree of courtesy and professionalism. You must use the Services responsibly.

                      5.2 Misuse. You must not misuse the Services, Software, or content that we provide to you as part of the Services. For example, you must not:

                      (a) copy, modify, host, stream, sublicense, or resell the Services, Software, or content;
                      https://github.com/0lento/UnrealEngine (GameWorks tech merges & upgrades, UE4 physics modifications)

                      Comment


                        Yes, Mixamo does not allow for redistribution of their content. That is, it can be used in commercial and non-commercial projects, but not in such a way that the content is directly accessible to the user, which it would be in this case.

                        Comment


                          Let me ask some completely noob questions:

                          1 - Why calculate Gerstner Waves on Both sides, in GPU and CPU? CPU is obvious because the need to update physics. But, Why not expose the clusters generation of C++ code to BP and then pass this vector parameter directly to material?
                          2 - How can I clean up the project to get ONLY the Ocean Part?
                          3 - Can I use vertex painting to GROW or SMOTH Waves? Like Z * Alpha Channel?
                          4 - There is a way that I Extract Only Ocean manager to make all this that i describe above?
                          5 - I have GTX 970 and here ULTRA Shader runs around 23 fps. That is because ocean or ALL other things in project?


                          Thank You.
                          YouTube:Coruja Games
                          Twitter:@_corujagames
                          Facebook:@corujagames
                          Instagram:@_corujagames

                          Comment


                            It's probably not the ocean, I also have a 970 and I'm getting 45-50 fps with the ultra shader at max settings in 2560x1440.

                            Comment


                              Originally posted by reneberwanger View Post
                              Let me ask some completely noob questions:

                              1 - Why calculate Gerstner Waves on Both sides, in GPU and CPU? CPU is obvious because the need to update physics. But, Why not expose the clusters generation of C++ code to BP and then pass this vector parameter directly to material?
                              2 - How can I clean up the project to get ONLY the Ocean Part?
                              3 - Can I use vertex painting to GROW or SMOTH Waves? Like Z * Alpha Channel?
                              4 - There is a way that I Extract Only Ocean manager to make all this that i describe above?
                              5 - I have GTX 970 and here ULTRA Shader runs around 23 fps. That is because ocean or ALL other things in project?


                              Thank You.
                              1) Gerstner waves are not just a bunch of vector parameters that you can pass from the CPU to the GPU, the Gerstner calculations are fairly math-intensive and are computed per-vertex on the GPU which is what makes the ocean plane move.
                              On the CPU side you only need to perform the Gerstner calculations for each buoyancy test point (which are very few compared to the thousands of vertices that the ocean plane has).

                              2)You can delete any content folder that you don't need and simply keep the Ocean folder but the skydome is also needed to pass the sun vector to the material so you will have to either keep the sky or copy over the vector update part from the sky blueprint to your own sky.

                              3) It's not possible to use vertex painting if you want to also use the infinite ocean system since it moves and scales the ocean based on camera location but you could potentially apply the material to a static plane and then vertex paint that.
                              Or you can use the landscape heightmap method to raise or lower the waves.

                              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
                                1) Gerstner waves are not just a bunch of vector parameters that you can pass from the CPU to the GPU, the Gerstner calculations are fairly math-intensive and are computed per-vertex on the GPU which is what makes the ocean plane move.
                                On the CPU side you only need to perform the Gerstner calculations for each buoyancy test point (which are very few compared to the thousands of vertices that the ocean plane has).
                                Man. Review your code. At some point its exact the same Math. (8 Waves / 8 is an example) At end of all you return is a Vector 3. And then repeat the same Math on Material. That I asking why is Equal and done 2 times.

                                Originally posted by TK-Master View Post
                                2)You can delete any content folder that you don't need and simply keep the Ocean folder but the skydome is also needed to pass the sun vector to the material so you will have to either keep the sky or copy over the vector update part from the sky blueprint to your own sky.
                                I cant use my own skydome? I think its because the caustics right?

                                Originally posted by TK-Master View Post
                                3) It's not possible to use vertex painting if you want to also use the infinite ocean system since it moves and scales the ocean based on camera location but you could potentially apply the material to a static plane and then vertex paint that.
                                Or you can use the landscape heightmap method to raise or lower the waves.
                                Also, I believe that calculations based on heightmap are unnecessary if I could using vertex painting.

                                Another questions:

                                Why you don't use materials functions on Ocean Material? That is a material that only you 2 can understand now.
                                I asked Dotcam if you need help several times and I was ignored. I can help especially in the artistic part. No offense, but I think the look of the ocean can be improved. Even send solution to the problem of intersecting objects, using Distance Field AO. (Solution here)

                                Ignore all the rest (Its ugly i know), focus on Foam Mask.




                                I really think it was a great job done here. But I think you should focus on clean and optimize, instead of increasing the features. And I really can help.
                                Last edited by Raziєl; 04-06-2016, 10:14 AM.
                                YouTube:Coruja Games
                                Twitter:@_corujagames
                                Facebook:@corujagames
                                Instagram:@_corujagames

                                Comment

                                Working...
                                X