Terrain for first person game

Hi,

I am new to BabylonJS, but I worked with other libs and frameworks before. I would like to start a first person adventure game / walking simulator project and I am wondering which technique I should use for the terrain rendering.
Currently, I am reading through the documentation and examples. I found the dynamic terrain section in the documentation. If I understand it correctly, it uses heightmap information in order to generate the terrain.
I am unsure whether this is suitable for designing a game world and placing entities in a level editor. My alternative idea would be to sculpt a terrain in Blender and import it (in this case I could also place my entities in Blender and export the positions to a scene file). However, I am afraid that one single big model for the terrain would harm the performance, since a terrain of that size (let’s say round about a square kilometer) would need some kind of LOD handling for parts that are further away (like mountains). On the other hand, it would allow me to sculpt caves into the terrain (in contrast to a pure heightmap solution).

Does anybody have any advice for me? Is there anything that I could use in order to dynamically load chunks of a big terrain model, or any hints how I could design a dynamic terrain (as in the documentation) and integrate it in some kind of scene editor?

Best regards and thank you in advance,
Carsten

1 Like

Hi there, welcome to the Babylon community! Your question about walking simulators is super relevant, since @syntheticmagus is working on “golden paths”, i.e, helping developers produce certain kinds of experiences, and a walking simulator is on the list of future golden path posts. :smiley:

But for now, there are a few discussions about dynamic/endless terrais that might be useful:
Dynamic Terrain extension, How to make infinite terrain? - Questions - Babylon.js (babylonjs.com)
Strategies for large terrains - Questions - Babylon.js (babylonjs.com)
Divide terrain in sections with specific data - Questions - Babylon.js (babylonjs.com)
High resolution terrain - Questions - Babylon.js (babylonjs.com)

I found them by searching for “terrain” on forum search.
Hope these can help a bit!

3 Likes

@cpfr : Welcome to the community :slight_smile:

I’m not a coder, but I do use Blender to build terrains so here are a couple built in two different ways.

  1. Flannan Isles and Castle

This terrain was built from a greyscale terrain displacement map of actual islands off the coast of Scotland.where there is a lighthouse that went dark on Dec 15th 1900 and the three lighthouse keepers disappeared. No lighthouse just a castle for now. Starts in ArcRotate Camera mode - scroll mouse in and out and rotate to look around. Hit the 'c" key to walk in the castle and terrain. Hit that key again to walk the walls (click to open doors) The towers, walls and doors are all instances, as are the rocks outside.

2: A graveyard.

This terrain was built by sculpting (carefully). The walls, ivy and trees were added and laid out in Blender as instances before exporting. The rocks, and small and large bushes were added as “thin instances” in the code.

In both cases the terrain was textured using an additional Babylon Script to mix textures.

Are those terrains big enough? Tthey were fairly easy to do and arranging various features also not hard

Stay Safe, gryff :slight_smile:

1 Like

Hey @cpfr Welcome to the Babylon Family!

We’re sincerely glad you’re here!

@carolhmj and @gryff have given some great suggestions.

I’ll add one other resource for you:

This video goes over the process for creating procedural terrain in Babylon.

I hope this is helpful!

4 Likes

Hi, thank you all for your answers and suggestions, I think I will need some time to go through all of these information. It’s cool that there is such an active and dedicated community for BabylonJS.

@carolhmj Thank you for the links. I discovered some of them before posting this, but I thought the topic in those posts was primarily procedural terrains (while what I want to do is the opposite – hand-crafted terrain, but with chunked loading / LOD or so)

@gryff Thank you for your examples. May I ask how your framerate is? In the first one, I have ~24 FPS, while in the second one (graveyard) I get around 16 FPS (both, Firefox and Chrome). To be fair, my PC is not a gaming machine in particular, but it runs other mid-end games fluently. Is the terrain in the graveyard scene just using standard UV mapping or do you use a terrain shader for blending sand, stone and grass texture together?

@PirateJC Thank you for the video link. I already knew that video, but I thought that its main point would be how to generate a noise for a heightmap. However, I’ll take a closer look at the second half.

@cpfr I get a frame rate of 60fps.

I don’t consider my PC to be a “gaming machine”. It is 5 years old and has an Intel i7 4,000 series CPU with 8gigs of RAM - I think they are upto 11,000 now. The video card is a 3 year old NVidia 1060 - I believe there are 1600, 2000, and 3000 series NVidia video cards now,

An as an aside, my PC can not upgrade to Windows 11.

So it is hardly the best of PCs.

Stay Safe, gryff :slight_smile:

It is a script that I use available for Babylon : Mix Material

Stay Safe, gryff :slight_smile: