Community Tutorial: Ocean Simulation

This tutorial will guide you through the process of making ocean simulation system in Niagara

https://dev.epicgames.com/community/learning/tutorials/qM1o/unreal-engine-ocean-simulation

17 Likes

Sir ! i think u drops this :crown:

3 Likes

Hello Sir , I am following the tutorial of ocean simulation but I am stuck at texture part .
I download your project files and but the textures are black (in the folder of [all > content > OceanWater > RenderTargets > Pixels] ).

So, how can I get these textures for creating the ocean . Please sir help me to find these textures as soon as possible
Thank you
IndieDev

Good day. These are not textures, but render targets. They will be populated, when the system is running.

Thank you for this amazing tutorial! Still trying to wrap my head around it.

This might be a stupid question since Iā€™m just getting started with UE, but is this right
vector5

Whatā€™s the result of this? A vector 5? Is that even possible?

I also noticed that the downloadable project has more modules. Are FX_OceanWater_Tick4WaveGroups, FX_WrapGroupIndex, FX_OceanWater_CrossFadeWaveGroups, FX_OceanWater_PopulateWaveGroups used anywhere?

Also foam parallax is calculated differently in the tutorial and project:


Which one is correct?

Finally, I think the tutorial didnā€™t mention how to set all those parameters on the object itself. The default values will work but wonā€™t look as good.
(not allowed to post more than one pic per post, sorry)

Whatā€™s the result of this? A vector 5? Is that even possible?

Result of that is Vector 4. Top pin contains red, green and blue channels, bottom pin contains alpha channel.

Are FX_OceanWater_Tick4WaveGroups, FX_WrapGroupIndex, FX_OceanWater_CrossFadeWaveGroups, FX_OceanWater_PopulateWaveGroups used anywhere?

No, they are part of of dynamically adjusting ocean state and hopefully will be used in follow-up soon. Thanks for pointing out, I removed them from the project.

Which one is correct?

Technically, the one with division is correct, but on the grand scene of things, it is not that relevant.

Finally, I think the tutorial didnā€™t mention how to set all those parameters on the object itself.

Indeed. User parameters can be adjusted on an instance of niagara system component, which you have dropped into the level. I will add that part.

5 Likes

Oh wow, I think you are right. This is different from a Constant4Vector
const4

Sorry, I know this is a real beginner question but how can you tell how many components the first pin has without hooking it up to another node that expects a float4? There is no tooltip and nothing in the help. And why is this different from a const4?

In UE5.2, Iā€™m getting the following errors. Any idea how to fix those?

System failed to compile with 5 warnings and 9 errors.
D3DCompileToDxil failed. Err0r code: Unspecified Err0r (0x80004005). WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:1518:6: Err0r: no matching function for call to 'SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc3'
	            SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc3(float2(CascPosX[3], CascPosY[3]), SampleValues[3]);
	            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:1517:6: Err0r: no matching function for call to 'SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc2'
	            SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc2(float2(CascPosX[2], CascPosY[2]), SampleValues[2]);
	            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:1516:6: Err0r: no matching function for call to 'SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc1'
	            SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc1(float2(CascPosX[1], CascPosY[1]), SampleValues[1]);
	            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:1515:6: Err0r: no matching function for call to 'SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc0'
	            SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc0(float2(CascPosX[0], CascPosY[0]), SampleValues[0]);
	            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:605:6: note: candidate function not viable: requires 3 arguments, but 2 were provided
	void SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc3(float2 In_UV, float In_MipLevel, out float4 Out_Value);
	     ^ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:1494:6: Err0r: no matching function for call to 'SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc3'
	            SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc3(float2(CascPosX[3], CascPosY[3]), SampleValues[3]);
	            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:604:6: note: candidate function not viable: requires 3 arguments, but 2 were provided
	void SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc2(float2 In_UV, float In_MipLevel, out float4 Out_Value);
	     ^ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:1493:6: Err0r: no matching function for call to 'SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc2'
	            SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc2(float2(CascPosX[2], CascPosY[2]), SampleValues[2]);
	            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:603:6: note: candidate function not viable: requires 3 arguments, but 2 were provided
	void SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc1(float2 In_UV, float In_MipLevel, out float4 Out_Value);
	     ^ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:1492:6: Err0r: no matching function for call to 'SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc1'
	            SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc1(float2(CascPosX[1], CascPosY[1]), SampleValues[1]);
	            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:602:6: note: candidate function not viable: requires 3 arguments, but 2 were provided
	void SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc0(float2 In_UV, float In_MipLevel, out float4 Out_Value);
	     ^ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:1491:6: Err0r: no matching function for call to 'SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc0'
	            SampleRenderTargetValue_Emitter_RT_PixelAttribs_Casc0(float2(CascPosX[0], CascPosY[0]), SampleValues[0]);
	            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WaterSim, Particle GPU Compute Script, 
