- Home /
Can we use a terrain-style splat shader on custom ground geometry?
We're well under way on our first Unity-based project. The ground is already built in Maya (and will continue to see some edits), so for this project we cannot use the Unity terrain system. Still, we are hoping to find a way to use a single texture to define some good terrain texture blending, specifically to use RGBK values to combine four diffuse/detail shaders, and if possible to add an alpha channel to define some black as necessary. I see a lot of discussion of splat shaders here, but i'm new to Unity and most of what i see predates version 3.4 and the rest is over my new-to-unity head... i could use some solid info to share with the engineers so i don't waste their time if we need something written here. Any thoughts?
Answer by Owen-Reynolds · Dec 08, 2011 at 01:21 AM
If you look the the downloadable builtin_shaders->Terrain->Splats folder, AddPass is what Unity uses. It does the obvious thing, and is short. They use rgba for 4 textures.
The trick is to set it up -- control texture stretched over the whole thing, splats scaled the way you want. And to get a good way to paint the control texture. That stuff is hidden in the Terrain script, but isn't too bad.
Thank you, that is a huge help! It took a little while to implement this in the scene and convince it to generate predictable results, but most of this was in exploring different texture file formats and generating some base-line sample textures for testing.
I still have some trial and error to do, but for now you've become my own personal savior. Cheers!
Hello Owen, I've got the AddPass shader setup on a plane in unity, but no matter which channel I set to 100% white in Photoshop (in the control texture), the shader seems to be stuck in a semi-transparent state.
Have you any experience with this problem?
Thanks for your time.
follow-up: Ins$$anonymous$$d of using the AddPass shader, i tried the FirstPass shader, and it seems to have solved my problem! Will this interfere with lightmapping later?
As a footnote: _Base$$anonymous$$ap doesnt seem to do anything for me!
Sorry -- they both work the same except Add has the extra Decal:Add
. Unity combines the 1st four ground textures with FirstPass, then "adds" (probably to a render texture) the rest in groups of 4 with AddPass. If you have 4 or less ground textures, you weren't using AddPass anyway.
If you read, _Base$$anonymous$$ap is used in the fallback shader. It's a low-res texture made ahead of time by blending everything together. It's used if your graphics card can't blend on the fly (and also for far away parts of the ground.) You can see it by setting Base$$anonymous$$ap distance really low.