0
\$\begingroup\$

I'm moving from working on 3D block-world terrain to more specific features like tree leaves and ore veins (the ore veins will likely be done with my existing Perlin noise for the terrain). One thing I'm having with is properly generate clusters of blocks (for example, leaves for trees).

I've tried looping through a radius and randomly skipping blocks so it seems more natural but this still doesn't look natural enough and also makes it based on a cube shape to start. I want some trees to have more of an overall sphere-shape to the leaves, or some to have a cone shape. I haven't really found helpful info on how to loop through coordinates of shapes other than a cube.

What technique(s) should I employ to generate natural looking clumps of tree leaf blocks?

\$\endgroup\$
  • \$\begingroup\$ Do you want leaves made of cubes, or leaves instead of cubes? If you don't need such features to be constructable/destructable, you could just have a node type of "leaf" and render an arbitrary mesh there. \$\endgroup\$ – David Cummins Dec 4 '13 at 2:21
  • \$\begingroup\$ Leaves as cubes. Similar to Minecraft. \$\endgroup\$ – BotskoNet Dec 4 '13 at 2:23
  • \$\begingroup\$ I can't understand why you removing random voxels, while you explicitly want to remove voxels that are not inside of some shape (e.g. sphere or cone)? You don't know how to detect if some coordinate is inside a sphere? \$\endgroup\$ – Shadows In Rain Dec 4 '13 at 8:43
  • \$\begingroup\$ Because nothing in nature is a perfect shape, so a perfect sphere won't cut it. Randomly removing won't work well because it has to be weighted for the edges, blocks shouldn't be missing from the inner areas. \$\endgroup\$ – BotskoNet Dec 4 '13 at 17:15
2
\$\begingroup\$

Would it make sense to generate a tree structure using an L-system, initially ignoring the cube grid, and then clamp the resulting leaf positions to the grid? (ignoring duplicates where multiple leaf nodes map to the same grid cell)

Another possibility: You could randomly generate points within a sphere (some approaches here, if your environment doesn't provide a convenience function for this), and then add a leaf block at each grid cell in a line between that point and the center of the sphere. This will ensure you don't have floating leaves with no neighbours, and the boundary will still be rough rather than looking like a perfect sphere.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.