Search Unity

Question HDRP Custom Pass with More Filter Options Besides Layer

Discussion in 'High Definition Render Pipeline' started by SecretGardener, Jan 17, 2024.

  1. SecretGardener

    SecretGardener

    Joined:
    Feb 23, 2021
    Posts:
    29
    There could be a solution somewhere but I'm too unfamiliar with shader stuffs, so I think it I'd rather post a new thread to ask.

    I want that when an object is selected, there's an outline around it. I found a pretty good example here: https://github.com/alelievr/HDRP-Custom-Passes?tab=readme-ov-file

    The only problem is, since we use physics and layer to determine which objects could be selected already, I can't rely on layer to determin which object to show outline.

    I tried to play with the rendering layer mask of the mesh renderer but I couldn't make it.
    What I tried is to modifiy 02_Selection_Objects.shader:
    1. Add "_renderingLayer("RenderingLayer", int) = 0" in Properties
    2. Add "uint _renderingLayer;" in SubSahder Pass
    3. In void GetSurfaceAndBuiltinData add:
    if (builtinData.renderingLayers != _renderingLayer){
    builtinData.opacity = 0;
    }

    But it's not working as I expected, no matter what the rendering layer mask of the mesh renderer is, I'll have to set _renderingLayer to 0 to make it have an outline.

    I do have a work around, though, that is to stick with the original way the custom pass is, and whenever I need the object to have outline,I copy it, gives it an alpha clipping material, and set it to the custom pass targeted filter. But I think it's a rather important feature so I'll be glad to know the proper way to handle this situation.
     
    nightdriveinteractive likes this.
  2. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    437
    I am also interested in that. I feel that the layers being used for both physics and rendering in that case shows it as a bad design. I would be able to filter objects for custom passes with more ways, for example the InstanceID/ObjectID would be really awesome.
     
  3. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    326
    Or just sending a list of whatever objects you want, rather than relying on some sort of filter parameters.
     
  4. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    437
    this!
     
    nightdriveinteractive likes this.
  5. nightdriveinteractive

    nightdriveinteractive

    Joined:
    Jul 10, 2023
    Posts:
    11
    I also second this.