I have a program where I need to represent height as an RGBT (in float) value. That is:
[R, G, B, T (Transperancy)] -> [0.0f-1.0f, 0.0f-1.0f, 0.0f-1.0f, 0.0f-1.0f]
Conceptually I know that you can encode via basic height between max and min height. I even have some code for greyScale height encoding:
double Heightmin=0;
double Heightmax=23;
osg::Vec4 getColourFromHeight(double height, double alpha=1.0) {
double r=(height-Heightmin)/Heightmax;
double b=(height-Heightmin)/Heightmax;
double g=(height-Heightmin)/Heightmax;
return osg::Vec4(r, g, b, 1.0);
}
What I would like to know, is if there is an algorithm that's more complex then just using R and G like this:
double r=(height-Heightmin)/Heightmax;
double b=0.0f;
double g=(Heightmax- height + Heightmin)/Heightmax;
(That is, the G is the inverted form of R, so at low values it will appear more green and at high values it will appear more red.
I would like to be able to utilise R G and B to give realistic looking hieght encoded landscapes:
This is an image of a 72dpi RGB height encoded topographic map. I would like to be able to achive something similar to this. Is there a simple algorithm to create an RGB value based on a minimum and maximum hieght?
Thaks for your help.
Ben