Search Unity

[FREE] [OPEN-SOURCE] Outline Effect

Discussion in 'Assets and Asset Store' started by cakeslice, Mar 28, 2015.

  1. briank

    briank

    Joined:
    Mar 25, 2017
    Posts:
    74
    Great outline effect. Thanks for sharing and maintaining this. It's much appreciated!

    The jittery-ness of temporal AA seems to be very exaggerated on the outline effect. While jitteriness may be expected to a small degree with TAA, when compared to the rest of the scene, the outline really dances around :)

    Reducing the jitter spread of the TAA settings makes it less noticeable, at the cost of more aliasing. If you think there is something that could be improved in the implementation to make this effect play more nicely with TAA, it would be great!!
     
    feldondragon likes this.
  2. IDONTWANTGOGIVEAUSERNAME

    IDONTWANTGOGIVEAUSERNAME

    Joined:
    Feb 23, 2015
    Posts:
    1
    Hello there, I really love your Outline Effect! :) I stumbled upon a problem where activating the effect produces an oil film like effect, independend of camera hdr. Any ideas what could be causing that? Thank you!
     

    Attached Files:

  3. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    said:
    This line was already uncommented in the version I downloaded it, but sprites with negative scales don't work either way for me.
     
  4. DiegoMRivera

    DiegoMRivera

    Joined:
    Jan 30, 2016
    Posts:
    1

    I have the same problem described by JustinBondy in 2). it works perfectly on editor but when compile to android none show up. I try a lot but i cant find a solution
     
  5. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    I did some tests and it seems to jitter less if applied before TAA. As for the ridiculous jitter if applied after, it's because for some reason TAA is applied after everything is rendered apparently, regardless of the order.

    If anyone knows Unity's post-processing stack well and the TAA implementation that could help that would be great!
     
  6. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Please send me a project that reproduces the issue.
     
  7. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Even if you toggle "Backface Culling" to false in the component? (before hitting play)
     
  8. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    How many devices did you try it on and which devices? There will always be some Android devices where it will not work...

    Also keep in mind this effect isn't really optimized for mobile devices
     
  9. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    Yes.
     
  10. Antarsoft

    Antarsoft

    Joined:
    Mar 21, 2014
    Posts:
    17
    First thanks for this good plugin.

    I'm using it for 2D Sprites but I have an issue with depth.

    For example I have a sprite with sorting layer 0 and another with 1
    basically the sprite with (1) will render over the one with (0)

    So I apply the outline on the sprite with (0) sorting

    The sprite (1) renders on top of sprite (0) but the outline still appears over the sprite (1)

    Anyone had the same issue ?
    I'm using unity 5.6.2f

    Thanks
     
  11. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Well in that case please send a project that reproduces the issue.
     
  12. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    This is how the effect is supposed to work, you have to use "erase renderers" to hide the outlines if you wish to do so.

    In the demo scene there's an example of this, a cube that is on top of an outline (it has an outline component with the option "Erase Renderer" on)
     
  13. Deleted User

    Deleted User

    Guest

    The outline effect looks really great. But in one of my scenes it disappears from all renderers that have Light Probe Proxy Volumes enabled. It works with normal Light Probes though.

    In another scene, the outline doesn't disappear entirely with Light Probe Proxy Volumes, but it gets weirdly shaded and totally discontinuous. With this "fix"...

    Code (CSharp):
    1.             o.Albedo = _Color * alpha;
    2.             o.Alpha = alpha;
    3.             o.Emission = o.Albedo;
    ...the situation gets improved, but not when I disable Backface Culling.

    I can't share the scene easily, but maybe you still have an idea why Light Probe Proxy Volumes don't work well with the effect?

    Thanks!

    Sean
     
  14. Deleted User

    Deleted User

    Guest

    I could solve this by making the same shader modification in OutlineBufferCullOffShader.shader.
     
  15. DavidMemini

    DavidMemini

    Joined:
    Jul 18, 2017
    Posts:
    1
    Hi there, first of all this is amazing and exactly what I need but can't seem to access the Outline class on the object in code at run time. What I want to do is turn the outline on and off at runtime but can't seem to access it? If you could assist me I'd much appreciate it.
     
    WallHackJack likes this.
  16. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Hello, thanks! To turn the outline on and off you should use "GetComponent<Outline>().enabled" and set it to true or false on the target GameObject
     
  17. WallHackJack

    WallHackJack

    Joined:
    Feb 6, 2016
    Posts:
    2
    There's a pretty big bug that can happen when you have outline attached to an object, you instantiate it again, and then add a 2nd outline effect to the same object. The result is no errors are shown in console, but upon approaching the object all of it's materials are deleted and replaced with "something-something-outline-buffer", but like 20 of them.

    Here's the code I was using that did this. The bug was caused because one of the objects this script attaches an outline to already had an outline component, leaving it with two outline components

    Outline newOutline;
    List<Outline> outlines;
    float outline_max_distance = 1.5f;
    float outline_alpha = 1;
    float outline_max_alpha = 1;

    private void CreateOutlines(){
    if(outlines == null) outlines = new List<Outline>();
    outlines.Clear();

    if(gameObject.GetComponent<Renderer>() != null){
    newOutline = gameObject.AddComponent<Outline>();
    outlines.Add(newOutline);
    }else{
    foreach(Transform child in transform){
    newOutline = child.gameObject.AddComponent<Outline>();
    outlines.Add(newOutline);
    }
    }
    newOutline.color = 0;
    }



    private void UpdateOutlines(){
    foreach(Outline outline in outlines){
    outline.enabled = (distance_to_player < outline_max_distance);
    outline_alpha = outline_max_alpha;
    if(outline.enabled && distance_to_player > outline_max_distance*0.5f){
    //outline_alpha = 0 + - (distance_to_player - outline_max_distance*0.5f)/0.5f)*outline_max_alpha;
    }
    }
    }


    Also @DavidMemini, you must be "using cakeslice" to reference Outline via script

    Also @cakeslice love you
     
    Last edited: Jul 23, 2017
    cakeslice likes this.
  18. anicecompany

    anicecompany

    Joined:
    Jul 29, 2015
    Posts:
    17
    Is it possible to add this to a RawImage somehow? (I want x amount of objects/meshes to have a nice outline)
     
  19. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Thanks! I think this is already fixed in the latest version on GitHub, can you please try it?
     
  20. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Do you want to apply it to a RawImage with transparency? What does that have to do with objects/meshes?
     
  21. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    Brutal Memory leak: Simply start the Demo scene and press 'K' often and watch Unity burning through all available memory.
     
  22. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Are you using the latest version? It generates garbage, but it gets collected, doesn't look like a leak...
     
  23. jayfelsman

    jayfelsman

    Joined:
    Jul 24, 2013
    Posts:
    11
    Hi cakeslice. I really like the effect of this shader. Is it hard to change the shader to work on objects with multiple materials?
     
  24. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    @cakeslice, I downloaded the version yesterday with Unity 5.6.0p3. Maybe the newest version is not in the asset store for this older version? I encountered that with other assets from the asset store.

    My PC crashes because it runs out of memory before any GC happens, so I don't think anything gets collected - also the used memory does not reduce anymore.
     
  25. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Hello, it already works for objects with multiple materials (but all of them will have the same outline color)
     
  26. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    That is really wierd, can you see what happens in a build instead? Maybe it's an editor bug of that specific version...

    If it still happens, can you try it in Unity 5.6.3?

    Thanks
     
  27. jayfelsman

    jayfelsman

    Joined:
    Jul 24, 2013
    Posts:
    11
    Ahh ok Thanks for the reply. I must be doing something wrong. I added the outline component to an object with multiple materials but the outline only appears around the part of the object that has the first material.

    Might be my mesh or something. I will have to work it out.

     
    Last edited: Aug 4, 2017
  28. jayfelsman

    jayfelsman

    Joined:
    Jul 24, 2013
    Posts:
    11
    Just an update. its doing it for every one o
    f my multi material objects :/ I must have something else conflicting with it.

    Edit :

    New project simple model with a cube that has half and half of 2 materials.



    Only the first material has the outline.

    Unity 2017
     
    Last edited: Aug 4, 2017
  29. fiLLLip

    fiLLLip

    Joined:
    Jul 7, 2017
    Posts:
    2
    I have a similar problem. I add the component programmatically, and it works fine for my single material objects. On multi material objects, it only get added to one part. I am also changing material programmatically, and then the outline disappears totally, even when removing the Outline component first and trying to readd it.
     
  30. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Are you guys using the latest version? The effect now handles multiple materials in a better way and shouldn't have those issues
     
  31. Tointer

    Tointer

    Joined:
    Mar 10, 2017
    Posts:
    5
    Hi. I'm new in Unity, sorry if question is stupid.
    I need for Outline to be disabled at start of the game and enabled when Player looks at object. But when I disable it in the editor, in Game nothing change. I think its becauce of this code in OutlineEffect script:

    private void OnEnable()
    {
    Outline[] o = FindObjectsOfType<Outline>();

    foreach(Outline oL in o)
    {
    oL.enabled = false;
    oL.enabled = true;
    }
    }

    Can i just delete "oL.enabled = true;" ? This will not break the whole system? If it is, how can i accomplish my task?

    Thank you.
     
  32. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Hello, you have to enable/disable the Outline component, not the OutlineEffect.

    Example script (needs to be applied to the object with Outline component):

    In the Start() function: GetComponent<Outline>().enabled = false;
    Then in Update() if looking: GetComponent<Outline>().enabled = true; (or false if not)
     
    Last edited: Aug 8, 2017
  33. Tointer

    Tointer

    Joined:
    Mar 10, 2017
    Posts:
    5
    Sorry, I explained it wrongly. I enable/disable Outline component. But OutlineEffect grab Outline component in OnEnable() and make this:
    oL.enabled = false; //1
    oL.enabled = true; //2

    I fixed it by simply swap this commands (1 and 2), so after OnEnable() all Outline components ends up disabled. Your solution with disabling it in Start() working too, by the way. Thanks.
     
  34. jayfelsman

    jayfelsman

    Joined:
    Jul 24, 2013
    Posts:
    11
    I created a completely new project with the latest outline effects installed. added nothing except the mesh and the outline asset.
    Added an outline component to the mesh and and outline effect component to the camera.

    Same result.



    Unity 2017



    Edit :

    This is Unity 5.6

    Exact same setup as above.

     
  35. jayfelsman

    jayfelsman

    Joined:
    Jul 24, 2013
    Posts:
    11
    I found that the same simple scene above if outline is turned on and unity editor just sits there for an while the memory usage goes through the roof and causes my pc to crash. It can sit there forever without the components attached and no memory increase.

    Components not added.


    Outline Components added and unity left to just idle.


    Wonder if the memory leak is associated with the outline on multiple materials object.

    Zipped Project.
    https://www.dropbox.com/s/mmjsw4sv2dtsuc3/Outline.zip?dl=0
     
  36. fiLLLip

    fiLLLip

    Joined:
    Jul 7, 2017
    Posts:
    2
    I am using the latest version, just downloaded from Asset Store and reimported. Same result. It does not handle changing material on a model, and then trying to activate the outline again either.

    The app works as following:
    1. Start app (blank Tango scene)
    2. Add object to scene by pushing button (ok)
    3. Touch object in scene to select (ok, outline is added to whole object on some models, and partial on others)
    4. Touch button to change material (material is changed, and outline disappears)
    5. Deselect object by button (this should remove outline and works if not changing material first)
    6. Touch to select object again (this should add outline and works if not changing material first, but does not add outline if material is changed)
    Using this snippet to change material
    Code (CSharp):
    1. Renderer renderer;
    2. for (int i = 0; i < _activeObject.transform.childCount; i++)
    3. {
    4.     renderer = _activeObject.transform.GetChild(i).GetComponent(typeof(Renderer)) as Renderer;
    5.     renderer.material = material;
    6. }
     
  37. xFeXx

    xFeXx

    Joined:
    Aug 7, 2017
    Posts:
    5
    I have the same Problem jayfelsman described.
    I have a multi texture gameObject and only one texture gets outlined. If the gameObject has only one Metarial, it works perfect, without memory leaks or anything else.
    The Outline script gets attached by touch. No enable stuff just add and destroy.

    upload_2017-8-7_18-46-59.png
     
  38. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    You guys are right, I will release a fix soon for the multiple material, material switching and memory issues.
     
    xFeXx and Alverik like this.
  39. jayfelsman

    jayfelsman

    Joined:
    Jul 24, 2013
    Posts:
    11
    Awesome, thanks cakeslice. The style this outputs is perfect for my project and I have been looking forward to implementing it :)
     
  40. xFeXx

    xFeXx

    Joined:
    Aug 7, 2017
    Posts:
    5
    Thanks alot! As I use this for my masters thesis App, can you estimate how soon this fix will be released?
    Really great work cakesclice!
     
  41. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Alright, it's done!

    You can get the fixed version on GitHub or wait for the Asset Store update.

    Have fun!
     
  42. jayfelsman

    jayfelsman

    Joined:
    Jul 24, 2013
    Posts:
    11
    Thanks a lot!
     
  43. trilobit

    trilobit

    Joined:
    Feb 17, 2015
    Posts:
    2
    Hi, Is there a way to make outlines work form UI images? They do not have Sprite Renderer component but Canvas Rendrer. When I try to add Outline script to UI Image not supported Renderer error happens.
     
    StuartKemp likes this.
  44. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Sorry but this isn't supported and I still have to figure out how I will do it, maybe one day...
     
    StuartKemp likes this.
  45. xFeXx

    xFeXx

    Joined:
    Aug 7, 2017
    Posts:
    5
    Hi cakeslice,

    sadly after the update my models look exactly the same as before. still only one material gets outlined...
    Do I have to change anything in my code?
     
  46. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Hello,

    No, I don't think so. Can you give me a project that reproduces the issue?
     
  47. xFeXx

    xFeXx

    Joined:
    Aug 7, 2017
    Posts:
    5
  48. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
  49. xFeXx

    xFeXx

    Joined:
    Aug 7, 2017
    Posts:
    5
    Works like charm!
    I have two broken models, where it does not work, but i can live with that. Thank you!
     
  50. Discord

    Discord

    Joined:
    Mar 19, 2009
    Posts:
    1,008
    Hey cakeslice, first off I just want to thank you for this asset, it's wonderful.

    I have a quick question. I wrote a basic diffuse shader with some vertex movement to simulate wind on some objects. Unfortunately, those changes aren't picked up by the outline shader. Can you point me in the direction I should go to fix that? Attaching a photo to demonstrate the issue.