[Community Project] WIP Weather & Water Shader

4.8 version uploaded!

Here we go! I have uploaded the 4.8 version :wink: ( will be updated at a later time).

Screens:

SSR
http://www.mediafire.com/convkey/ea7f/9ifotl4151ob4d2zg.jpg?size_id=6
(Click for original size)

Foam
http://www.mediafire.com/convkey/03a1/octvtnvf2kpam4gzg.jpg?size_id=6
(Click for original size)

Shore
http://www.mediafire.com/convkey/f095/70xpo3gp13mprlszg.jpg?size_id=6
(Click for original size)

New 4.8 features:

-Screen Space Reflections (SSR)
-Infinite System
-Distance Blended Normals
-Configurable Sets of Panning Normals (Small, Medium, Far)
-Heightmap-based Seafoam & Foam Wave Caps (Thanks Le!)
-Cubmap-based Reflections (optional)
-Exposed many parameters to BP_Ocean. - You can now easily switch between shader versions, change textures, normals, foam, cubemap, heightmap etc.
-Underwater Distortion Effect
-Underwater Caustics

-Fixed buoyant destructible physics (too “jumpy”)
-Fixed a few other problems caused by 4.8 engine core changes

Current known issues:
Destructible icebergs can cause a crash when rapidly shot by cannons (if you guys have any ideas about one, please let me know :p)
SSR shader version uses 14 samplers (might not work in/… please let me know)

Link removed, get the latest version from !

Thanks, man!!!



1>------ Build started: Project: ue47pano, Configuration: Development_Game x64 ------
1>  Parsing headers for ue47pano
1>  Reflection code generated for ue47pano
1>  Performing 26 actions (4 in parallel)
1>  [4/26] Resource ue47pano.rc
1>  PCH.UELinkerFixups.UELinkerFixupsName.h.cpp
1>  PCH.ue47pano.ue47pano.h.cpp
1>  PCH.OceanPlugin.OceanPluginPrivatePCH.h.cpp
1>  UELinkerFixups.cpp
1>  MyClass.cpp
1>  ue47pano.cpp
1>  OceanPlugin.generated.cpp
1>  MarchingCubes.cpp
1>  BuoyantDestructible.cpp
1>  Noise.cpp
1>  OceanPlugin.cpp
1>  SimplexNoise.cpp
1>  FishNode.cpp
1>  FlockFish.cpp
1>  TerrainMeshComponent.cpp
1>  TerrainGenerationWorker.cpp
1>D:\ue4projects\Merkur\ue47pano\Plugins\OceanPlugin\Source\OceanPlugin\Private\Terrain\TerrainGenerationWorker.cpp(31): warning C4996: 'FRunnableThread::Create': Function deprecated. Use FRunnableThread::Create without bAutoDeleteSelf and bAutoDeleteRunnable params and delete thread and runnable manually. Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile.
1>          C:\Program Files\Unreal Engine\4.7\Engine\Source\Runtime\Core\Public\HAL\ThreadingBase.h(263) : see declaration of 'FRunnableThread::Create'
1>  ProceduralTerrain.cpp
1>  FishState.cpp
1>  OceanManager.cpp
1>  BuoyancyMovementComponent.cpp
1>  BuoyancyComponent.cpp
1>  FishManager.cpp
1>  FishFactory.cpp
1>  [25/26] Link OceanPlugin-Static.lib
1>  [26/26] Link ue47pano.exe
1>     Creating library D:\ue4projects\Merkur\ue47pano\Binaries\Win64\ue47pano.lib and object D:\ue4projects\Merkur\ue47pano\Binaries\Win64\ue47pano.exp
1>UELinkerFixups.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl EmptyLinkFunctionForStaticInitializationOceanPlugin(void)" (?EmptyLinkFunctionForStaticInitializationOceanPlugin@@YAXXZ) referenced in function "void __cdecl UELinkerFixups(void)" (?UELinkerFixups@@YAXXZ)
1>D:\ue4projects\Merkur\ue47pano\Binaries\Win64\ue47pano.exe : fatal error LNK1120: 1 unresolved externals
1>  -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: D:\ue4projects\Merkur\ue47pano\Binaries\Win64\ue47pano.exe
1>  Cumulative action seconds (8 processors): 0,00 building projects, 53,40 compiling, 0,00 creating app bundles, 0,00 generating debug info, 7,95 linking, 0,00 other
1>  UBT execution time: 43,39 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""C:\Program Files\Unreal Engine\4.7\Engine\Build\BatchFiles\Build.bat" ue47pano Win64 Development "D:\ue4projects\Merkur\ue47pano\ue47pano.uproject" -rocket" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



