- Home /
How do I blend multiple textures on a mesh?
I have made a custom terrain that simply creates a plane mesh with it's vertices set according to a heightmap(not in shader!). The reason I do not use the built in Terrain objects is that this approach is faster in my case even though texture blending might be easier on the terrain objects.
Now I want to blend multiple textures according to a reference map, it can be a texture used as an alphamap or any other possible approach that you know of. Note that I would like both diffuse and normalmaps to be applied to the mesh.
I did read up a little on splatmaps but I'm not sure if I can use them on anything other than terrain objects or even how to use them. Are they a possible solution?
Answer by Owen-Reynolds · May 31, 2015 at 05:56 PM
A shader can be written to blend multiple textures. The built-in unity terrain shader does this - it reads four textures, and blends them based on the fifth "splat map" texture (which is often called a control texture.) That's partly why Terrain is special - so the system knows to use this shader, with textures loaded in groups of 4 on multiple passes.
You can get the terrain shader and read the code, or just read up on shaders and control textures in general. The basic idea is colFinal=col1*splatCol.r + col2*splatCol.g ...
(where splatCol RGBA adds up to 100%.)
I haven't seen the new U5 universal shader, so it may have some shortcuts to do this (or not.)
I know this can be done easily with shaders though I'm a bit intimidated by the shader code used in unitys standard shader, because I want the shader to work and be as efficient as possible.
I was hoping the standard shader would do this automatically with no shader coding necessary though it doesn't seem like that.
Your answer
Follow this Question
Related Questions
How to rotate only the mesh and not texture/material in Unity 1 Answer
Splatmapping / blending between two textures in an atlas? 0 Answers
How can I blend a lot of textures on one mesh ? 5 Answers
Paint textures like on terrain but without terrain? 0 Answers
Generate collision mesh from 2d texture? 0 Answers