如何生成随机斑点? [英] How to generate random blobs?

查看:45
本文介绍了如何生成随机斑点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 3D 中生成随机形状.我希望形状是斑点,基本上可以通过取一个球体并将其扭曲成不太规则的形状但仍然主要是紧凑的.考虑拿一个粘土球并轻轻捏或推拉它.表面上的表面曲率或不规则程度应该可以使用某种参数进行控制.我希望输出是由体素组成的体积(内部为 1,外部为 0),尽管可以转换为体积的表面也可以.

I would like to generate random shapes in 3D. I want the shapes to be blobs, essentially what could be obtained by taking a sphere and distorting it to be less regularly shaped but still mostly compact. Think taking a ball of clay and pinching or pushing and pulling it slightly. The surface curvature or scale of irregularities on the surface should be controllable using some kind of parameter. I would like the output to be a volume consisting of voxels (1 for inside and 0 for outside), although a surface which can be converted to a volume is also ok.

我看过高斯随机球体,它们是球谐函数的叠加.我无法完全弄清楚这些的数学方法,并且在任何地方都没有示例代码.此外,它们无法生成任何具有悬垂的形状(即,来自球体中心的射线多次与表面相交).

I've looked at Gaussian random spheres, which are superpositions of spherical harmonics. I couldn't quite figure out the math for these, and there is no sample code anywhere. Also, they can't generate any shape which has an overhang (ie, where a ray from the center of the sphere intersects the surface more than once).

推荐答案

使用 3D metaballs.

随机生成一组 3D 点.5 个或更少应该可以工作,但您可以更改此设置.

Randomly generate a set of points in 3D. 5 or less should work but you can vary this.

对于每个体素,计算到每个点的反距离(或体素和点坐标的其他函数)并将它们相加.如果总和等于或大于阈值,则在 blob 中,如果小于则在外面.

For each voxel, compute the inverse distance (or some other function of the voxel and point co-ordinates) to each of the points and sum them. If the sum is equal to or greater than a threshold value, it's in the blob, if it's less than it then it's outside.

您可以改变阈值,并可选择为每个点赋予不同的随机权重(可以为负).粗略地说,您希望每个点的阈值距离重叠,否则您将只有一堆单独的球体.

You can vary the threshold value and optionally give each point a different random weight (which can be negative). Roughly speaking you want the threshold distances from each point to overlap, or else you'll just have a bunch of separate spheres.

这篇关于如何生成随机斑点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