Right now I'm working on a project that involves applying splatmaps to a generated mesh. I'm trying to use the built in Terrain shaders to achieve this but I'm running into one problem that involves the "FirstPass" and "AddPass" shaders.
It's pretty clear how these shaders are supposed to work. FirstPass is applied and handles 4 textures and a control (splat) texture. If the user applies more than 4 textures, AddPass (which is very similar to FirstPass) is "added" as another shader pass at compile time. AddPass is added an arbitrary amount of times depending on how many textures the user applies to the terrain (4 textures per pass.)
How does the terrain engine achieve this multi-pass effect? The amount of passes required can be determined at compile time so I don't think its impossible... I just don't know where to go from here. I think it may have something to do with the Dependency properties at the bottom of FirstPass, but I'm not sure.
Dependency "AddPassShader" = "Hidden/TerrainEngine/Splatmap/Standard-AddPass"
Dependency "BaseMapShader" = "Hidden/TerrainEngine/Splatmap/Standard-Base"
If anyone has any insight on this please let me know. For convenience I've uploaded FirstPass, AddPass, and TerrainEngine.cginc shader files from the Unity archive to pastebin.
Thanks!