Best method to change hydrax water colour related to ambient

Netskate

18-10-2008 14:13:41

So, to make it shorts...

I want to change water colour... if is night, water had to be more dark, else it had to be more bright.

Which method to do this?

I have implemented one, but I'm not sure if it's the best (probably not) and if it is too heavy (seems not to be). So I would know your thought.

Premise I use caelum, then I have a sun with a position, but this can be applied to another light source in movement like a sun.

The idea is to have a watercolour that is costant, as xavi told, water is always of the same colour.

So what we had to change is the brightness of that colour...

Then I implemented two methods:



static Ogre::ColourValue rgbToHsl(Ogre::ColourValue rgb); // Transform a rgb colour into hsl coordinates (r = hue, g = saturation, b = lum)
static Ogre::ColourValue hslToRgb(Ogre::ColourValue hsl); // Transform a hsl colour into rgb coordinates


first I convert the rgb water color to hsl model, then I increment and decrease the lum value in base of the sun position, (for this I make an interpolation from max and min value of brightest and darkest colour) then reconvert the hsl colour (with lum value updated) to rgb and set it to hydrax->setwatercolour();

this operation is done at every frame, or each 0.5 seconds (it's not important, depending to be realistic, from the sun's speed)

So I would know if this is a good not-too-heavy method in your opinion, and if there's something better than this.

Xavyiy

18-10-2008 14:56:24

I think it's a good method if it works as expected for you.
It's not-too-heavy, it needs only some operations, anything comparing with Hydrax, PU, or Ogre calculations per frame.
;)

P.D.: Had the refraction fix .cpp solve the issue?

Netskate

18-10-2008 15:18:00

it works perfectly, and colour is very natural, so I think I'll continue to use it.

Another problem (integrating hydrax with caelum) is that when is cloudy, sun shouldn't reflects on water. I can make this, and I can also make it to show on water only if it's under the cloud's level height. The only problem is the transition between "sun reflect on the water" on/off, but these are details.

If you had used ColourValue instead of Vector3 to set sun colour reflection on hydrax, I could solve this using alpha value, making it transparent and step by step opaque to appear.

ps: I haven't the time now for try this, I'll try it tonight, I had to go now, sorry.

ps2: thanks a lot, I gave you a lot of works on this forum lately :P

Netskate

19-10-2008 14:19:49


If you had used ColourValue instead of Vector3 to set sun colour reflection on hydrax, I could solve this using alpha value, making it transparent and step by step opaque to appear.


so, there's a reason to use vector3 instead of colourValue? An implementation of this, could be much appreciated

Xavyiy

19-10-2008 15:10:25

Hi,
Yes, there is a reason.
In shaders, all possible optimizations are needed.
Hydrax is Shader Model 2.0 capable, that have a limitation of 64 instructions per fragment program.
So, if all calculations are done using float4(ARGB) colours instead of float3(RGB), shaders performance must be decreased and it's possible that shaders won't compile under SM 2.0 profile.

Xavi

Netskate

19-10-2008 15:26:38

ok, I'll find another way to do this

nitrooxide3

30-12-2008 19:49:42

could you post contents of the conversion methods because i have not been able to find a good conversion code on the net, thanks

Netskate

30-12-2008 20:12:59

I think you can find more info to implement you own method into this thread: viewtopic.php?f=20&t=8458

feel be to ask for any doubt