Search Unity

How to draw GameObject hierarchy on two layers?

Discussion in 'General Graphics' started by Coolthulhu, Aug 16, 2019.

  1. Coolthulhu

    Coolthulhu

    Joined:
    Nov 4, 2016
    Posts:
    4
    I'd like to render an object and its children on two cameras: one "main" one, that renders Default layer, one used for post-processing and rendering only a small subset of objects.
    Is there a way to do it without manually re-layering the entire hierarchy every frame, or manually syncing a copy of the objects to render?

    Ideally, I'd like it to:
    • Work for animated objects without having to manually correct/copy values every frame
    • Don't depend on specific renderer types
    • Allow substituting materials or shaders at draw time
    • Not be incredibly slow
    I would use it for Left 4 Dead style outline. Some objects would be drawn on screen, then, with a different shader (one uniform color, no shading) to a texture, which would then be blurred and blended with the screen. The outlined objects could be obscured by other renderables, but the outline would still show as if there was nothing between the camera and the outlined objects.