gasgiant / fft-ocean Goto Github PK
View Code? Open in Web Editor NEWFFT ocean for Unity
License: MIT License
FFT ocean for Unity
License: MIT License
Thank you, this is a great model! Really beautiful result! I would be interested in changing the JONSWAP spectrum with a custom wave spectrum, is there a way to isolate the contributions from JONSWAP? I notice it being explicitly called in WaveSettings, but I want to be sure I have also edited all of the other dependencies that assume a specific spectrum
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,
First thanks for this beautiful code and video.
I have a question regarding the function that get the water height in CPU : WaveGenerator::GetWaterHeight()
.
How does it works ? Why is it not just the sum of the height of all cascades ?
Thanks in advance
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!
Hi,
In compute shader WavesTexturesMerger.compute
where does this calculation comes from :
Turbulence[id.xy] = Turbulence[id.xy].r + DeltaTime * 0.5 / max(jacobian, 0.5);
Turbulence[id.xy] = min(jacobian, Turbulence[id.xy].r);
I see it's used for foam rendering, but I don't fully understand how it works.
Thanks in advance.
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?
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);
Hi!
I was wondering if you planned to convert the "Ocean" shader to URP ๐
Or you can help me to do so?
Best,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.