Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How does a color heightmap work?

Author
Message
Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 18th Sep 2011 05:39
Hi,
I'm playing around with height maps at the moment. I'm curious as to exactly how colored height maps work.

the most information I've found so far is

Quote: "kaedroho - The colour heightmapping feature simply takes the value of the green channel to fine tune in the value on the red channel for extra accuracy."


I'm not exactly sure what this means.

does it mean that the red channel is used for mountains and the green channel makes bumpy terrain over top of the mountain?

or does it mean that the two are added together?

is red channel large steps and green channel small steps?
would that mean that for smaller hills you would use green and for larger you would use red?

Any help or info clearing this up would be greatly appreciated.

thankyou

kezzla

Sometimes I like to use words out of contents
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 18th Sep 2011 06:48 Edited at: 18th Sep 2011 06:50
I'm not too sure but sometimes a colour map is used as a normals map. If so then a normal map would be added to the terrain texture to high light lighting effects.

Either that or what has been quoted means that instead of a height map having just values from 0-255, then the accuracy is increased by using the values of 3 bytes instead of 1.

Warning! May contain Nuts!
Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 18th Sep 2011 10:16
thanks wlgfx,
I wonder the same. I'm asking for use with Blitzterrain so I dont think its a normalmap(not certain, so it may be)

I might PM kaedroho to clear this up and post an update in this thread.

kezzla

Sometimes I like to use words out of contents
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Sep 2011 15:27
Quote: "is red channel large steps and green channel small steps?"

This.

As far as I'm aware, height maps and normal maps aren't usually combined, although technically you could, using 1 byte for height, and 3 bytes for the normal vector.

Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 19th Sep 2011 02:32
Using one channel a height value can range from 0-255. Using two channels the height can range from 0-65535 (256^2-1) giving much greater precision. You can work out the red and green components from a height value as follows:



So red = 0, green = 255 is one step lower than red = 1, green = 0.

[b]
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Sep 2011 03:16 Edited at: 19th Sep 2011 03:23
@Diggsey - That confuses me even. Sowwy!

If a height map was in colour then you would either get RGB or ARGB or maybe even RGBA, depending on format. Either way, what you are reading in is the values...

A normal height map is RGB or ARGB or RGBA, oh god, back to that again... (other forums for that) Which gives you a value 0-255? Yup...?

RGB is 3 bytes... 3 times the accuracy... (Red, green and blue)

However you are reading the values, if the initial value is the red, then the next is the so on and so on....

Kezzla: RGB = (RED*65536) + (green*256) + blue (You knew that anyway!)

I think accuracy got a bit lost here myself. And if I was doing accurate height maps I would go the same way. (Cheat!)

EDIT: @IanM - You given me an idea there...

Warning! May contain Nuts!
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 19th Sep 2011 19:49
Quote: "RGB is 3 bytes... 3 times the accuracy... (Red, green and blue)"


No, using 3 bytes as opposed to 1 byte gives 2^16 times more accuracy.

Normal heightmaps only use one channel. Since a single channel is one byte, that gives you a range of 0-255 for the height.

If the terrain height is set using two channels (ie. two bytes) you can a range of 0-65535 for the height. (Look up range of the "word" datatype in DBPro) What's confusing about that?

[b]
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Sep 2011 03:22
I just re-read it. I think I made that post well gone after midnight.

Warning! May contain Nuts!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Sep 2011 12:18
And of course you can get greater accuracy still by using the alpha channel as well - but whether you'd ever notice the extra precision on current machines is another matter.
Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 22nd Sep 2011 00:55
Cool thanks guys,
That explains the severe stepping I get when generating my own "grey" height maps.

I understand color heightmaps much more clearly now.
Thanks again,

Kezzla

Sometimes I like to use words out of contents

Login to post a reply

Server time is: 2025-06-20 05:21:51
Your offset time is: 2025-06-20 05:21:51