Sample: Terrain with Xenko


#1

Here is a quick example of a basic terrain system in Xenko. It uses height maps for geometry, and blend maps for texturing. I was not able to figure out how to get Xenko’s own lighting into the render feature for the terrain (xen2 mentioned it’s not possible yet). As a result, I’ve coded a fairly simple diffuse lighting that has decent end-results, with plans to try and add more types of lighting as time allows. Hopefully this helps anyone trying to create landscapes.

I’ll probably do a few enhancements to the demo over the next few weeks. Longer term, I am going to continue working on the techniques in this demo and will be turning it all into a full terrain system that I will publish. The type of terrain I am focusing on will be for open-world RPG style of terrains.

Here is a screenshot from the sample:


#2

I’ve posted a pretty big update to this sample. The system is no longer doing any self-rendering, and instead uses entity processors and render features to grab resources needed to create xenko base objects. This lets the terrain re-use anything within Xenko, such as lighting.

The major update I still intend to make to the sample is some mechanism to allow a character to walk on the surface. I am seeing if I can dynamically create a collision hull as my preferred method, but if that does not work out I will make a height-map-aware component that can be added to a character to keep them above the surface.

In-editor:

In-game:


#3

Interesting idea–making a height map/mesh aware component and rendering off that information. For games without physics this would surely work. I wrote a terrain hugging method for an moba/rts like project I was working last year, pretty simple. Basically the unit model entity adjusted yaw/pitch/roll inside of the parent character entity based on a number of raycasts.

One question I would have, would it be possible to split the map into sections and pass smaller sections into the hull collider? It works decently enough on rudimentary shapes/objects.

-Jarmo


#4

Well, my intention with how I’m writing the terrain demo / future project is that you create your world by using many of the terrain tiles. Each tile is itself supposed to be small enough and simple enough to have a mesh and collider that’s of reasonable complexity.

Luckily with the help of some people in the discord server, I was able to get Bullet’s height field collider “working” enough to be the collider implementation. (quotes because it’s not matching the visual mesh, but that’s because I believe the collider self-centers with some rules I don’t understand and need to research more, but I get the overall reason why lol).


#5

Hello to the community. I do not speak English very well, but I will try to express my thoughts clearly. I believe that sections in the terrain will simplify execution a lot. Say, square sections of size 100x100 with adjustment of the quality of the texture, which is baked for the surface. And these sections are added as needed. I think this approach is not news, but optimal. This is a personal opinion from the beginner :slight_smile: