Island Mesh
Building on Voronoi and Delaunay grids, I then sought to work out how to turn that into geometry in Unity.
So my initial attempt to implement height in my mesh experienced some interesting issues. One vertex appears to be getting offset in the wrong axis, and the lighting is far from smooth even where the edges should align pic.twitter.com/2CDZWI7GFP
— Jez 🌻 (@NinjaJez) February 24, 2018
Turns out I had an = instead of a - in the wrong place. Wouldn't have been possible if I wasn't accessing fields directly; this is why you use getters and setters, kids ;)
— Jez 🌻 (@NinjaJez) February 25, 2018
Next problem to resolve is how the mesh is handling shading. Vertex normals, perhaps? pic.twitter.com/nyOTZZIfuQ
Getting there! The scattering of dark lines look to be artefacts where some corners appear to not be correctly averaging the expected neighbouring centre elevations. Might be another bug with how I'm getting data from the triangulation algo :/ pic.twitter.com/0wZt2qi0Qj
— Jez 🌻 (@NinjaJez) February 25, 2018
Discovered my hunch was close; looks like the TriangleNET algo I'm using is incorrectly generating multiple unconnected vertices close to each other. A bit of merging and id mapping helps to reduce those artefacts though. pic.twitter.com/HJ93sTlKGQ
— Jez 🌻 (@NinjaJez) February 25, 2018
What if, right, we just threw perlin noise and some primitive deformation functions at it, then added an arbitrary clipping plane? pic.twitter.com/OcbgKWO41I
— Jez 🌻 (@NinjaJez) February 26, 2018
Figured out why there were weird edges in my geometry! Sometimes corners lay outside the lines drawn between centers, leading to some very acute angles. Positioning the corners within the centers they touch gives a much more even barycentric dual mesh :D pic.twitter.com/fVtu6H0KXz
— Jez 🌻 (@NinjaJez) March 3, 2018
Behind the scenes: here's my debug view - white lines trace the delunay graph between centers, green lines trace between corners and centers. Note how in one pic green lines cross the white ones, leading to more hard-edged artefacts. pic.twitter.com/4DWavU7yFv
— Jez 🌻 (@NinjaJez) March 3, 2018
Implemented one way of adding rivers and water erosion: calculate the downward slope of each graph point, use that to distribute and accumulate a moisture value, then use that to modify the elevation of each point. Doesn't handle basins though, which could cause problems. pic.twitter.com/HSdRBfSdiC
— Jez 🌻 (@NinjaJez) March 3, 2018
So I tried upping the point count, and... well... it turned into swiss cheese.
— Jez 🌻 (@NinjaJez) March 6, 2018
Pretty sure that's because I'm hitting the vertex limit on unity meshes with my simple meshing algo. To the code-mobile! pic.twitter.com/EAxXfpO0HI
Implemented mesh chunking! The map below was generated from 10,000 seed points but with the same deformations as above; see the extra contouring details!
— Jez 🌻 (@NinjaJez) March 6, 2018
The mesh picture shows how I've implemented chunking, with the middle section selected in blue. pic.twitter.com/aBHrTTsILW
A side effect of increasing the resolution is that there are a lot more depressions gathering water, revealing a bug with my water erosion algo and highlighting the need to handle the case of water gathering in-land rather than flowing out to the edge. pic.twitter.com/Lcs2Ftzj1g
— Jez 🌻 (@NinjaJez) March 6, 2018
Given a clipped island, can I work out how to make triangles for the underside to make it a floating rock thing?
— Jez 🌻 (@NinjaJez) April 9, 2018
So far... not so much. pic.twitter.com/lq2Eyg3Nty
!!! Turns out when you spend some time thinking about things, you can actually work how to do them :D #proceduralGeneration #Unity3D #babySteps pic.twitter.com/tgQnxKCi8s
— Jez 🌻 (@NinjaJez) April 9, 2018