ethereumdegen / bevy_mesh_terrain

MIT License
39 stars 5 forks source link

Document how individual "tile" textures are applied to the overall map #5

Closed mattdm closed 10 months ago

mattdm commented 10 months ago

I can see that something is happening with https://github.com/ethereumdegen/bevy_mesh_terrain/blob/main/assets/terrain/textures/array_texture.png, but it's not at all clear to me. Is the "splat texture" like a tilemap?

ethereumdegen commented 10 months ago

There are 3 textures right now.

  1. Height Map Texture The source of height ! This is a grayscale image in R16 format and if values are totally dead black then the shader will actually make alpha == 1 right there so you can blow holes in the terrain for caves and such (youll prob want to put rock doodads there to make it look nice!)

  2. Color Array Texture This is the source of the actual terrain textures. In this configuration, there are only 4 different types you get in order to improve performance of the shader and gpu memory . So for example, grass, dirt, snow, and sand. You can edit that file of course for different looks. These pop through based on the splat map..

  3. Splat Map Texture This is an RGBA texture where the intensity of each channel controls the alpha of each of the Color Array Textures. So for example if the R channel is white and the rest black, the entire terrain will be grass. This is what you would typically edit in a 'terrain editor' to paint your grass in one area, dirt in another area, snow on mountains, etc.

This setup is extremely typical for most terrain shaders that I have seen.

mattdm commented 10 months ago

Cool, thanks! I understood the first part, but the RGBA splat map concept is new to me.