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.
- 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 whenTriangulate=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 theTIndexedTriangleSetNode
seemed more straightforward solution).The
TIndexedTriangleSetNode
also maps directly to GPU (unlikeTIndexedFaceSetNode
that needs triangulation, unlikeTElevationGridNode
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. -
Normals are calculated fast and are good for connected terrain patches.
This was broken previously (in both
Triangulate=true
andTriangulate=false
modes, although was supposed to work OK inTriangulate=true
).Now it’s correct (and it is correct regardless of the deprecated
Triangulate
/ newTCastleTerrain.TriangulationIgnoreHeights
). Terrain patches will match (regardless ofTCastleTerrain.TriangulationIgnoreHeights
, terrains will maych even if theirTCastleTerrain.TriangulationIgnoreHeights
are different).Explore
additional_noise_offset_test.castle-user-interface
in examples/terrain to test this. The screenshot on the side shows 3TCastleTerrain
instances, but you see no weird lighting at the point where they connect, their normals match perfectly. -
New
TCastleTerrain.TriangulationIgnoreHeights
property. This determines how we split quads into triangles. -
Triangulate
is now a deprecated alias toTCastleTerrain.TriangulationIgnoreHeights
. If you used this to request consistent ordering — then newTCastleTerrain.TriangulationIgnoreHeights
is just as good. If you usedTriangulate
for anything else — then it is probably not needed anymore, new rendering takes the best from previous 2 algorithms. -
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!