Math question for surf

Started by Dune, August 26, 2022, 01:56:18 AM

Previous topic - Next topic

Dune

I am trying to figure out how to obtain a smooth sawtooth curve, with the steep end pointing at a certain direction (in this case; shallow water). Math was always my weakest, so maybe one of you can help me out. Also, the formulas found need to be translated to TG functions.
Here's a formula for a smooth sawtooth: p(x)=x(1−x2n) , where n gives the sharpness of the sawtooth curve. I guess p to be the height. I think n should be derived from the underlying ground, so if that's higher (nearer coast), the sawtooth gets sharper. It would be awesome if a transition could be made from sinus to sawtooth, based on underlying ground altitude.
I will get to work with this, but any TG translations of this would be most welcome.

Dune

Two tests with surf.

Hannes

Amazing!!!
Regarding your questions: I have not the slightest idea... ???

aknight0

Did you figure it out?  The test looks really cool!

mhaze


Dune

Haven't figured it out yet, but using an extra normal in the waterline (in combination with waves and transparency/reflectivity) makes rendering very, very slow is one conclusion. And redirect or vdisp without a normal won't work, unless for only one direction, not globally.
What I'm now aiming for is isolate a part of the sinus curve. The low trough can be flattened by a smooth max for more distance between upper curves, but then a soft area is needed, as in the sketch, to steepen that side of the curve. Probably very simple, but didn't find it yet.

aknight0

Looking at your shape there brought to mind this sand dune tutorial from years back.  Very similar shape.  Might work for waves too?  https://planetside.co.uk/forums/index.php/topic,18400.msg178752.html#msg178752

WAS

I don't think this is actually sawtooth, but just a sinus frequency. Saw tooth is cubic, so no gradual build-up to a peak. It'd be cubic increments to the peak. Note the uploaded image.

I already put together a function which has the frequency lean and drop-off awhile ago. You can lean either direction. But to lean towards the shore, or shallow water, you'll need to derive a vector from the ground. Which as we know, is not possible without exporting a vector map of the underlying terrain.

I was just doing similar programming for Disco Diffusion Cutn scheduling, where we wanted to convert cubic sawtooth scheduling to eased sinus. To simulate this in cubic restrictions, we just incremented at each float value to make it look like a sinus wave.

Dune

Thanks guys. I probably have those functions somewhere, I'll look those up again.
I have been trying to get a cheap method to lean in coastal directions, and can't grasp why it is not possible to get the vectors from a terrain for use as vdisp without rendering/exporting it first. But with a compute normal a lean can be laterally displaced to coast, but takes longer. In fact, even with just a vdisp/twist and shear (and no compute normal) it takes twice as long as without.
Or indeed locally with a twist and shear or vector displacement. And I realized it's not even important for stills to have the lean everywhere. Just for animations, and even then it can be animated.
I'll leave it be for a while.

WAS

Yeah this is a real limitating factor for a lot of stuff. Ans from what I can this sort of functionality was present in Terragen classic, judging by the plugins for literal water interaction with shores as far as foam and waves and stuff. 

Perhaps this will be possible when Matt gets in global texture export for microexporter. Maybe some new data can be exposed for vectors from other surfaces. 

Targeting different objects and capturing data from them to use with other objects seems to be incredibly useful, and already needed for a lot. With it we could do anything, including collision functions and stuff. 

Dune

Indeed. I very much wonder what Matt is up to..... (regarding TG).