/Engine/Generated/NiagaraEmitterInstance.ush:654:23: warning: ambiguous type for bit shift; use a type suffix on literal values, like 'L' or 'U', or a cast [-Wambig-lit-shift]
	        int sectionWidth = 2 << passIndex;
	                             ^ WaterSim, Particle GPU Compute Script, 

Update: Seems as if you have to pass the mip level now as 2nd parameter for the SampleRenderTargetValue lines in the RoughnessIntegrator like this:

RT_PixelAttribsA_Casc0.SampleRenderTargetValue(float2(CascPosX[0], CascPosY[0]), 0.0f, SampleValues[0]);

This makes it compile in 5.2 but the visuals are still completely broken.

1 Like

It has something to do with the data interface setup in the generic simulation stages.

In UE5.2, you cannot longer select a dispatch type when you select Data Interface as Iteration Source (The Override Gpu Dispatch Type checkbox is gone).

Instead, there is now a new Iteration Source called ā€œDirect Setā€. Problem with Direct Set is, that you canā€™t specify a Data Interface anymore.

If you set everything to Data Interface in 5.2, you get something that looks mostly right but itā€™s extremely slow.

Update: The bug is that it ignores the ā€œOverride Gpu Dispatch Num Threadsā€ setting in ā€œDirect Setā€ mode in 5.2. Iā€™ve made a bug report on UDN: https://udn.unrealengine.com/s/question/0D54z000096cseXCAQ/niagara-generic-simulation-stage-gpu-dispatch-override-is-being-ignored-in-direct-set-mode-in-52

2 Likes

This is incredibly generous of youā€¦ thank you very much.

I think the tutorial is a bit above my head, but the project fileā€¦ thatā€™s the best looking realtime ocean Iā€™ve seen yet.

Thanks again.

Yes, Ive contacted niagara developers regarding this and hopefully they will include a fix in 5.2.

2 Likes

Thanks buddy for tutorial and your help

Hi, I am Korean. Please understand even if my English is not good.
Iā€™m trying to get the project and use it, but I got that error
Iā€™ve read all the tutorials, and Iā€™ve applied the ones I covered in 7, 8, and 9, but I canā€™t
Can you tell me why?


if you download project from github and set path for those 4 modules (unless you like to follow tutorial) as explained it works straight away in 5.1 but not in 5.2 or later, for now. Hopefully fix will come. Ocean looks very cool, havent seen anything more realistic

Theyā€™ve fixed it already!

1 Like

Yes, its working , but still applied your fix

RT_PixelAttribsA_Casc0.SampleRenderTargetValue(float2(CascPosX[0], CascPosY[0]), 0.0f, SampleValues[0]);

@ Deathrey
Default plane size is set to 1.0, when experimenting with bigger size to fill whole map waves are not as good looking, so Ive placed few planes on the map together, they overlap nicely. Would there be better or more efficient way of achieving same result but covering whole map? Current size is set to 50.0 and i adjusted some params to have slightly smaller waves. Thank you

Yeah, I get these same errors and have no idea why they are popping up.

Any assistance would be much appreciated.

Of course, you need a system to have adaptive geometry for larger ocean. You could use the one which comes with Unrealā€™s water system, Ocean water body, or you can make one using niagara mesh particles. Hopefully I will have time in nearest future to cover that topic, along with physics.

1 Like

Which errors are you getting and on what engine version ?