wave-harmonic / crest

A class-leading water system implemented in Unity
MIT License
3.49k stars 478 forks source link

Beaufort scale #416

Open accio84 opened 4 years ago

accio84 commented 4 years ago

Hi, is it possible to set the state of the sea with the levels of the beufort scale? I need different states of the sea. Thank you

huwb commented 4 years ago

We don't have that explicitly at the moment.

The approach for this would be to set up different wave conditions for different wind speeds, then have multiple gerstner input game objects and blend using the Weight parameter. So one could cross blend between them to smoothly vary conditions. Does this makes sense?

I'll discuss with my colleagues about making this better supported in the future.

daleeidd commented 4 years ago

I had this laying around. It uses the provided Phillips spectrum function. Not sure if it suitable for production though (blending weights mentioned above is probably a better approach):

using UnityEngine;
using Crest;

public class WindForSpectrum : MonoBehaviour {
  public ShapeGerstnerBatched gerstner;
  [Range(0, 120)] public float windSpeed;
  float WindSpeedInMetersPerSecond { get => windSpeed / 3.6f; }
  public float speed;

  void Start() {
    var spectrum = gerstner._spectrum;
    spectrum._windSpeed = 0;
    spectrum.ApplyPhillipsSpectrum(spectrum._windSpeed, spectrum._smallWavelengthMultiplier);
  }

  void Update() {
    var spectrum = gerstner._spectrum;
    var oldWindSpeed = spectrum._windSpeed;
    spectrum._windSpeed = Mathf.MoveTowards(spectrum._windSpeed, WindSpeedInMetersPerSecond, speed);
    if (oldWindSpeed == spectrum._windSpeed) return;
    spectrum.ApplyPhillipsSpectrum(spectrum._windSpeed, spectrum._smallWavelengthMultiplier);
  }
}

It isn't a Beaufort Scale by any means since Beaufort covers foam. We would need to include normal maps too since the first integer is "glassy". It is a great standard to measure ocean renderers against and I would love to see it added one day too.

huwb commented 4 years ago

@daleeidd agreed, do you want to add a task to our list?

accio84 commented 4 years ago

Thanks for support :)

Il giorno ven 7 feb 2020 alle 11:09 daleeidd notifications@github.com ha scritto:

I had this laying around. It uses the provided Philips spectrum function. Not sure if it usable for production though:

using UnityEngine;using Crest; public class WindForSpectrum : MonoBehaviour { public ShapeGerstnerBatched gerstner; [Range(0, 120)] public float windSpeed; float WindSpeedInMetersPerSecond { get => windSpeed / 3.6f; } public float speed;

void Start() { var spectrum = gerstner._spectrum; spectrum._windSpeed = 0; spectrum.ApplyPhillipsSpectrum(spectrum._windSpeed, spectrum._smallWavelengthMultiplier); }

void Update() { var spectrum = gerstner._spectrum; var oldWindSpeed = spectrum._windSpeed; spectrum._windSpeed = Mathf.MoveTowards(spectrum._windSpeed, WindSpeedInMetersPerSecond, speed); if (oldWindSpeed == spectrum._windSpeed) return; spectrum.ApplyPhillipsSpectrum(spectrum._windSpeed, spectrum._smallWavelengthMultiplier); } }

It isn't a Beaufort Scale by any means since Beaufort covers foam. We would need to include normal maps too since the first integer is "glassy". It is a great standard to measure ocean renderers against and I would love to see it added one day too.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/crest-ocean/crest/issues/416?email_source=notifications&email_token=AB2LSDFIZKVPGF4YGSZ5LH3RBUXMPA5CNFSM4KO4FNL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELCMUSA#issuecomment-583322184, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2LSDGVZH6223FE7T2GTG3RBUXMPANCNFSM4KO4FNLQ .

-- Marco Vetrano

CTO - Cal-Tek Srl Spin-off Company of University of Calabria Via P. Bucci 45C, 87036 Rende (CS), Italy Cel. +39 3426237363 Tel. +39 0984 494891 Fax +39 0984 494673 url: www.cal-tek.eu

Informativa Privacy - Ai sensi del D. Lgs n. 196/2003 (Codice Privacy) si precisa che le informazioni contenute in questo messaggio sono riservate e ad uso esclusivo del destinatario. Qualora il messaggio in parola Le fosse pervenuto per errore, La preghiamo di eliminarlo senza copiarlo e di non inoltrarlo a terzi, dandocene gentilmente comunicazione. Grazie. Privacy Information - This message, for the D. Lgs n. 196/2003 (Privacy Code), may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.