iopprojects.blogg.se

Unity terrain textures
Unity terrain textures













unity terrain textures unity terrain textures unity terrain textures

Material Distribution simulates the values of the splatmap where 0.7 means 70% texture A and 30% texture B.ĭepth is the value as described in the section “Masked Depth blend” Its a simple Monobehaviour that can blend two material textures and visualize the result. The provided unitypackage was created with Unity 2018.3.6f1 and contains this shader as well as a simple tool to help demonstrate the blending technique of this article. Depending on the needs of your game, you might even consider disabling the shadow casting functionality of you terrain and save up some performance. In our project we are using a more adjusted lighting solution. The lighting in the provided shader below is taken from the unity documentation example shaders. This will drastically reduce the performance of your draw call due to cache misses when rendering distant parts of your Terrain, so better make sure they are enabled! If you wanna use this shader in other circumstances, like for example for a first person shooter, where mountains often block the players view, you might consider not to use this optimization.Ī common mistake is to disable the mipmaps on your material textures.

unity terrain textures

We can do this because in our game the Terrain rarely occludes other geometry. This way we can make best use of the zbuffer to only draw pixels that are not occluded. This usually allows us to have 4 different terrain materials, however a fifth one can be implied serving as the base material where no other materials are set (1 – (R+G+B+A))īecause this shader uses a lot of texture reads per pixel drawn on the screen, it makes sense to use a higher render queue than all other opaque world geometry. (For example a pixel containing 50% stone and 50% sand would correspond to a pixel value of RGBA (0, 0.5, 0.5, 0)) The percentage of material on a pixel is mapped to a range between 0.0 and 1.0 and written in its corresponding color channel. We will assign one material to each channel of our splatmap (for example Dirt = Red channel, Stone = Green channel, Sand = Blue channel, Soil = Alpha channel). Every channel in in a texture holds a floating point value ranging between 0.0 and 1.0 for every pixel. In the example picture we use 2 pixels per meter of terrain.ĭepending on chosen texture format, the splatmap can make use of all the four color channels Red, Green, Blue, and Alpha. The resolution of the splatmap is defined by the size of the terrain and the required amount of detail depending on your game. Those material textures are provided to the shader separately.Ī set of materials a Terrain might use (Grass, Dirt, Stone, Sand and Earth) This texture is not rendered directly, but is used as an information source instead, to specify where on the terrain, what material is supposed to be drawn. With this technique a so called splatmap texture is provided to the shader. This obviously does not scale.Ī common solution to tackle this problem is Texture Splatting. If you’d wanted a texture for this, the floor in this scene alone would require a texture of 3072 * 3072 pixels minimum. There are about 12 * 12 cells visible on the screen right now. In this example scene every grid cell consists of a texture of 256 * 256 pixels. Let one artist draw a lot of beautiful grass and tiny rocks by hand and the world will look amazing! Well in theory this would indeed result in astonishing visuals, in most cases this will result in a performance and workload nightmare. You create a mesh and simply put a texture on it. This shader supports up to 5 different materials in a single mobile friendly draw call.Ī naive approach of texturing the Terrain would be to treat it like another asset in your scene. It will describe the concepts of Texture Splatting and our blending technique. This article is about a Terrain Shader we developed at InnoGames for one of our upcoming Unity projects. So, getting the visuals and performance right is important and a bit more complex than one might initially expect. Besides beautifully textured buildings, plants and creatures that inhabit your world, it is often the ground that will fill up most of the space of your scene. A lot of games these days are offering huge game worlds for the players to explore.















Unity terrain textures