Eliminating (or detecting) holes in procedural noise for game development

北慕城南 提交于 2019-12-13 02:50:16

问题


I've been following this page http://devmag.org.za/2009/04/25/perlin-noise/ as a guide to create my own perlin noise - it's been pointed out in the comments section that this is FBM noise, but that's irrelevant.

This is working very nicely so far, these are the results, after some 'cleaning' to remove as many artifacts as I can. http://puu.sh/dayg9/2943aca5ce.png

Now that I've created my noise, I'm going to use it as an infinite map for a platform game. However, as you can see, there are some holes in my noise.

-Please note- this noise is meant for a 2D game!

My question is - how can I either fill in these holes, or stop the player from spawning inside them? Can't find an answer despite a lot of googling and thinking EXTRA hard.

Thanks for your time:)


回答1:


Just use a Non-Euclidean http://en.wikipedia.org/wiki/Haversine_formula based algorithm to first look at where they are spawning to find the number of objects within a set gap size, and then move the player to a different spawn area if the count is too low.

For speed you could calculate this at initial area generation generation time, and then cache the results on a per-region basis to make it easy to query.




回答2:


Someone mentioned that the solution has a lot of relevance with filling algorithms, like the ones used in microsoft paint.

I'm going to proceed to use the 'scanline fill' algorithm - http://en.wikipedia.org/wiki/Flood_fill



来源:https://stackoverflow.com/questions/27207512/eliminating-or-detecting-holes-in-procedural-noise-for-game-development

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!