Using Maya 2012. I was wondering how to set up hypershade, to paint a mesh using several diffuse textures, with bump/normal maps. I want to use the RGBA splat map, and then export this splat map?
create 3 file nodes point to your diffuse 1 and 2 and the spalt map
create a blend node, hook the outColor of the first diffuse file into the Color1 of the blend, the outColor of file 2 into the Color1 of the blend, than take outColorR of the spalt and hook it up to the Blender of the blend node.
I was considering vertex painting but I realized, I cannot paint between verts, creating a more detailed look, like I could with a regular painting. Or at least with a splat map. Why is vertex painting a better solution? Final target is Unity engine. I think splat maps can create really nice looking blends compared to vertex painting, especially when the verts are sparse.
But hey I'll give this a try and see what I can do! Thanks for your help.
I tried out the paint brush tool in maya. It seems really great way to create a splat map, using RBG to paint. But I don't know how I could export this as a texture? Or this there a way I can paint with the hypershade set up like you have shown, and using the brush to blend them? Would still need to export a color map somehow. Hmmmm...
well with vertex colour you can share the same material and textures across lots of meshes, and instances.
in unity it is possible to get a plug in that let's you paint vertex colours in unity so you can also paint instances of meshes differently too.
the way to get around it only applying to verts, and causing gradients of colour between them, is to use a fall off mask. like say I was painting moss into a brick wall I could use the inverse of my heightmap to let me have the vertex blend, blend into the cracks and grout first.
vertex colour plays nice with overlapping uvs as well.
also say your painting a wall just add some extra geo to paint.
A few extra verts cost a hell of a lot less than a extra texture per prop.
You need to use a Layered shader in Maya, or some custom CGFX or HLSL -shader. Below is how you do it in Maya (instructions under the image) - but since your target is Unity I suggest skipping Maya altogether and just doing it in Unity.
Green arrows in the middle: outColor -> color
Yellow arrows in the middle: outAlpha -> transparencyR, transparencyG, transparencyB for the first material
outColorR -> transparencyR, transparencyG, transparencyB for the second. Then outColorG for the third material, etc
So the color (ARGB) channels from the splat map are feeded into the transparency channels for the materials
The yellow arrows to the right: outColor -> inputs[0].color and outTransparency -> inputs[0].transparency
So the outColor and outTransparency from each material is plugged into the color and transparency inputs on the layered shader.
It's not the best way to do it, but this works at least in Maya. Problem is that you are limited to 4 materials, which is why I think a custom shader would do it better.
I set up a duplicate mesh, and used it to paint the splat map, and plugged it into the set up shown by Deadly Nightshade. So now I can just paint it, and save it, updating the blend on the other mesh. I tried using some test textures, and just painted some pure red. But there is a issue, the texture assigned to the red channel appears to just be black.
Do I need to use file types with an alpha channel for the 4 textures? Do I need to use a special material (Im just using lamberts)?
EDIT: I tried using targa image for the red channel, still not appearing correctly.. strange. I have noticed the red channel painted area is making the mesh transparent though.
If I set the material to surface shader and turn down out transparency to 0, it becomes nontransparent finally.. but still doesnt represent the texture assigned to it, its just grey.
I'm so torn about vertex color vs colormap(splatmap). At what point, if ever, does the amount of vertices vertex painted become worse performant than a 2048 or 4096 splatmap? I know vertex colors make some sort of copy of the mesh, but I'm not sure how harsh that can be on performance.
because its a massive piece of terrain. At least from player perspective. I meant like just the splat map would maybe be that large, maybe smaller. But idk, at that point I might as well use the verts if they're cheaper as you say. Plus it would be nicer to paint.
Well, if it's only one of the materials that are not working, then it's either one of the files that are broken (lack transparency/alpha) or you connected something wrong. I can upload my scene to you if you want?
But as passerby says, using a huge 4096 (or even larger) splatmap for a huge piece of environment isn't really worth it performance-wise. A custom-made splatmap-shader that works on the vertex colors is a much better idea for that. A coder at my last workplace made such a shader about a year ago when we were planning for a project that got cancelled, so I know that it's perfectly possible.
I've not worked with Unity before, but shouldn't there be any guides on how to work with large environments in general - and splatmapping in particular?
ya what you do, use use vertex colour + a smaller map, that influences how the textures blend via the vertex colour. This way you can vertex colour without too many polys, but it still has a nice edges too it.
I see. Well I bought a vertex painter for unity that comes with some shaders, so now I can use it for terrain also. I've learned how to create shaders too, so a good terrain shader should be managable. Thanks for the help
Replies
Final target would be Unity.
create a blend node, hook the outColor of the first diffuse file into the Color1 of the blend, the outColor of file 2 into the Color1 of the blend, than take outColorR of the spalt and hook it up to the Blender of the blend node.
very nice, thank you. Is there a way to paint a splat map on the fly with maya, blending them like that?
this would require a cgfx or hlsl shader in Maya but is a much better solution.
But hey I'll give this a try and see what I can do! Thanks for your help.
in unity it is possible to get a plug in that let's you paint vertex colours in unity so you can also paint instances of meshes differently too.
the way to get around it only applying to verts, and causing gradients of colour between them, is to use a fall off mask. like say I was painting moss into a brick wall I could use the inverse of my heightmap to let me have the vertex blend, blend into the cracks and grout first.
vertex colour plays nice with overlapping uvs as well.
also say your painting a wall just add some extra geo to paint.
A few extra verts cost a hell of a lot less than a extra texture per prop.
Green arrows in the middle: outColor -> color
Yellow arrows in the middle: outAlpha -> transparencyR, transparencyG, transparencyB for the first material
outColorR -> transparencyR, transparencyG, transparencyB for the second. Then outColorG for the third material, etc
So the color (ARGB) channels from the splat map are feeded into the transparency channels for the materials
The yellow arrows to the right: outColor -> inputs[0].color and outTransparency -> inputs[0].transparency
So the outColor and outTransparency from each material is plugged into the color and transparency inputs on the layered shader.
It's not the best way to do it, but this works at least in Maya. Problem is that you are limited to 4 materials, which is why I think a custom shader would do it better.
Do I need to use file types with an alpha channel for the 4 textures? Do I need to use a special material (Im just using lamberts)?
EDIT: I tried using targa image for the red channel, still not appearing correctly.. strange. I have noticed the red channel painted area is making the mesh transparent though.
But as passerby says, using a huge 4096 (or even larger) splatmap for a huge piece of environment isn't really worth it performance-wise. A custom-made splatmap-shader that works on the vertex colors is a much better idea for that. A coder at my last workplace made such a shader about a year ago when we were planning for a project that got cancelled, so I know that it's perfectly possible.
I've not worked with Unity before, but shouldn't there be any guides on how to work with large environments in general - and splatmapping in particular?