FFT-Ocean
Fast Fourier Transform ocean waves simulation for Unity. This is a prototype. Not recommended for real projects.
Fast Fourier Transform ocean waves simulation for Unity. This is a prototype. Not recommended for real projects.
Hi. Really nice work.
However I notice rendering artefacts on top/right edge of each Ring. It is present both in the Editor and in the gameview. Looks like it is off by one?
Really nice work. I have been working on FFT ocean waves in UE4 for a couple of weeks. I really appreciate you since I referred to your repository heavily. But now I am struggling with normals when putting cascaded waves together. I don't understand why it works. How do you compute normal from derivatives?
float4 derivatives = tex2D(_Derivatives_c0, IN.worldUV / LengthScale0);
#if defined(MID) || defined(CLOSE)
derivatives += tex2D(_Derivatives_c1, IN.worldUV / LengthScale1) * IN.lodScales.y;
#endif
#if defined(CLOSE)
derivatives += tex2D(_Derivatives_c2, IN.worldUV / LengthScale2) * IN.lodScales.z;
#endif
float2 slope = float2(derivatives.x / (1 + derivatives.z),
derivatives.y / (1 + derivatives.w));
float3 worldNormal = normalize(float3(-slope.x, 1, -slope.y));
o.Normal = WorldToTangentNormalVector(IN, worldNormal);
Hello
Could you please refer me to sources on your ocean spectrum equations? I am not familiar with half of whats going on for your InitSpectrum shaders.
I am very familiar with Tessendorf's initial spectrum math but you don't seem to be using that one. You seem to be using multiple functions i am unfamiliar with and there is a lot of magic numbers with no explanations for them also.
Hi! I was wondering if you planned to convert the "Ocean" shader to URP 🙏 Or you can help me to do so?
Best,
Hi
Me again, I've slowly been learning the math for this as I want to understand it before I use it.
I read tessendorf's paper but wanted to ask something about the complex number generation for the Fourier amplitudes.
For h0 it is defined as : 1/sqrt(2) * (a + ib) * sqrt(Phillips(kVector));
And h0* (the conjugate) is: 1/sqrt(2) * (a - ib) * sqrt(Phillips(kVector));
Does the conjugate h0* use the same a and b values as the h0 term (but b is negative) or do you generate a second complex number entirely?
Hey, me again.
I've so far got most of the FFT understood now but I am confused by some parts of your code.
You have permute shader which I don't know what that is or where it comes from? I see no mention of it in Tessendorf.
Also your scale shader pass is also confusing you have:
void Scale(uint3 id : SV_DispatchThreadID)
{
Buffer0[id.xy] = Buffer0[id.xy] / Size / Size;
}
This equates to (xy*Scale) / Scale which basically simplifies to xy so you're not scaling anything since scale/scale =1..?
Shouldn't it be:
[numthreads(8, 8, 1)]
void Scale(uint3 id : SV_DispatchThreadID)
{
Buffer0[id.xy] = Buffer0[id.xy] / (Size * Size);
}
I am basing it on this iDFT equation:
Also i am very confused by the cascade stuff, does each cascade require its own FFT for DY DX DZ ? How did you chose the numbers:
[SerializeField]
float lengthScale0 = 250;
[SerializeField]
float lengthScale1 = 17;
[SerializeField]
float lengthScale2 = 5;
Are these numbers arbitrary or is there a calculation you made to determine the ideal cascade scales?
Thanks!