I have a MiniMap camera floating above my scene, and I want it to render my terrains without rendering the vegetation on them.
I have a script attached to the camera, the relevant parts of which are included below.
The script sets the terrain's terrainTreeDistance and terrainDetailDistance to 0 before the camera renders, and after the camera renders, it resets the terrain to it's previous state.
Interestingly enough, the minimap camera renders trees on the terrain even with this script present. I know the script is properly changing the terrain vars, because if I remove the OnPostRender() section of the script, the trees disappear.
It looks like the terrain object defers the application of my settings 'till after the camera has rendered, by which time it is too late to do any good. Could this be possible, and if not - what else could I be doing wrong?
Ryan Scott suggested that I use shader replacement to hide the trees - and I may end up needing to - but I would much rather save the terrain object all the work of feeding the trees to the graphics pipeline to begin with.
asked Dec 17 '09 at 04:19 AM
How about making duplicate terrains on a different layer, which are the same as the regular terrains, but without vegetation? If you remove the terrain collider so there's no additional performance hit, I think the only drawback would be taking up extra memory.
answered Jan 16 '10 at 07:45 AM
Note: I attempted to post this as a comment on my original post, but the answers software wouldn't let me because it said my post was locked or deleted. This site sure is full of bugs!
I just attempted altering the tree's layers at runtime, but although Unity gives no errors - the trees still render on the terrain layer...
If it would work, this would be the most elegant solution of all!
answered Dec 17 '09 at 04:47 AM
Can the different cameras have different culling properties with respect to layers? Then you could assign the trees to a vegetation layer permanently, and not worry about changing layer at runtime.
answered Dec 17 '09 at 05:15 PM