white caps, swell height and waves ?


24-08-2010 05:48:12

Hello There,

Am asking if there is a possible to do a white-caps in hydraX ? is is possible to use collision technique to make white-caps ...?

and Can I set the height for waves(swells) and period of each wave(swell) ....?



24-08-2010 11:24:42

The period and height of waves could be managed using FFT noise (probably you are using Perlin noise), and editing it to use the frecuencies and amplitudes that you want (don't forgive let the FFT to add some random sub-waves aiming to better visual results).

White caps... i think that you must manage it with textures (as the foam), that is a little bit complex method (you could try to create a second thread that make it).

Waiting your news!


24-08-2010 14:28:01


Thanks for your reply.

Yes currently i'm using perlin, IF i'm using mFFt and it's requirey Options could you advice me which values that control the waves height and period on that constructer.
i.e. could you show me a small sample if you don't mind :)



24-08-2010 15:33:54

This is the piece of code that you must edit:

void FFT::_initNoise()
initialWaves = new std::complex<float>[resolution*resolution];
currentWaves = new std::complex<float>[resolution*resolution];
angularFrequencies = new float[resolution*resolution];

re = new float[resolution*resolution];
img = new float[resolution*resolution];

Ogre::Vector2 wave = Ogre::Vector2(0,0);

std::complex<float>* pInitialWavesData = initialWaves;
float* pAngularFrequenciesData = angularFrequencies;

float u, v,

for (u = 0; u < resolution; u++)
wave.x = (-0.5f * resolution + u) * (2.0f* Ogre::Math::PI / mOptions.PhysicalResolution);

for (v = 0; v < resolution; v++)
wave.y = (-0.5f * resolution + v) * (2.0f* Ogre::Math::PI / mOptions.PhysicalResolution);

temp = Ogre::Math::Sqrt(0.5f * _getPhillipsSpectrum(wave, mOptions.WindDirection, mOptions.KwPower));
*pInitialWavesData++ = std::complex<float>(_getGaussianRandomFloat() * temp, _getGaussianRandomFloat() * temp);

temp=9.81f * wave.length();
*pAngularFrequenciesData++ = Ogre::Math::Sqrt(temp);


You could see that you have resolution x resolution waves, you could perform some of them manually.



24-08-2010 17:02:30


thanks for that. I'm actually using mHydrax.dll library(for MOGRE), so I don't think I can modify that.

Firsly, Can I use both perlin and noise as there are many features in perlin and I want to use it ...............?

Secondly, is there a way to override the default function with new one in my current class ...?

and lastly, regardless to resolution, I just put any value for try ..?




25-08-2010 16:20:27


First for all, the resolution should be a power of 2 value (better options to perform Fast Fourier Transforms).

Concern to use FFT+Perlin+Dominant waves, probably your best choice is to create your own noise module (that don't need recompile Hydrax). To do it you must follow the next steps:

1.- Copy from the Hydrax source code the FFT.cpp and FFT.h files into your project, and rename they to CustomNoise.cpp & CustomNoise.h.
2.- Edit the files to replace all ocurrences of FFT word by CustomNoise word.
3.- Add all the features of Perlin (that you could take from Perlin.cpp & Perlin.h)
4.- Add your dominant sea waves code.
5.- In your app, when you start Hydrax, you have an code similar to the next:

// Create Hydrax object
Hydrax = new Hydrax::Hydrax(mSceneMgr, mCamera, mCamera->getViewport());

// Create our projected grid module
Hydrax::Module::ProjectedGrid *mModule
= new Hydrax::Module::ProjectedGrid(// Hydrax parent pointer
// Noise module
new Hydrax::Noise::Perlin(/*Generic one*/),
// Base plane
Ogre::Plane(Ogre::Vector3(0,1,0), Ogre::Vector3(0,0,0)),
// Normal mode
// Projected grid options
Hydrax::Module::ProjectedGrid::Options(/*264 Generic one*/));
// Set our module

// Load all parameters from config file
// Remarks: The config file must be in Hydrax resource group.
// All parameters can be set/updated directly by code(Like previous versions),
// but due to the high number of customizable parameters, Hydrax 0.4 allows save/load config files.

Hydrax::Mesh::Options MeshOptions = Hydrax->getMesh()->getOptions();
Hydrax->getMesh()->setOptions(Hydrax::Mesh::Options(MeshOptions.MeshComplexity, Hydrax::Size(300000, 300000), MeshOptions.MeshStrength, MeshOptions.MeshVertexType));

// Create water

Where you must replace the line:

new Hydrax::Noise::Perlin(/*Generic one*/),


new Hydrax::Noise::CustomNoise(/*Generic one*/),

Good luck!

Jose Luis Cercós Pita


25-08-2010 19:45:50

0111, I guess you'll have to recompile Hydrax and then build MHydrax on top of that. Not very pleasant thing to do :)