Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,253 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
MED Terrain Import: Explain R*1 + G*1 + B*2 #184564
02/19/08 08:39
02/19/08 08:39
Joined: Apr 2006
Posts: 66
Sweden
R
rstralberg Offline OP
Junior Member
rstralberg  Offline OP
Junior Member
R

Joined: Apr 2006
Posts: 66
Sweden
Hi

When importing a heightmap in MED
the Z-postion has a formula R*1 + G*1 + B*2

I assume this means Red*1 + Green*1 + Blue*2
and is used for heigt calculation.

The problem is that I don't understand this so
if anyone could explain this I would be grateful.

The heightmap file, isnt that a greyscale image
where Red=Green=Blue? So why B*2 ?

Say I have designed a heightmap where white(R=G=B=255)
should be equal to 50 meters and black(R=G=B=0) is 0 meters.
How should the formula look for this scenario?

~Roland


Roland Strålberg Gamestudio/A7 Commercial rstralberg@msn.com
Re: MED Terrain Import: Explain R*1 + G*1 + B*2 [Re: rstralberg] #184565
02/19/08 08:58
02/19/08 08:58
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
This link may help explain a bit about heightmaps and how they work.

It's not GameStudio related but it explains about how they work.

I'm sure GS uses the same principle.

Info about heightmaps.


Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: MED Terrain Import: Explain R*1 + G*1 + B*2 [Re: rstralberg] #184566
02/21/08 22:01
02/21/08 22:01
Joined: Apr 2006
Posts: 66
Sweden
R
rstralberg Offline OP
Junior Member
rstralberg  Offline OP
Junior Member
R

Joined: Apr 2006
Posts: 66
Sweden
Hi again

I have made some reading trying to find out what the RGB formula achieves.

If I got it right it should work like this:

RGB tells the z-position of each vertex in the imported terrain
RGB=0 gives a Z-position of 0, RGB=255,255,255 gives the highest Z-position.

Normally we have grayscale height maps where R=G=B so for them any of the
RGB values can be used. R is normally used.

So, the formula for grayscale height maps should be something like

R*1 + G*0 + B*0

We only care about one of the RGB components as they are all the same values
for each pixel

In MED the formula is said to calculate z-position.

I did a simple test by in MED importing a black 1024x1024 height map with one
white dot in it with following results when importing the produced .hm file into WED.
----------------------------
R*0 + G*0 + B*10 - terrain pos at z = 0, size 1024x1024x512
R*0 + G*10 + B*0 - terrain pos at z = 0, size 1024x1024x512
R*10 + G*0 + B*0 - terrain pos at z = 0, size 1024x1024x512
R*10 + G*10 + B*10 - terrain pos at z = 0, size 1024x1024x512

So apparently the formula does nothing for grayscale height maps
or have I totally missed the whole idea of how this works?


~Roland

Last edited by rstralberg; 02/21/08 22:04.

Moderated by  HeelX, rvL_eXile 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1