greyscale bmp output?

Started by pfrancke, January 03, 2009, 05:33:13 PM

Previous topic - Next topic

pfrancke

Sorry for the poor subject line, I'm having a hard time generalizing...

I've got a topdown pov looking at the ground.

I'm reading in a terrain file downloaded from USGS and doing a square (say 1024x1024) render.  The surface layers that it flows through generates different colors for the different elevations changing colors every x number of feet - and this generates a pretty relief map of the area that I'm interested in.

Now what I want to do is to produce a grey scale exact relief map of the exact same area where the rgb of each elevation point is it's grey scale color.  For instance, if the elevation is at 210, then I want RGB to all be 210.  The higher the elevation, the brighter the pixel.  If I could do this, then I'd have a bmp (raw height map).  I've written a C++ program that can read a square grey bmp file as a heightmap, and then texture the color relief map on top of it...

But I'm awful at TG2 functions -  this is probably an easy thing to do in a small handful of nodes, but I'm brain-dead and not that good with TG2.  Any help much appreciated!!

Piet   

Hetzen

Just thinking out loud, but I reakon you could project a grey scale grad lateraly across your landscape through an image map shader, using a XY projection type, so black is the bottom and white is the top. Then just make sure you stretch the grad to the same height and width of your landscape, in the shader scale, and position it centraly to your area.

Then set up your render camera directly above your landscape and check the Orthographic box to kill any perspective.

pfrancke

Hetzen, you completely lost me, then I thought I'd try it anyway to see how far I could get.  (nothing wrong with your instructions, I just have a hard time following instructions) 

I created a black to white gradient in PS and created a surface layer and plugged the image map into it as a child.  About the only thing I had to do was set the size up large enough.  I also had to kill atmosphere (to keep blues out) and it worked like a charm.  Except that the colors wrapped in a loop....   If I had an elevation of 260, it would show up as black (a 4 I assume).  I licked the problem by multiplying the heightfield by 70 percent in heightfield adjust and adding a bit back in.  Anyway, I want to thank you, this is big for me and I owe you!!!

Volker Harun

It is a bit tough, as we work with at least two unknown constants ... the absolute minimum and maximum of the terrain.
We need the height range of the terrain to create shader that goes from pure black to pure white.

The imagemap is a nice idea ... but to crate this a 3rd party app would do better ... loading the terrain into geocontrol or worldmachine ... using those export functions.

If you still want to shade the terrain by height, you use an image shader with XZ-projection.

Volker

Hetzen

Pfrancke, I'm glad it sort of worked out. I had a go this end and discovered that depending on how wide the landscape is in metres, the larger it is, the further it wraps itself around the planet, thus your landscape extents reach below your grad projection. To illustrate, imagine your grad as a rectangular piece of paper resting edge first on the side of a ball...

What would be better, and have only just noticed this, you can use the Colour Tab in the Heightfield Shader. Ie check on "Apply Colour and Shade". Check "Shade by height". Voila! A lot less painfull.

pfrancke

Volker,  I had already painted myself into a corner because the pov and image I generated from TG2 were input into PS and lots of artwork (roads and rivers and trees, poorly done) were already done.  So I needed to hack something into place that matched perfectly the terrain that I'd already clipped out.  But your point is very well taken about using the right tool for the right job!! 

Hetzen, you had to make it hard on me didn't you!!!!   I just tried what you said and it works like a dream.  I think I'll generate it again as it probably does a better job than the gradient hack - ingenious idea that it was <grin>

Attached is my latest output - the programming for displaying a 3d map of Gettysburg is going well - it zips along at 160 frames per sec and I'm very excited with the progress I've made today.  Now only if I were a better artist and could think clearly!!!  Also, Ultimately I'm going to have to tile my output, the engine I'm using only takes in 256 per square image maps (that I layered with a 4096x4096 texture...)

Hetzen

Lol, we're both learning.

That looks like a map for a war game. A bit like the SSI series of Panzer General.

pfrancke

thank you again Hetzen...  I'm striving for a brigade level battle of Gettysburg.  And learn I will have to do or miserable failure is in front of me.

Learning - we do it till we die, else those around us wish us dead. 

Recently I learned how badly my map stunk.  I stumbled onto the US national archives and found online images of last century maps of the Gettysburg battlefield - so I have months of art fixing to do, but at least I won't be guessing anymore.  And I found out (since I was painfully struggling with photo-shop) how to do some of that work better and easier - I found out how the pen worked and how the stroke thing worked for instance.   

A week ago my map was going to be a flat top down view, but now, I'm coding in C++ using the Irrlicht engine -  a very nice community of people by the way, reminds me of the folks here and at Ashundar.  Today I learned that there was a bug in their engine that left the vertices with an off by 1 problem.  My map was shifted and one edge had all elevation 0.

Within 10 minutes, someone told me that it was a known bug and the coding fix was blah, blah, blah.  With trepidation, I tried to recompile the engine and found myself with 11 compile errors dealing with missing directX include files --- 10 minutes later I had been directed to change a configuration file that would let me bypass those files.  I tried it and it worked.

But then I learned that my openGL was running much slower than the directX code would have, and that made me want to download the directX SDK.  Well, to make a long story short, now I'm learning that it takes forever do download 483MB at 11.2 KB/sec. 

After I get that, the Irrlicht guys tell me that that there are more bugs and fixes dealing with terrain meshes, but they (code fixes - can't wait till March or so for the new release) are there for the taking...  So, I'm thinking that the last thing that I've learned is that those German guys are much braver and harder working than this poor foolish Dutch/American.  So much to learn, and so little time and the weak brain cells are just slipping through my fingers. 

Learning plus persistence!!!  Don't ever leave out persistence.

Goodnight friends.