Terrain improvements

Terrain
Terrain patches seamlessly connect
New TCastleTerrain subdivisions meaning
Blender subdivisions meaning

We did a few updates to our terrains, set up by the TCastleTerrain component. You can play with them e.g. by exploring the examples/terrain or separate demo test-high-precision-terrains.

  1. The code is simpler and more efficient by internally using the TIndexedTriangleSetNode node for rendering.

    This means always using 1 draw call to render entire terrain (unlike previous TIndexedTriangleStripSetNode rendering mode when Triangulate=true where each strip took 1 draw call; we considered using an OpenGL trick to connect multiple strips into one draw call by using degenerate triangles at strip start/end, but the TIndexedTriangleSetNode seemed more straightforward solution).

    The TIndexedTriangleSetNode also maps directly to GPU (unlike TIndexedFaceSetNode that needs triangulation, unlike TElevationGridNode that needs a proxy).

    The code is also simpler: we have just one rendering path. Previously, we had 2 approaches, and deprecated Triangulate was choosing which one we use.

  2. Normals are calculated fast and are good for connected terrain patches.

    This was broken previously (in both Triangulate=true and Triangulate=false modes, although was supposed to work OK in Triangulate=true).

    Now it’s correct (and it is correct regardless of the deprecated Triangulate / new TCastleTerrain.TriangulationIgnoreHeights). Terrain patches will match (regardless of TCastleTerrain.TriangulationIgnoreHeights, terrains will maych even if their TCastleTerrain.TriangulationIgnoreHeights are different).

    Explore additional_noise_offset_test.castle-user-interface in examples/terrain to test this. The screenshot on the side shows 3 TCastleTerrain instances, but you see no weird lighting at the point where they connect, their normals match perfectly.

  3. New TCastleTerrain.TriangulationIgnoreHeights property. This determines how we split quads into triangles.

  4. Triangulate is now a deprecated alias to TCastleTerrain.TriangulationIgnoreHeights. If you used this to request consistent ordering — then new TCastleTerrain.TriangulationIgnoreHeights is just as good. If you used Triangulate for anything else — then it is probably not needed anymore, new rendering takes the best from previous 2 algorithms.

  5. TCastleTerrain.Subdivisions meaning changed.

    They now determine the number of rows in columns in the mesh. E.g. subdivision (4,4) means 16 (4 * 4) quads and 25 (5 * 5) vertexes. This matches the Blender’s “subdivisions” parameter for grids.

Note: This post details changed done last month, even before 7.0-alpha.3 release. Yeah, we have a backlog of announcements 🙂

Next steps in terrains: synchronize, review and merge Base terrain editing tools for Castle Engine Editor pull request from Andrzej Kilijański to introduce a big new feature – terrain editing! Stay tuned and please support us on Patreon!