- Home /
procedure generate terrain using a Jpg
I was wondering how I can use a jpg instead of a raw file to generate a terrain in unity via code. What I want to do is to get a jpg off a server or my computer and then use that to generate the terrain. So far all Ive seen has been using raw format.
So basically I was thinking like this 1: Apply a texture i.e. the height map of the terrain i want to model to a mesh. 2: Loop though each vertex of the mesh and get the color of the pixel 0-1 value 3: Base the height Y of the mesh on that value according to the max height index like 1500 ft for a mountain or what not.
I think this would work it seams like it would any thought or improvement to this? Thanks for any help with this
So why do you not use raw-format? Because of download-size?
I want to use real GIS data in this and the software only exports it as a jpg or png not raw, I am making the game grab real data from a database of images and then generate this. Its a lot of data and I dont want to go though it and convert all of the data into raw that would uber suck.
Answer by senad · Sep 30, 2012 at 06:27 PM
Your algorithm sounds good to me. Maybe it would be easier after all to convert to PNG, if you can find a library for the conversion.
Also for your algorithm, since you only do it once on start-up, I would probably do it on the CPU, instead on the GPU for easier debugging and stuff.
Your answer
Follow this Question
Related Questions
Runtime mesh generation from text file 0 Answers
How to generate terrain for 2d up scroller game ? 0 Answers
Make a simple tree 1 Answer
Tile Terrain Generation 1 Answer
Pathfinding RTS (C#) 1 Answer