- Home /
Texture layers on single mesh
I have a little tile editor with procedurally generated mesh. Everything works fine with single texture, but i would like to be able to paint multiple layers on each tile. What it should look like:
I paint a grass on a tile by applying grass uv. Next I paint some flowers (as a second layer) on this grass, which I would like to paint from different texture. Then on another tile I paint the very same grass, but as a second layer now I can add, let's say, tree, which is located in the same texture as flowers. I want be able to remove these layers independently, so they can't be "hard painted" with texture SetColors.
I was wondering how is something like this achieved? First idea that came to my mind was creating meshes that would be offset by some small value (so every next layer would be on top of the previous one), but this doesn't seem like a good solution. I've seen similar effect in vertex painting (but I'm quite sure that my case is way way easier than vertex painting). Any ideas appreciated.
Offtopic: As I'm constantly learning all that graphics stuff, I was thinking about messing around with that vertex painting, but couldn't find any good source of knowledge on this topic. Does anyone know good one? Or could point me in right direction?
Answer by VesuvianPrime · Sep 12, 2014 at 11:20 AM
Hey Radwan92
This question may help you: http://answers.unity3d.com/questions/22961/multiple-textures-layered-in-a-single-mesh.html
I think your best bet is going to be writing a shader that takes multiple texture inputs and masks each one. I know this can be done very easily in ShaderForge, though this is not an inexpensive solution:
I've been there already, and, either it's not what I'm looking for or I do not understand it. The only thing you can control in your submesh are triangles (which hold verts indices). From my understanding in this situation you cannot have different regions of one texture applied on top of another, because you do not control uv. What it means is you can have flower on top of the grass or tree, but never both (one tile grass with flower, next one grass with tree). Or am I wrong?
You can do some really interesting things with shaders.
In the youtube video the author demonstrates how you can use the color channels of painted verts to control how different textures blend together. This behavior very much allows you to have multiple textures occupying the same space.
This isn't at all limited to vertex colors. You could paint your own black and white mask to finely control how different layers combine (for example stamping flowers over grass).
Do you have access to anything like $$anonymous$$aya or 3DS$$anonymous$$ax? Node-based shader editors are a lot of fun to play with, and you'll learn a ton about rendering.
Looks like I'll have to learn alot (shaders) before moving on. I have $$anonymous$$aya, but I didn't know I can make some shaders with it. Thank you very much sir.
Take a look at the hypershade! http://www.3dtutorialzone.com/tutorial?id=66
Your answer
Follow this Question
Related Questions
Repeating Images From an Atlas 0 Answers
How do I use many different tile textures for one mesh? 2D Tile based game. 2 Answers
Calculate UV coordinates of 3D point on plane of mesh's triangle 1 Answer
Repeat Texture instead of Stretching it all over? 4 Answers
Simple mesh deformation : Mesh.vertices or vertex shader with displacement texture ? 1 Answer