Search Unity

Replacement Shader with Per-Object Instance/MaterialPropertyBlock Values?

Discussion in 'General Graphics' started by Recatek, May 2, 2020.

  1. Recatek

    Recatek

    Joined:
    May 2, 2020
    Posts:
    30
    I know the traditional way to do effects like an outline is to first render the scene with a replacement shader, and then read that custom buffer and use that information to draw the final effect in a fullscreen pass to the camera.

    For an effect I'm working on, I'm trying to draw surfaces to a custom buffer where each object writes a different color to the buffer based on some per-object material property (e.g. this object draws purple, that object draws red, etc.). Is there a way for the replacement shader to use a per-object instance property or MaterialBlock for each object, in a single pass?

    This is using HDRP, for reference, where so far it looks like I can only override materials rather than shaders in a custom pass. Unless I'm missing something.
     
    Last edited: May 2, 2020