# Grayscale "Cliff" Detection

This topic is 4413 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm working on a 2D game that uses Grayscale images for height. The actual height is no problem, but there is a major problem: Whenever a character comes into a major sheer face, (or technically, when it refers to a bit from the greyscale sharply higher than the previous), it 'teleports' him or her straight to the top. I know I should be able to fix this by interpolating between each pixel on the grayscale, (or at least I think I know), but knowing what to do, and how to do it are very exclusive ideas... If it means anything, the game uses vector coordinates to determine a character's speed and direction, and the traditional (x, y) coordinates for the location. Also, though you probably already figured it out, movement is free in all directions. Because of how there are no restrictions of movement, it's very important that the game be able to assume a curved cliff where there would be an irregular diagonal array of pixels. I figure this must be a problem everyone runs into eventually, so there must be a solution out there somewhere; no matter how many times you reinvent the wheel, it can be no better than the original.

##### Share on other sites
You really need an interpolation function. The interpolation function should model the reality you are creating visualy.

Ie, if you are using bilinear interpolation in the terrain shading then you should probably use bilinear filtering for the heightmap interpolator. This will make it fit closely with what the user expects based on what he sees.

Make things easy on yourself.. write a function which gets the interpolated height at a given floating point X,Y pair and try to keep it simple and efficient. Just about everything else you need to do with heighmaps should be querrying this fuction when they need a height, rather than the actual heightmap data.

##### Share on other sites
Here's another thread with some code that you may find usefull. It interpolates the height per triangle so it matches the visible terrain polygons.

1. 1
2. 2
3. 3
4. 4
Rutin
19
5. 5

• 14
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632926
• Total Posts
3009252
• ### Who's Online (See full list)

There are no registered users currently online

×