Can anyone help me? I’m on 4.7.6 and I get error on Shipping and Development builds. I used as source: https://.com/UE4-//archive/.zip

//edit:
Never mind - I realized I’m only using the skysphere, not any stuff that uses the code… I removed the code and I can compile now. Though, anyone got an idea?

Good Day,

Many Thanks to the initiative.
There is a big problem though with actually building and packaging the project …
When I try to build the project in C++ from Visual Studio 2013 I get the following errors:
Error 1 error RC2135: file not found: …/…/…/…/Build/Windows/Application.ico A:\GIT_HUB\Source\OceanDemo\Resources\Windows\OceanDemo.rc 68 1 OceanDemo
Error 3 error : Failed to produce item: A:\GIT_HUB\Intermediate\Build\Win64\OceanDemoEditor\Development\UE4Editor-OceanDemo.exp A:\GIT_HUB\Intermediate\ProjectFiles\ERROR OceanDemo
Error 4 error MSB3073: The command ““A:\Epic Games\4.7\Engine\Build\BatchFiles\Build.bat” OceanDemoEditor Win64 Development “A:\GIT_HUB\OceanDemo.uproject” -rocket” exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 OceanDemo

From error it seems that you are missing Build/Windows/Application.ico in your project (you can copy that file from another project or from TK branch).

If you guys are using 4.7 I recommend that you use the TK’s-Dev branch since it’s more up to date than .

@ - you are the man! update is sweeet.

Infinite system is one I’ve been looking forward to for a while even though I mostly need it for a lower-priority project.

Glad you enjoy :wink:

Today I made a simple boat wake test.

It basically spawns planes with the same gerstner wave displacement on top of the (you can think of it as decals).
It doesn’t look that great right now but I think with a proper material it might just look believable.

The problem is that the is not being displaced by the boat, if only we could combine with something like the fluid surface plugin… :rolleyes: keeps dreaming


In file included from ../../../../Unreal Projects//Plugins/OceanPlugin/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/UE4Editor/Inc/OceanPlugin/OceanPlugin.generated.dep.h:30:
../../../../Unreal Projects//Plugins/OceanPlugin/Source/OceanPlugin/Classes/Fish/FlockFish.h:115:25: error: implicit conversion of NULL constant to 'float' -Werror,-Wnull-conversion]
        float CustomZSeekMin = NULL;
                             ~ ^~~~
                               0.0


I am curious as to why you use NULL instead of just 0.0?

Fantastic guys, you guys deserved a medal, one is really production ready for the infinite system and the ssr! great job!

I’ve tried two things for wakes.

I tried a particle ribbon approach where the particle’s material was also displaced with the gerstner wave.

I also tried keeping a collection of points (location/time/direction) and drawing to a canvas that is then rendered into the material. Drawing to the canvas was a bit slow once the point collection grew. I also only showed wakes 100m around the camera. did have the ability to displace the waves though and actually create the triangle wave following the boat.

But I was never happy with any on .

by far is an project and open source thanks you!
The waves can sync over network games like in BF4 ?

You mean the war ship steering? yeah unfortunately there are a lot of problems with it, not just with steering.
The problem is that I’m using complex collision (per-poly) and that doesn’t work very well with physics… complex collision is not meant to be movable it seems.

It’s not the torgue.

I made a topic about problem which shows the jittering problem (that was from 4.7, in 4.8 it only has gotten worse :p)
https://.unrealengine.com/showthread.php?68664-Unstable-physics-Per-poly-collision-physics-problem

Yes, I have already implemented a way to sync the waves (check out the custom vehicle controller and BP_Ocean).
All it does is get the time difference between the server and client and then add a time offset on the shader and manager (on the client).

I haven’t done any extensive testing and I don’t know if it’s that accurate but it looks like it works :stuck_out_tongue:

Hey ! good to see you around :wink:

That sounds super interesting :slight_smile: how do you go about displacing the waves exactly?
I would love to take a look at your implementation (if you want to share)! sounds like it would work fine for a single boat at least.

Problems with Packaging project in 4.7.6

Hello,
Impressive job with project.
I am not a coder so I don’t think I can contribute with code to , maybe with 3D assets.
I have an with the plugin. It plays in the editor … but it does not package on my 4.7 version. Is there a special way to install package ? Apart for the usual copy paste of the Plugin folder and then build the C++ project.

The error part of the Log looks like :

MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: A:\PROJECTS\Unreal Projects\TheOld\Plugins\OceanPlugin\Source\OceanPlugin\Private\Terrain\TerrainGenerationWorker.cpp(31) : warning C4996: ‘FRunnableThread::Create’: Function deprecated. Use FRunnableThread::Create without bAutoDeleteSelf
MainFrameActions: Packaging (Windows (64-bit)): and bAutoDeleteRunnable params and delete thread and runnable manually. Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile.
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: A:\Epic Games\4.7\Engine\Source\Runtime\Core\Public\HAL\ThreadingBase.h(263) : see declaration of ‘FRunnableThread::Create’
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: FlockFish.cpp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: BuoyancyMovementComponent.cpp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: BuoyancyComponent.cpp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: FishState.cpp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: FishFactory.cpp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: OceanManager.cpp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: [26/27] Link OceanPlugin-Win64-DebugGame-Static.lib
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: [27/27] Link TheOld-Win64-DebugGame.exe
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: Creating library A:\PROJECTS\Unreal Projects\TheOld\Binaries\Win64\TheOld-Win64-DebugGame.lib and object A:\PROJECTS\Unreal Projects\TheOld\Binaries\Win64\TheOld-Win64-DebugGame.exp
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: UELinkerFixups.cpp.obj : error LNK2019: unresolved external symbol “void __cdecl EmptyLinkFunctionForStaticInitializationOceanPlugin(void)” (?EmptyLinkFunctionForStaticInitializationOceanPlugin@@YAXXZ) referenced in function “void __cdecl UELinkerFixups(void)” (?UELinkerFixups@@YAXXZ)
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: A:\PROJECTS\Unreal Projects\TheOld\Binaries\Win64\TheOld-Win64-DebugGame.exe : fatal error LNK1120: 1 unresolved externals
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: -------- End Detailed Actions Stats -----------------------------------------------------------
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: ERROR: UBT ERROR: Failed to produce item: A:\PROJECTS\Unreal Projects\TheOld\Binaries\Win64\TheOld-Win64-DebugGame.exe
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: Cumulative action seconds (8 processors): 0,00 building projects, 65,63 compiling, 0,00 creating app bundles, 0,00 generating debug info, 3,14 linking, 0,00 other
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: UBT execution time: 45,46 seconds
MainFrameActions: Packaging (Windows (64-bit)): CommandUtils.Run: Run: Took 45,6186092s to run UnrealBuildTool.exe, ExitCode=2
MainFrameActions: Packaging (Windows (64-bit)): ErrorReporter.Error: ERROR: AutomationTool error: Command failed (Result:2): A:\Epic Games\4.7\Engine\Binaries\DotNET\UnrealBuildTool.exe TheOld Win64 DebugGame “A:\PROJECTS\Unreal Projects\TheOld\TheOld.uproject” -noxge -rocket -NoHotReloadFromIDE. See
MainFrameActions: Packaging (Windows (64-bit)): logfile for details: ‘UnrealBuildTool.txt’
MainFrameActions: Packaging (Windows (64-bit)): BuildCommand.Execute: ERROR: BUILD FAILED
MainFrameActions: Packaging (Windows (64-bit)): Program.: ERROR: AutomationTool terminated with exception:
MainFrameActions: Packaging (Windows (64-bit)): Program.: ERROR: Exception in AutomationTool: Command failed (Result:2): A:\Epic Games\4.7\Engine\Binaries\DotNET\UnrealBuildTool.exe TheOld Win64 DebugGame “A:\PROJECTS\Unreal Projects\TheOld\TheOld.uproject” -noxge -rocket -NoHotReloadFromIDE. See
MainFrameActions: Packaging (Windows (64-bit)): logfile for details: ‘UnrealBuildTool.txt’
MainFrameActions: Packaging (Windows (64-bit)): Stacktrace: at AutomationTool.CommandUtils.RunAndLog(String App, String CommandLine, String Logfile, Int32 MaxSuccessCode, String Input, ERunOptions Options, Dictionary2 EnvVars) MainFrameActions: Packaging (Windows (64-bit)): at AutomationTool.CommandUtils.RunUBT(CommandEnvironment Env, String UBTExecutable, String CommandLine, String LogName, Dictionary2 EnvVars)
MainFrameActions: Packaging (Windows (64-bit)): at AutomationTool.UE4Build.BuildWithUBT(String ProjectName, String TargetName, UnrealTargetPlatform TargetPlatform, String Config, String UprojectPath, Boolean ForceMonolithic, Boolean ForceNonUnity, Boolean ForceDebugInfo, Boolean ForceFlushMac, Boolean DisableXGE, String InAddArgs, Boolean ForceUnity, Dictionary2 EnvVars) MainFrameActions: Packaging (Windows (64-bit)): at AutomationTool.UE4Build.Build(BuildAgenda Agenda, Nullable1 InDeleteBuildProducts, Boolean InUpdateVersionFiles, Boolean InForceNoXGE, Boolean InForceNonUnity, Boolean InForceUnity, Dictionary2 PlatformEnvVars) MainFrameActions: Packaging (Windows (64-bit)): at Project.Build(BuildCommand Command, ProjectParams Params, Int32 WorkingCL) MainFrameActions: Packaging (Windows (64-bit)): at BuildCookRun.DoBuildCookRun(ProjectParams Params) MainFrameActions: Packaging (Windows (64-bit)): at BuildCommand.Execute() MainFrameActions: Packaging (Windows (64-bit)): at AutomationTool.Automation.Execute(List1 CommandsToExecute, CaselessDictionary`1 Commands)
MainFrameActions: Packaging (Windows (64-bit)): at AutomationTool.Automation.Process(String] CommandLine)
MainFrameActions: Packaging (Windows (64-bit)): at AutomationTool.Program.MainProc(Object Param)
MainFrameActions: Packaging (Windows (64-bit)): at AutomationTool.InternalUtils.RunSingleInstance(MainProc , Object Param)
MainFrameActions: Packaging (Windows (64-bit)): at AutomationTool.Program.()
MainFrameActions: Packaging (Windows (64-bit)): Program.: ERROR: Command failed (Result:2): A:\Epic Games\4.7\Engine\Binaries\DotNET\UnrealBuildTool.exe TheOld Win64 DebugGame “A:\PROJECTS\Unreal Projects\TheOld\TheOld.uproject” -noxge -rocket -NoHotReloadFromIDE. See logfile for details: ‘UnrealBuildTool.txt’
MainFrameActions: Packaging (Windows (64-bit)): ProcessManager.KillAll: Trying to kill 0 spawned processes.
MainFrameActions: Packaging (Windows (64-bit)): Program.: AutomationTool exiting with ExitCode=2
MainFrameActions: Packaging (Windows (64-bit)): Domain_ProcessExit
MainFrameActions: Packaging (Windows (64-bit)): ProcessManager.KillAll: Trying to kill 0 spawned processes.
MainFrameActions: Packaging (Windows (64-bit)): copying UAT log files…
MainFrameActions: Packaging (Windows (64-bit)): RunUAT.bat ERROR: AutomationTool was unable to run successfully.
MainFrameActions: Packaging (Windows (64-bit)): BUILD FAILED

Does infinite plane work in 4.8 release or are you adding ti in?

I don’t see any plugin error from log, the TerrainGenerationWorker.cpp(31) warning does not prevent from building the project.
I cannot replicate problem no mater what I try, I can package the plugin just fine even when I add to another project.

Which version of the plugin are you using (don’t use branch)? also what are the exact steps you take to package your project? can you package the project without the plugin?

It works :stuck_out_tongue:
However I found a bug with it just yesterday, basically it will cause a crash if your character goes below the level’s kill Z.
I have already fixed it but for now just make sure he doesn’t :wink: I will update the branch soon.

I meant just adds to the displacement output, not to GetWaveHeight.

For the canvas approach I accumulate every boats trace. The green channel is for foam and the red channel is for displacement. Each wake point draws a rectangle that grows over time making the wake stretch out.

The material get a extra wake section that adds to the normal, displacement and foam lerp to the color.

The wake is updated every frame with code


void AOceanManager::UpdateWakeBuffer(float time)
{
	if (!WakeTexture)
		return;

	float maxAge = 10;

	if (WakeCanvas == nullptr && WakeRenderTarget != NULL)
	{
		WakeCanvas = new FCanvas(WakeRenderTarget->GameThread_GetRenderTargetResource(), NULL, GetWorld(),ERHIFeatureLevel::SM5);
		WakeCanvas->Clear(FLinearColor::Transparent);
	}


	WakeCanvas->Clear(FLinearColor::Transparent);
	for (int index = WakeList.Num() - 1; index >= 0; index--)
	{
		FVector location = (WakeList[index].Location / Size) + 0.5f - (Center / Size);

		//WakeCanvas->DrawTile(5, 5, 245, 245, 0, 0, 1, 1, FLinearColor::Red);

		float age = (time - WakeList[index].TimeStamp) / maxAge;
		float inverseAge = 1.0f - age;
		float WakeStartSize = WakeList[index].Size;

		FVector2D shockwaveWakeSize = FVector2D(0.75f * WakeStartSize / Size, ( 0.75f * WakeStartSize / Size)/* * (1 + (2 * maxAge * age))*/);
		FVector2D wakeCenter = FVector2D((location.X - shockwaveWakeSize.X * 0.5f) * WakeRenderTarget->SizeX, (location.Y - shockwaveWakeSize.Y * 0.5f) * WakeRenderTarget->SizeY);
		FCanvasTileItem tile(wakeCenter,
			WakeTexture->Resource,
			FVector2D(shockwaveWakeSize.X* WakeRenderTarget->SizeX, shockwaveWakeSize.Y* WakeRenderTarget->SizeY),
			FVector2D(0, 0),
			FVector2D(1, 1),
			FLinearColor(inverseAge, inverseAge, inverseAge, 1));
		tile.BlendMode = ESimpleElementBlendMode::SE_BLEND_Additive;
		tile.PivotPoint = FVector2D(0.5f, 0.5f);
		tile.Rotation = WakeList[index].Rotation;

		// Shockwave
		tile.SetColor(FLinearColor::Red * inverseAge);
		FVector2D wakeDelta = FVector2D(WakeList[index].Right.X * WakeRenderTarget->SizeX, WakeList[index].Right.Y * WakeRenderTarget->SizeY) *(WakeList[index].Velocity.Size2D() * 2 / Size) * age;
		tile.Position = wakeCenter + wakeDelta;
		WakeCanvas->DrawItem(tile);
		tile.Position = wakeCenter - wakeDelta;
		WakeCanvas->DrawItem(tile);

		//Turbulence
		tile.SetColor(FLinearColor::Green * inverseAge);
		FVector2D turbulenceWakeSize = FVector2D(WakeStartSize / Size, (WakeStartSize / Size)) * (1 + (3 * age));
		tile.Position = FVector2D((location.X - turbulenceWakeSize.X * 0.5f) * WakeRenderTarget->SizeX, (location.Y - turbulenceWakeSize.Y * 0.5f) * WakeRenderTarget->SizeY);
		tile.Size = FVector2D(turbulenceWakeSize.X* WakeRenderTarget->SizeX, turbulenceWakeSize.Y* WakeRenderTarget->SizeY);
		tile.Texture = TurbulenceTexture->Resource;
		WakeCanvas->DrawItem(tile);

		if (age >= 1.0f)
		{
			WakeList.RemoveAt(index, 1);
		}
	}

	WakeCanvas->Flush_GameThread();

}

I am not very fond of implementation though.

I suggest trying the new HACD collision volume gen on the ship - I bet it can give you a reasonable approximation if you set it to be able to use enough hulls. That should be better than using “complex as simple” which isn’t great for a lot of reasons.

Wow… I would have not though of that to be honest… thanks for sharing your method :wink:

gives me a few ideas, I will report back if manage to make it work :stuck_out_tongue:

Unfortunately no, the new convex collision generator is much better but there is no way it can ever handle the interior of a ship, it’s too complex for automatic collision :stuck_out_tongue: plus even if it could it’s too inefficient, it would be an amount of collision primitives (not good for performance).

The only alternative that I see right now is to manually place/scale collision shapes inside the SM editor, but it’s a bit lengthy process.

Kinda like (a quick test I made a while ago entirely by boxes and couple of capsules):

http://oi61.tinypic.com/2rh30as.jpg

But only worked because it’s a much simpler/smaller ship, without interior :stuck_out_tongue:

Also using per-poly collision turns out to not only be accurate but it’s also better performance wise, the only problem is the jittery physics.

Hi my hero,
You are just super cool when creating plugin for UE community.
I tried and found plugin not working well with UE4.8 integrated with Nvidia GameWorks (guess due to VXGI) the surface looks like missing shader. But one works pretty well with UE4.8 not integrate with GameWork. Any ideas to deal with ?

Another one, I feel if the shore gets wet when the wave chopping to the shore, it’s kind of wet map, it’s definitely a big thumb up

Hi,

I have some questions about plugin. I want to make a game with ship, so it perfect.

  1. Am I free to use it in my own project and maybe distribute it in my game (if it becomes a cool game)?
  2. When I try to download the files, they all are .uasset-files, but I can’t import them. How do you do ?

I hope to hear anything soon, becaue project is really cool!