A simple height map mesh engine

Post your own tutorials, guides and demos.

Post » Thu Dec 17, 2009 1:29 am

Just a uber simple way to generate a mesh from a height map.
Note:
This uses Image Manipulator, so its a bit too slow to be used all the time.
Also note Image manipulator is a bit quirky... The image must be resized, and flipped to work.
Plus this sets the distort map to 60x60, and that's pushing its limits. Finally its set to check values from 0 to 255... 100 is supposed to be max, 255(pure white) will be off screen.

[attachment=0:sowq06ay]simpleheightmap.cap[/attachment:sowq06ay]
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Thu Dec 17, 2009 4:09 am

That is so cool! :D
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Thu Dec 17, 2009 5:25 am

That's crazy. Very impressive 8)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Dec 17, 2009 5:56 pm

and displacing a different sprite instead of the heightfield pretty much gives you textured 3D backgrounds.
Wohoo! Now we can talk about something else :D
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Thu Dec 17, 2009 9:10 pm

very awesome
I never knew the image manipulator could do anything cool at all

I thought it was just for slowdowns and crashes

btw, the h loop is unneeded, so this is a probably a little more efficient:
[url:352nqvnu]http://dl.dropbox.com/u/1013446/spritefont/Capture2.PNG[/url:352nqvnu]

this is badass though
awesome work
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Thu Dec 17, 2009 9:35 pm

Yeah that will work, ....even simpler with an array. :lol:
[code:3cig86vh]+ Array: For Each element
-> Sprite: Set relative displacement at (Array.CurrentX-1, Array.CurrentY-1) to XYZ(0, 0, ImageManipulator.GetR(Array.CurrentX-1, Array.CurrentY-1)) UV(0, 0) 100 % [/code:3cig86vh]

Ok perhaps not as simple to figure out for those who have trouble with 0 based stuff, but ehh..
Keep in mind you would still need a third loop if you want to do some comparisons, like applying a color filter to a certain range, etc.

[quote="Madster":3cig86vh]and displacing a different sprite instead of the heightfield pretty much gives you textured 3D backgrounds.
Wohoo! Now we can talk about something else :D[/quote:3cig86vh]

All you have to do is change the frame after wards, unless you want to export the mesh.

Also, I might point out, that this doesn't have to be just for grayscale. You could use this for bumpmapped, or baked maps(aka normal maps) as well, by adding a green loop, and a blue, but of course it would take much longer to process.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Thu Dec 17, 2009 11:26 pm

Awesome? Yes. Image manipulator is actually useful, I didn't know it could read individual pixels!

edit: I tried making the distort map 255x255, to make it just z-distort each pixel pretty much, and construct doesn't seem to allow it. :( 70x70 appears to be the limit.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Fri Dec 18, 2009 12:46 am

Yeah, each row/column is what 4 vertex's, so even 60x 60 was pushing it. You can add multiple meshes, but,......and its a big but, they wont line up even if the z heights are the same.
Your best bet is to stretch the mesh, and then apply a different texture to it, but you will need a z multiplier, since z scales with the mesh.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Fri Dec 18, 2009 1:07 am

[quote="newt":2s31endg]You can add multiple meshes, but,......and its a big but, they wont line up even if the z heights are the same.[/quote:2s31endg]

That makes both baby jesus cry, and kills kittens at the same time as clubbing seals. This doesn't apply to the way things are done in your terrastruct does it?
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Fri Dec 18, 2009 4:37 am

I'm talking about placing meshes next to each other like a tile map. If you place one right after another, you will get a line where the background shows through. It has something to do with 3d layering, not sure if its a bug tho...
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Next

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests