View Full Version : Changing the grayscale range within a height map
10-02-2011, 05:09 PM
Hello, I'm new to the forums. It seems there's far more info here than I can quickly process. I did a search, but I didn't find what I was looking for, so maybe someone here can help.
I'm creating 8 bit grayscale .bmp files for a free game called Armored Brigade. http://www.armoredbrigade.com/
The game reads a grayscale .bmp file and assigns the height (in Meters) to the value for each pixel. For example, if a pixel has a grayscale value of 155, then the elevation is 155 Meters.
My problem is that every random terrain generator tends to assign the value 0 (black) to the lowest elevation, and 255 (white) to the highest elevation, thereby making every single map between the elevations of 0-255.
For example, if I create a random heightmap in Terragen or L3DT setting the vertical range as 50 to 155 Meters, the program still creates a grayscale map with the lowest point a black (0) and the highest as white (255).
If I want my actual map vertical range between 50 and 155 Meters, how do I convert a greyscale 8 bit .bmp map from 0-255 to 50-155?
I'm hoping something in Wilbur can do this.
I'm sorry if this is a double-triple post but I'm having real issues submitting this thread
10-02-2011, 05:17 PM
HI Sam, your thread was held in a moderation queue because you're a first time poster and posted a link. It's through now!
10-02-2011, 06:22 PM
Thats not a problem. The easiest is with a graph tool but I am familiar with PSP not Gimp or PS but I would imagine they have one too. This graph tool is one where you can draw a curve (set points and it interpolates the line) for the input and it will scale the luminance to the output.
By setting the curve such that its a two point straight line where 0 goes to 50 and 255 goes to 155 it will directly convert that map to your requirements.
If you dont have one of those then its easier to get it by first getting the range correct then by setting the brightness. So first of all you would drop the contrast from (255 - 0) = 255 to (155 - 50) = 105. Thats a 105/255 drop which is 41% of original. That in most application terms is a -59% contrast adjust. Then you would have an image which is of that new range but it offsets it by default around the mid grey mark. So it ought to be 128 +/- 52. So you need to drop it by another 26 to get it to 50 to 155.
Like I said - the graph tool does it all for you tho. No messin'.
You might want to think about using 16bit heights to prevent the banding that will occur. And b) you can try my totally free 3D visualizer (http://www.viewing.ltd.uk/cgi-bin/viewingdale.pl?category=dragons_flight) for height map data. Save the image as Height.bmp (or PNG) and then run the app in the same dir as the image.
10-02-2011, 06:23 PM
Wilbur can do this, but it's a little convoluted to get your mapping. The first step is to set a shader that will map altitude directly to color (done as a code block to make the indentation stay):
Do Texture>>Shader Setup to bring up the Lighting Settings property page
Select the General Tab
Select Display Type as Height Code.
Select Altitude Tab
Turn on Absolute Coloring
Set Altitude Max to 255
Set Altitude Min to 0
Click Color List on the Land side to bring up the Edit Color List dialog
Hold down Shift and click Remove to clear the color list
Click Add... and select Black (RGB 0,0,0)
Click Add... and select White (RGB 255,255,255)
Click OK to accept the Edit Color List changes
Click OK to accept the Lighting Settings changes. Your surface should appear as grayscale with 0 as black and 255 as white.
If you need to remap your surface to a particular range of values (letís say that another image editor has adjusted your data to the range 0 to 255 and you want it to the range 50 to 155), then use Filter>>Mathematical>>Span and enter your desired high and low values (50 and 155 in this case). After clicking OK, your surface will be displayed as you wanted.
Save the texture using File>>Save As and set File Type as BMP Texture or PNG Texture. Itís the texture that you want here, not the surface.
10-02-2011, 08:15 PM
In Photoshop go to Image - Adjustments - Curves.
10-02-2011, 10:23 PM
Wow! thanks for the quick replies!
First of all, using the curves approach works! Never was sure what that was for . . .
The Wilbur solution works too!
By the way, I'm using Paint.net and it has an adjustment>curves option. I use GIMP also, but whenever possible I stick to the simpler tool.
10-04-2011, 11:17 AM
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.