Hey everyone 🙂
Long time no write, I guess I lost myself in heavy “Research & Development” work around NeREIDS, while not adding much code to the project in concrete terms. But this doesn’t mean nothing was done !
At the onset of this long silence, there was some reading on my part on a few programming aspects. To make things simple, I’ve browsed forum posts where a way of coding called the “entity-component system” was the new hype, and some posts where same system was disregarded in favor of classic object-oriented approaches. Well, at one point, while casually reading on the matter, I stumbled upon some long article that was… insightful at least. I experienced something like a philosophical shift regarding my programming habits, and changing programming habits is kinda earth-shattering for a nerd like myself… Anyway, for those interested in the technical aspects, you can read more about all this on that post here. For the others, let’s say the matter occupied me for quite some time, and I underwent an heavy retooling work of some part of the code for almost two months.
And I don’t even know if I’ll really use all those new tools, as usual. But hey, this is a principle of R&D, isn’t it ? So, please, bear with me 😛
That lonely triangle above is well known of all 3D programmers and artists. It is the building block of (almost) all current interactive 3D scenery. Fancy games and incredible graphics of AAA titles ? Well, basically, no matter how beautiful or realistic, if you take a close look at their guts, you’d see bare triangles like this one.
The other two illustrations ?
Remember the Terrain & Environment system for NeREIDS I was bragging about in previous posts ? Well, I gave all this some serious thoughts, then some more thoughts, and worked and reworked and scrapped and reworked the design of it. A couple of times. Or two.
Why all this fuss ? Well. Hmmm… Well, NeREIDS is… gahh… I don’t want to give it away yet.
Suffice to say I’d like all environment on your screen to be an unified blob of those triangles, and not having too many special cases for vegetation or rocks being distinct from the ground surface, nor too many special cases for overhangs or caves or even buildings. I’d also like some great view distance calling for efficient LOD management (LOD being Level of Detail : the principle of increasing the number of triangles needed to render an object close to view, and/or decreasing it for objects far away), and some tricky procedural stuff. This is enough to occupy anyone for years, already, but then, at one point, I went “hey, why not try to mesh all this on a sphere, so that a playground map could be the size of a planet”.
To be completely honest, I do not even “need” things to be planetary sized. Initial plans for NeREIDS are more like a fantasy role-playing game, close to your character, close to the ground, on a medium-sized map where aerial views would be restricted to dragonback rides at best. This is quite a long way from moon views of the earth’s surface. But then, I envisioned the switch to a fully scalable, any-setting-including-scifi-able-RPG, which seemed just in reach of NeREIDS design, and I had the urge to throw planet-sized maps into in the mix.
Terrain rendering of realistic or semi-realistic landscapes requires large amounts of data. At one point, I went “my initial design may be too slow, handling irregular blobs of triangles, maybe I should use some kind of regular 2D grid to minimize the volume of data to be updated, as everybody else does”. Then, I went “hey, a regular 2D grid and a sphere, wtf ?”. And then, things started to go havoc.
Now, let’s be clear, planetary meshes are nothing new, and solutions exist for smoothly zooming from orbital heights to daisy view. But as always, there is more than “one” solution, and finding (and/or reinventing) the solution that would go nicely together with all my other self-imposed requirements requires some hard work. After all those weeks, few things in the Terrain & Environment design are entirely set in stone still. But I’ve improved my representation of the problem and some solutions begin to arise.
In the process, I spent quite some time trying to implement a bijective function that would map plate-carree disposed data (think of simple latitude/longitude) to coordinates inside an icosahedron-based mesh (a sensible choice for planetary geometry) and back, not involving lookups of the recursive subdivisions (thus allowing any subdivision scheme, and faster at high resolutions), nor deformations arising from the simpler method of subdividing the faces before projecting them (not to mention the difficulty finding the reciprocal of such methods). Although this pushed my grasp on trigonometry to its limits, I think I’ve finally succeeded, as the following image shows (nothing NeREIDS related there, it was just a test for this very function)
Each pixel of such a texture at any resolution is directly assignable to a vertex of a same-sized refinement of an icosahedron.
It thus shows minimal area and distance distortion when projected on an icosahedron-based mesh.
Colors are a simple mix of elevation and some lighting trick with normals derived from the heightmap. Sea is (incorrectly) assumed to cover anything below height 0 using this datum, which is why on some parts of Europe here, you may have wetter feet than IRL (this is especially obvious over Belgium and Netherlands).
Below is a (very) downsampled version tiled and tilted with Photoshop to help you visualize the coverage of the whole world using this projection :
Producing that image required that I wrote some piece of code for outputting in .BMP format, and I reused that part a few days later to test some other stuff. For example, I’ve just written an algorithm to compute nice-looking pseudo-random point scattering in 2D and 3D, and a way to encode more than one level of sparseness in a single grid. I think I’ve succeeded too, as this “sparseness gradient” image (again, just a test) shows for the 2D version of the scattering algorithm :
I’m confident that data like this will prove invaluable when the time comes to throw vegetation over a 3D terrain, since simple random points wouldn’t do the trick (as nicely explained in that Gamasutra article). True, I’m working on a lot of different stuff at once for NeREIDS environment, and I did a lot of researches on existing models on the matter of climatology, botany, soil types, geology and even stratification or tectonics, to think of ways to come up with good-looking landscapes.
Until some pics from NeREIDS, take care !