Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Outline effect using HDRP

Discussion in 'Graphics Experimental Previews' started by Xerioz, Oct 11, 2018.

  1. Xerioz

    Xerioz

    Joined:
    Aug 13, 2013
    Posts:
    104
    For the scene in editor there seems to be something called "SceneSelectionPass" @ Unlit.shader, I'd like to use the same effect for the in-game selections. How can I achieve that?

    Note that I'm fairly skilled at low-level rendering techniques, but I have yet to dive into HDRP source code.
    Does this require me to fork and modify HDRP to my needs, or can Unity's RP be somehow extended to include such feature?
     
    Jick87 likes this.
  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    289
    You probably won't be able to use it as is.
    But basically, this selection pass shader is used to render a buffer with object ids that is later on used in the scene view in a post process to draw the outline.
    You could probably implement something similar by using a custom post process and render you in-game selected object in a separate render texture as a mask.
     
    Xerioz likes this.
  3. Xerioz

    Xerioz

    Joined:
    Aug 13, 2013
    Posts:
    104
    So the way to go is through PostProcessing Stack ?
    If I understood it correctly, inside of a custom PostProcessEffectRenderer, I would have to re-render the object I want to outline with my shader and merge it with the final image buffer. An example would be nice to have, otherwise I'll look into myself later and see if I can figure out. Thanks!
     
  4. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    I previously participated in this thread which may be of some use possibly. Not sure how well (or if at all) it will translate to working in an SRP, but maybe it is a starting place. :)

    If you end up figuring anything out please do share. ;) I will probably try playing around with some things myself as well once I get some free time.
     
  5. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    319
    Remy, could Unity consider implementing outline effects from the scene window? It works well with the HDRP and all released Unity versions. We might have to add in some extra filtering and passes to make it more in-game presentable but it seems like a good standard feature to be included.
     
  6. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    289
    Maybe you should go to the feedback site and ask for the feature : https://feedback.unity3d.com/
    I'm not sure it's an absolute necessity. I don't know the proportion of games that need a selection highlight for example.
    And for those who need it, maybe they don't want it to be exactly how the selection in the editor is done...
     
    GameDevCouple_I and hippocoder like this.
  7. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    489
  8. vanderFeest

    vanderFeest

    Joined:
    Apr 12, 2017
    Posts:
    2
    I've written a simple version for the stack, will put the first rough version on the Asset Store for free soon. (As I also noted in the Feedback thread)
     
    Jick87 and Xerioz like this.
  9. Xerioz

    Xerioz

    Joined:
    Aug 13, 2013
    Posts:
    104
    Thanks @vanderFeest,
    I assume this is what you were talking about: https://github.com/IronWarrior/UnityOutlineShader

    I did a quick test to see if I could outline only certain objects and here's the result:
    upload_2019-2-13_18-46-24.png

    This isn't exactly a proper solution but a lazy one nonetheless.
    The way I did it is using two cameras, one to render the scene and another one with this postprocessing applied ( without RenderReplacementShaderToTexture ). One camera renders everything except Outline layer, while the second camera renders only Outline layer, depth clear and with this PostProcess effect applied.

    edit:
    Actually it draws over every other object, not a good lazy solution. So ignore this :)
     
  10. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,627
    Xerioz likes this.
  11. Xerioz

    Xerioz

    Joined:
    Aug 13, 2013
    Posts:
    104
    I must've missed that one, thanks!

    Time to open my wallet.
     
  12. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    50
    Our asset now is not working with PPSv3 (in new HDRP), but you can try use something similar.
     
  13. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    531
    pretty much every fps game, every prg game, strategy, simulators, yes pretty much most of them use this in combination with some additional fill.
     
  14. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    319
    Remy,
    Pretty much all FPS/TPS games use it for showing selection, possible selection and in world highlighting.
    All tycoon/RTS games live off on this as mouse over effect is absolutely a must.
    Any 3d game with a tutorial will probably use outline effects to guide the player.

    The proportion of games is definitely very very high and something this obvious should not be going through "feature-request-channel". The real question should be the feature set of the implementation and the performance increase by having a built in component. Seriously we have deferred decals, atmospheric scattering, subsurface scattering, vertex animation, 20+bone weight support, cinematic post processing and all the cool stuff that blows any developer's mind, but here we are thinking if outline effect should be included... :D
     
    zhuchun, OfficialHermie and Flurgle like this.
  15. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,923
    V3 post stack will accept custom post effect in 2019.2 onward from what I read, around that time in the future.
     
    zhuchun likes this.
  16. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    482
    @eizenhorn I just wanted to purchase your asset, but you have really bad reviews, and you don't respond to them. Can you have a look?
     
  17. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,627
    This is not my asset (if you told about outline asset) :) it’s @Chaiker asset
     
  18. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    482
    Ohhhhh, sorry, ok, now I understand it. You posted this asset to tell that one can learn how to do it by buying this asset and taking a look at the sources.
     
  19. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    482
    I would like to vote for an Outline system done by Unity. It seems to be connected very closely to the render pipeline / shaders, etc.
    Therefore I think it should be Unity's work to provide such an Outline function, and it would also serve as a test scenario for them.
    Thank you.
     
    PixelJ likes this.
  20. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    482
    Can you explain what this means for an Outline effect?
     
  21. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    33
    Quick update here, with the HDRP release 7.2.0 on 2019.3 you will now be able to do custom post process, the way they are done is a bit similar to the system we had in the post process stack V2 except that there are three injection point in the HDRP render loop: before transparent, before post process and after post process.

    There are also Custom Passes that are coming along with the 7.2.0 release, it will allow you to do some more complex effects that requires multi-pass or to draw meshes. Some example of custom pass can be found here: https://github.com/alelievr/HDRP-Custom-Passes (along with an outline custom pass).
     
  22. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    231
    Custom postprocess is available in 7.1.2, I am successfully using it right now.