简体   繁体   English

使用Transvoxel / Marching立方体和3D Perlin噪声制作过程地形

[英]Making a procedural terrain with Transvoxel/Marching cubes and 3D perlin noise

I'm working on an implementation of Transvoxel and it works fine, but I can't get on with the noise. 我正在开发Transvoxel的实现,效果很好,但是我无法忍受噪音。 Now I'm generating a 2d heightmap using perlin noise and using the heightmap I'm setting the cell values, but I don't have any idea on how to generate the values for the cells. 现在,我使用perlin噪声生成2d高度图,并使用heightmap设置像元值,但是我不知道如何为像元生成值。 Actually they have to be between -127 and 128, and they have to increase and decrease smoothly, but I can't generate those values. 实际上,它们必须在-127到128之间,并且它们必须平滑地增加和减少,但我无法生成这些值。

EDIT: 编辑:

I stopped using 3d noise and I'm trying to do something with 2d noise. 我停止使用3D噪波,而尝试使用2D噪波做一些事情。 Now, I can triangulate a density field as I'm using marching cubes and transvoxel since about half a year. 现在,大约半年以来,我可以使用行进立方体和Transvoxel来对密度场进行三角测量。 But the only thing I don't know is that if I generate a 2d heightmap to have terrain features like mountains then I don't know what densities do I have to use. 但是我唯一不知道的是,如果生成2d高度图以具有山脉等地形特征,那么我不知道必须使用什么密度。 I tried just simply give everything solid -127 and everything non-solid 127 and I also tried getting a heightmap value at a given (x,z) and then just adding y to it like: (x, 0, z) = 42, (x, 1, z) = 43, (x, 2, z) = 44 etc... But theese variations generate blocky terrains like the image below: 我只是简单地给所有实心-127和所有非实心127,并且还尝试获取给定(x,z)的高度图值,然后将y加上:(x,0,z)= 42, (x,1,z)= 43,(x,2,z)= 44等等...但是这些变化会产生块状地形,如下图所示:

在此处输入图片说明

What should I do to make it smooth? 我应该怎么做才能使其顺畅? Vertex locations are floats with non-whole values so it shouldn't be the problem. 顶点位置是具有非整数值的浮点数,因此这不是问题。

Transvoxel is a more complex implementation of Marching Cubes and I suggest you forget Transvoxel for now, study Marching Cubes first. Transvoxel是Marching Cubes的更复杂的实现,我建议您暂时忘记Transvoxel,首先学习Marching Cubes。

In summary, Marching cubes receives noise from 0 to 1, where 0 is no terrain and 1 is terrain. 总而言之,行进立方体接收的噪声从0到1,其中0是无地形,而1是地形。 You just need to write 1 where you are planning to have terrain. 您只需要在计划有地形的地方写1。 For instance, generate a small map with 1 value where y < 3, on all X and Z positions of your map. 例如,在地图的所有X和Z位置上生成一个y <3且值为1的小地图。 You should get a flat terrain. 您应该获得平坦的地形。

Try out! 试用! =) =)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM