|
I'm working on a set of custom shaders to override Unity's built-in terrain shaders. When I add the "alpha" parameter: ...suddenly distant terrain trees start drawing on top of nearby terrain hills — it looks as though the terrain shader is no longer writing to the Z-Buffer. I have Any ideas about how I can fix this?
(comments are locked)
|
|
I believe it's a problem specific to Terrain, and can't really be solved. Transparent objects need to be drawn back to front(?) after everything else. But, Terrain is drawn by a special routine -- the ground is cut up on the fly into squares, each subdivided based on LOD, then drawn probably outward from the player (for efficiency.) It's probably also run 1st, also for efficiency (these are just guesses.) I tried a transparent shader with only Terrain, maxed out the "use low-res overmap" setting, and got the same occasional completely transparent hill. Transparent terrain didn't even draw correctly with itself, never mind trees. Interesting. Thanks, Owen. I would have assumed that, even if the terrain is being drawn by a special segmented geometry renderer, it would still obey shader parameters as usual — but it looks like some internal magic is going on here.
May 23 '12 at 03:24 AM
smokris
I imagine the chunks could be created and then sent for general rendering. But, for example, each chunk of the same LOD has the same Triangle array. So, the terrain renderer can save time by only sending that once.
May 23 '12 at 01:22 PM
Owen Reynolds
(comments are locked)
|
|
as you use own shader you just need terrain be rendered before trees and writes it's depth to z-buffer, then on tree-drawings stage z-buffer will hide far trees. just try to decrease queue (in shader parameters) value for terrain shader, to be lower then for tree shader
(comments are locked)
|

