[Community Project] WIP Weather & Water Shader

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

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 vector parameter directly to material?
2 - How can I clean up the project to get ONLY the 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 manager to make all that i describe above?
5 - I have GTX 970 and here ULTRA Shader runs around 23 fps. That is because or ALL other things in project?

Thank You.

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

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

2)You can delete any content folder that you donā€™t need and simply keep the 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.

  1. Itā€™s not possible to use vertex painting if you want to also use the infinite system since it moves and scales the 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.
  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 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 plane has).
    [/QUOTE]

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.

2)You can delete any content folder that you donā€™t need and simply keep the 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.
[/QUOTE]

I cant use my own skydome? I think its because the caustics right?

  1. Itā€™s not possible to use vertex painting if you want to also use the infinite system since it moves and scales the 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.
    [/QUOTE]

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 Material? That is a material that only you 2 can understand now.
I asked 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 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.

Like I saidā€¦ you canā€™t do all the math on the CPU because not only you would need to pass thousands of vector parameters (one per vertex) which is ridiculous and not possible :stuck_out_tongue: but also doing the calculations on the GPU is a lot faster.

You can! you will just have to copy the blueprint part which updates the sun vector to your own skydome (I will try and post more details on that later). Itā€™s fairly easy to do.

Again, you canā€™t do that because the vertex painting is based on the mesh UVs but since the mesh is constantly being moved and scaled by the infinite system (and therefore the UVs) you canā€™t use vertex painting so you would have to either make something like a larger static plane or use a similar technique which is used for the landscape heightmap (itā€™s basically a texture mapped in world space really).

I would like to further optimize and simplify the material at some point of course but thatā€™s not high priority for me.

is not ignoring you on purpose or anything :stuck_out_tongue: he has not been active for quite some time due to health problems (he had complications with his back surgery), I havenā€™t talked him since September or so so unfortunately I have not any recent information.

Distance field foam and displacement is on my to-do list.

is welcome to contribute to the project of course!
You can make a pull request, post snippets of your material or pm me.

Code is not Formula? With features to Rotate?

c822b522a9ddfa20a2cb4f5b36ed816e6cf32fb0.jpeg

If I plug the result of code on a Displacement pin inside material, the plane will not have ONE WAVE?



FVector AOceanManager::CalculateGerstnerWaveVector(float rotation, float waveLength, float amplitude, float steepness, const FVector2D& direction, const FVector& position, float time, FWaveCache& InWaveCache, bool CalculateXY, bool CalculateZ) const
{
	float frequency = (2 * PI) / waveLength;

	FVector dir;
	if (!InWaveCache.GetDir(rotation, direction, &dir))
	{
		dir = FVector(direction.X, direction.Y, 0);
		dir = dir.RotateAngleAxis(rotation * 360, FVector(0, 0, 1));
		dir = dir.GetSafeNormal();
		InWaveCache.SetDir(rotation, direction, dir);
	}

	float wavePhase = frequency * FVector::DotProduct(dir, position) + time;
	float c = 0, s = 0, QA = 0;

	//FMath::SinCos(&s, &c, wavePhase);

	if (CalculateXY)
	{
		c = FMath::Cos(wavePhase);
		QA = steepness * amplitude;
	}

	if (CalculateZ)
	{
		s = FMath::Sin(wavePhase);
	}

	return FVector(QA * dir.X * c, QA * dir.Y * c, amplitude * s);
}


You mean run that code on the CPU and then pass the result in the material via a vector parameter?

If so then no! that wonā€™t work of courseā€¦ that would compute the displacement for only one position not for all vertices (each vertex has itā€™s own world position so the calculations needs to be done per vertex).

Look the parameters of Wave functionā€¦ Unless the ā€œABSOLUTE WORLD POSITIONā€ node, is ā€œper vertexā€ not by object.
PBWLfpm0K0o

I Will try at night. :wink:

Okay I know that Iā€™m not the best at explaining things butā€¦ **** you are gonna drive me mad lol xD I think you are confused about a few things :smiley:

And yes, absolute world position gives the position of the vertex in case.

So here is my confusion then. :wink: Solved.

So, with that at each frame, the ā€œmaterialā€ will run all the code on nodes for each vertex, in something like that sequence?
PgiWgIW.jpg

Sorry for that. Iā€™m that kind of guy that know how to make some things, but donā€™t know why.

Yes, it basically does a ā€œfor loopā€ through all vertices and computes whatever you plug into world displacement for each individual vertex.

Absolute world position will return the vertex position when something is executed in the vertex shader (world displacement) or the pixel position (always in world space) if it is executed in the pixel shader (diffuse, normal, roughness etc.).

Is there still a blueprint only version of (even if it isnā€™t fully featured for the sake of performance)?

So the source code compiles fine under 4.11 who was working on shaders can you please PM or post what needs to be fixed and what youve fixed so I can get started on that.

Here you go.

These are still for the Gaussian DOF only, I plan to update everything else that needs to use the custom depth (like Bokeh DOF, atmospheric fog etc. I believe the new capsule shadows would need that as well to work on the ) but I donā€™t know when I will find time to do that :p.

I have, i when i change color of directional light and sky light and hit build lighting it resetsā€¦

Hey, is a great project. Thanks a lot for the time it took to make it. A quick question, though. How do you get the fog effect under the water? Iā€™ve tried to dissect the provided level and it seems to be a part of the BP_ocean actor. However, Iā€™ve copied itā€™s variables and setup identically in my own level and there are no PP or fog under the water. What am I missing? Iā€™ve spent 3 hours trying various things to no avail. Thanks for your time,

Yeah seems to be confusing a lot of people :stuck_out_tongue:
You most likely havenā€™t enabled the stencil buffer in your project since itā€™s disabled by default.

Edit > Project Settings > Rendering > Custom Depth-Stencil Pass = Enabled with Stencil

I recommend that you read a few pages back next time when you have issues like , you might often find the answers you are looking for.

Iā€™ll work on what I can and compare the old shaders to the new and see what happens, im not a shader expert especially when it comes to HLSL shaders versus GLSL,

Thanks for the help, but I tried that already and it made no difference. I have read 4 or so pages back and the first couple pages as well, and none of the posts have solved for me. Very curious indeed. Any other things I could be missing?