[Community Project] WIP Weather & Water Shader

Wow, it is such an amazing thing youre doing it looks amazing

I thought you might want to know.

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 terms of service.
Can I continue to use for my graphic design, video game, film or print project?
Yes. Adobe provides services intended for professional use. 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 royalty free or in commercial projects?
Yes. 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 have officially broken my ue4 API cpp cherry with udemys escape game. A lot of simple game actions are easier than I thought. Iā€™m ahes away from contributing to the project but Iā€™m making my way have headers macros annd member functions figured out at a basic level.

Wow guys, I havenā€™t looked at since early versions - it looks better than WaveWorks now!
Nice work and thanks for sharing !

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 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 doesnā€™t even render on my computer for some reason. it keeps saying that 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 works.

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)

will you port to 4.11?

I tried implementing plugin into an empty project and I had trouble getting the underwater stuff to work until I copied over the Config folder. What setting was I missing? Something in rendering?

Stencil buffer, got it.

Now, is it possible to use to mask out underwater interiors?

Hey dudes gave you a mention hereā€¦http://80.lv/articles/ue4-from-scratch-by-the-beginner/

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 .

If anyone has done anything similar or knows perhaps a paper that dealt with the let me know.

Hey whatā€™s up :slight_smile:

Reply train ahead!



    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`
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-


:stuck_out_tongue: :stuck_out_tongue:

Eventuallyā€¦ :stuck_out_tongue:

You can but it will need some work unfortunately :rolleyes: basically you will have to interpolate between different wave set parameters (both in material and in bp ).

Eventually we will have a Beaufort scalar parameter to do more easily but for now it is what it is :stuck_out_tongue:
The stormy 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).

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.

Hi, are you talking about caustics reflected on the ship hull? if so then 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.

If you are getting the 16 samples error then you must be on or which are currently not supported out of the box (sorry!).

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.

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).

Feel free to implement these, that would be great :slight_smile:

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 yet.

I would start with something like
https://.unrealengine.com/showthread.php?86465-Fake-Dynamic-Light-Shafts

Cool! :wink: I have seen quite a few videos which are using the project since the 4.10 update, glad you guys find it useful :slight_smile:

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,
.

Fish Avoidance

Hey everybody,

Since interest in 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 quite working how I wanted it to. Letā€™s look at the code:


FVector AFlockFish::AvoidObstacle()
{
	FVector actorLocation = ->GetActorLocation();
	FVector forwardVector = (->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 = (->GetActorLocation() - OutHitResult.ImpactPoint).Size();
	if (bHadBlockingHit)
	{
		if (OutHitResult.ImpactPoint.Z > ->GetActorLocation().Z + FishInteractionSphere->GetScaledSphereRadius())
		{	
			returnVector.Z += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * -1;
		}
		else if (OutHitResult.ImpactPoint.Z < ->GetActorLocation().Z - FishInteractionSphere->GetScaledSphereRadius())
		{
			returnVector.Z += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * 1;
		}

		if (OutHitResult.ImpactPoint.X > ->GetActorLocation().X)
		{
			returnVector.X += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * -1;
		}
		else if (OutHitResult.ImpactPoint.X < ->GetActorLocation().X)
		{
			
			returnVector.X += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * 1;
		}

		if (OutHitResult.ImpactPoint.Y > ->GetActorLocation().Y)
		{
			returnVector.Y += (1 / (distanceToBound * (1 / AvoidForceMultiplier))) * -1;
		}
		else if (OutHitResult.ImpactPoint.Y < ->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.


	// 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 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. 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 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 :D,

Yup, itā€™s possible to change the heightmap at runtime, check out the Set Global Parameters function in the 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 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.

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 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 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.

My 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.

@ 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.

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 can be fixed with some math but itā€™s still somewhat of an annoying problem.

I would think twice about sharing licensed content. If you look at their terms of use, it does tell you :