Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7874255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:45:32+00:00 2026-06-03T02:45:32+00:00

I have a program where I need to represent height as an RGBT (in

  • 0

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:

enter image description here

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:45:35+00:00Added an answer on June 3, 2026 at 2:45 am

    You just need to come up with a suitable colour gradient that you like, and then put it in a lookup table (or similar).

    Then all you need is something that will map a value in the range min_height -> max_height into the range 0 -> 255 (for example).

    Of course, it’s possible that you will find a colour gradient that can be expressed as mathematical functions, but that’s less general.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that I need to be able to search a file
I have a legacy program that I need to run with the extension of
I have a program that is written in Ada, and I need to compile
I have a program that looks like this. I need to consistently write something
I have a program for a C class I need to write. The program
I have a program in which I need to store a Class object into
I have a program (temptrack) where I need to download weather data every x
In my program I need to programmatically configure an ApplicationContext. Specifically, I have a
I need help getting my java program ready for release. I have a program
Just a quick question here. I have a program in which I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.