Search Unity

[FREE] [OPEN-SOURCE] Outline Effect

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

  1. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Hello, I don't have that issue, did you download the latest version and can you check if there's a layer named "Outline" in the scene?

    Also what's the Unity version you're using?
     
  2. destinyrocks

    destinyrocks

    Joined:
    Mar 18, 2015
    Posts:
    1
    I'm having a problem with the fill amount on device. I want the object to have an outline with no fill. It appears fine in the editor; having 0 fill only shows the outlined color on the object. But on device, if the fill is 0, there is no outline on the object.

    Any ideas what the problem might be?
     
  3. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Please provide more details: what is the device, Unity version, graphics API in Player Settings, etc...
     
  4. danBuonocore

    danBuonocore

    Joined:
    Aug 26, 2015
    Posts:
    12
    Cannot get this to work. Here is a screenshot of the demo scene after adding the "Outline" layer.

    I am using Unity 5.5.0f3 64-bit Professional.

     
    Alverik likes this.
  5. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    This is because you have anti-aliasing enabled (quality settings)

    As a workaround, use the "Flip Y" option in the Outline Effect component.

    It will be fixed in a later release.
     
    Last edited: Jan 20, 2017
  6. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Hello guys, the asset is now on the store and comes with a lot of improvements and fixes:

    Biggest changes:

    - Now to add an outline to a renderer all you need to do is add the Outline component to it

    - Better Outline Effect component inspector

    - Added option to scale with screen size (now is the default)

    - Added a better looking Demo scene

    - Performance improvements

    - Extra options:
    Fill Amount
    Additive rendering
    Add lines between colors
    Outline corners​

    - Bug fixes:
    No more "Outline" layer needed
    Flipped UV when MSAA is enabled
    Only the first material of meshes was being outlined
    Colors didn't look like in inspector
    Second line color had a bug in the outline shader​

    Check it out: http://u3d.as/FGk
     
    Last edited: Jan 23, 2017
    rakkarage likes this.
  7. BogdanDude

    BogdanDude

    Joined:
    Jun 18, 2009
    Posts:
    89
    Cool plugin!
    I think the 1.1 version has an error where the Outline Camera Culling mask is set to ~outlineLayer, I think it should be 1<<outlineLayer, so that the camera only sees the Ouline Layer, otherwise I keep getting artifacts even when no Outline script is placed on any of the mesh renderers.
    Great Job!
     
  8. PelleChristensen

    PelleChristensen

    Joined:
    Jun 10, 2014
    Posts:
    1
    A fine plugin. But the newest update cannot co-exsist with TextMesh Pro.
     
  9. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Thanks, can you elaborate please?
     
  10. pixpusher2

    pixpusher2

    Joined:
    Oct 30, 2013
    Posts:
    121
    Thanks for the asset!
    On version 1.1, the outlines weren't displaying correctly in my project (it gets hidden behind some objects). A simple change as shown below seems to have fixed the issue

    In OutlineEffect.cs, line 285:
    From:
    Code (CSharp):
    1. outlineCamera.cullingMask = ~outlineLayer;
    Change to:
    Code (CSharp):
    1. outlineCamera.cullingMask = 1 << outlineLayer;
    I had also encountered the class naming conflict with some other assets. A quick fix will be to rename the Toggle.cs script and class that came with the Demo to something else (calling it Toggle2 will do the trick).

    Cheers
     
  11. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Ok, the naming issue is already fixed on GitHub the other one I'll fix later, thanks for the feedback!
     
    pixpusher2 likes this.
  12. VisualTech48

    VisualTech48

    Joined:
    Aug 23, 2013
    Posts:
    247
    There is actually one feature I would like to see, and that is if you could change the outline color of each object, rather than having a global one
     
    JLowther likes this.
  13. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    Is it possible to add blur to the outline effect?
     
    JLowther likes this.
  14. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Right now the effect uses the Red, Blue and Green channels of a texture for each color. I tried doing unlimited colors before but there was a lot issues. Maybe in the future I'll try again.
     
    JLowther likes this.
  15. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Yes, it's in my TODO list :)
     
    nxrighthere likes this.
  16. ViktorKom

    ViktorKom

    Joined:
    Feb 24, 2015
    Posts:
    29
    Cool effect! :)
    But don`t support VR :(
     
    Alverik likes this.
  17. khudnall

    khudnall

    Joined:
    Aug 29, 2014
    Posts:
    2
    Really enjoying the effect right now, thanks for making it!

    I have a question about additive scenes with new cameras. Is there any way to support this currently? I did a brief look at the code and it looks like you keep a static reference to the OutlineEffect, so I'm guessing not, but I wanted to make sure I wasn't missing anything.
     
  18. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Sorry, but I don't have a VR headset right now so I can't test, it's in my issues list though
     
  19. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Yeah it doesn't support it. Can you tell me why you would need to render outlines in more than one camera?
     
  20. MasqueNoMercy

    MasqueNoMercy

    Joined:
    Apr 26, 2014
    Posts:
    5
    I downloaded the latest version of unity which should be 5.5.1 but i downloaded the version with the chairs demo and that seems to work. i was able to run the demo and get the glows to happen. My next step is to put the glow on a prefab.
     
  21. khudnall

    khudnall

    Joined:
    Aug 29, 2014
    Posts:
    2
    Basically, we load additional scenes additively that live temporarily in our level and they each have their own cameras that are configured differently than the main camera. We try to make everything in those scenes contextual to that scene so that we can unload them cleanly, test them easily, etc.
     
  22. Lexscite

    Lexscite

    Joined:
    Jan 22, 2017
    Posts:
    1
    Hi! Thanks for you work man! The question is: can i get the outline not to be drawn above everything in 3d scene. How can i set it to follow depth of the scene? Can you give me an approximate solution to achieve it through the script if there's no such an option?
     
  23. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    The only way would be to render the depth of the main camera to a texture and then use that texture when rendering the outlines (OutlineBufferShader)

    This would increase the performance cost of the effect and would require another image effect on the main camera (to render the depth) so it's not a very good solution.

    Don't forget that you can always erase outlines with objects, maybe that would be enough to fix your issue.
     
  24. dittomat

    dittomat

    Joined:
    Oct 7, 2015
    Posts:
    1
    Hey! Thanks for making such a nice asset for this!

    Outlines work really nicely, until I set the scale of my SpriteRenderers(or it's parents) transform. Simply setting transform.localScale=Vector2.one; just makes the outline stop drawing for that renderer. Is this a known problem, is there any fix/workaround?
     
  25. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Hey, you're welcome!

    Can you reproduce it on the demo scene?
     
  26. XxPleYxX

    XxPleYxX

    Joined:
    Jul 26, 2011
    Posts:
    41
  27. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
  28. XxPleYxX

    XxPleYxX

    Joined:
    Jul 26, 2011
    Posts:
    41
    I say outlines inside the box and invisible outside the box
     
  29. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Yes with a bit of work, you would have to render the "x-ray" boxes in a separate buffer and then use it when rendering the outlines (to check if you can draw an outline or not)
     
  30. ArysX

    ArysX

    Joined:
    Mar 4, 2015
    Posts:
    3
    Hi,
    At the beginning of congratulations for a great plugin!
    I have a little problem, so it looks like:

    Screenshot (11) - Copy.png

    Screenshot (11).png

    Anyone seen something like this?
     
  31. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Thanks, can you send me a project that replicates the issue?
     
  32. ArysX

    ArysX

    Joined:
    Mar 4, 2015
    Posts:
    3
    I find ugly workaround.... :)

    In OutlineBufferShader.shader, I change float alpha = c.a * 99999999; to float alpha = c.a * 9999999999;

    Right now outline object looks that:
    3.png 2.png 1.png

    I have error on shader, but outline works good.
     
  33. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Hummmm errors in shaders are not a good thing...

    What kind of material do you have on the sofa? Does it have transparency?
     
  34. amitkuliyal

    amitkuliyal

    Joined:
    Dec 3, 2014
    Posts:
    1
    Hello everyone, i'm using this script for highlighting the characters when players tap on them. The script works well if i'm using it in a single scene(not moving to other scenes) but it fails to outline the character when i'm moving from one scene to another, even though the script(on both camera and object) is attached like before. One thing i found out that when i'm using any 3d or 2d object then it works well but if i use spine2d files then it fails. Please help me.
     
  35. AleksanderN

    AleksanderN

    Joined:
    Jan 9, 2017
    Posts:
    6
    I've made a standalone windows build of your demo scene. After letting it run for 10 minutes it consumed 700mbs of memory.
    OutlineMemoryLeak.PNG

    As long as Outline component is enabled, the leak continues and process will continue to accumulate memory. But if you disable Outline component, then accumulation of memory will halt, but not reduce.

    I've taken a look into Unity Profiler, my Materials count went up from 180ish to 12.500 in under a minute of Outline usage. Once the Outline component enabled is set to false, the number stops climbing, but does not go down.

    Destroying outlineeffects component on camera does not seem to have any effect on amount of materials accumulated. I also tried running DestroyMaterials function, but it only causes:
    How do you deal with the huge memory leak?
    If this effect is unable to clean up after itself during run time, its useless.

    EDIT:
    If you change outline.Renderer.materials on line 185 and 189 in OutlineEffect.cs
    Code (CSharp):
    1.                        
    2. for(int m = 0; m < outlines[i].Renderer.materials.Length; m++)
    3. {
    4.    if(outlines[i].Renderer is MeshRenderer)
    5.    outlines[i].Renderer.materials[m].mainTexture = outlines[i].OriginalMaterials[m].mainTexture;
    6. }
    7.  
    to outlines.Renderer.sharedMaterials
    Code (CSharp):
    1.                        
    2. for(int m = 0; m < outlines[i].Renderer.sharedMaterials.Length; m++)
    3. {
    4.    if(outlines[i].Renderer is MeshRenderer)
    5.    outlines[i].Renderer.sharedMaterials[m].mainTexture = outlines[i].OriginalMaterials[m].mainTexture;
    6. }
    It fixes crazy material spamming, dunno if there will be any other side effects.

    EDIT2: fixed line breaks.
     
    Last edited: Mar 1, 2017
  36. OrangeCanine

    OrangeCanine

    Joined:
    Oct 29, 2016
    Posts:
    2
    Just curious. As of now there is no way to have more than three line colors correct?
     
  37. AleksanderN

    AleksanderN

    Joined:
    Jan 9, 2017
    Posts:
    6
    Yup, look at the code pattern and expand it accordingly.
     
  38. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    What are spline2d files? Also please provide a project that reproduces the issue.
     
  39. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Thank you for this, will look into it.
     
    Last edited: Mar 8, 2017
  40. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    So apparently using sharedMaterials is okay with different textures (for alpha cutout) for multiple meshes with the same outline color and I just don't understand how that is possible. This is the reason why I changed this a while back but now it just works!

    How is this possible?
    I change the sharedMaterial.mainTexture twice before camera.Render() and it renders both textures? I thought sharedMaterial meant the same material instance for all renderers (change a texture in one and all others will change too...)

    Well doesn't matter since it works I guess...

    EDIT:
    Yeah it doesn't work lol. That code change you did fixes the memory leak for you?

    Anyway, what I'm going to do is drop support for multiple outlined meshes that use alpha cutout materials to fix this.
     
    Last edited: Mar 8, 2017
  41. vincent0506

    vincent0506

    Joined:
    Sep 7, 2013
    Posts:
    1
    How can I use it in multicamera for VR application (not using neither occlus nor vive)
    Already add the outlineEffect.cs to both camera

    Unity 5.5.0f3 Personal (64bit) - interior.jpg
     
  42. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Are you using the latest version from GitHub?

    If not, please try that one.
     
  43. AleksanderN

    AleksanderN

    Joined:
    Jan 9, 2017
    Posts:
    6
    The code change fixed my problems indeed and technically its not mine, a co-worker at my place figured it out on a hunch. I just thought it would be prudent to inform you of it since it kept on causing problems for windows on medium end systems (and eventually crashing builds).

    I've come over several situations where objects with outline effect are stacked close or on top of one another. Take for instance a table you outline and a phone or a book lying on the table. In this case the book outline will be culled out, in other words its not visible unless you turn off table outline.
    Setting object on the table to a differetn outline color and checking Add Lines between colors helps to alleviate this problem, silver lining I suppose :)
     
  44. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    Any update on VR support? I also get displaced outlines. I worked on making a manager to easily control fading/unfading and pingpong, but I'm working on VR and I didn't know it didn't work in VR (I also don't have a headset myself, so I was using VRTK's simulator rig, so I didn't know it didn't work until my teammate actually tested the thing)... think one of these days we could do a skype video call with my teammate so you can do some testing?
     
  45. archcomix

    archcomix

    Joined:
    Aug 22, 2015
    Posts:
    3
    Great job, though I second the VR support - trying it in a Vive and added the outline effect script to the Steam VR camera and the outline to an object, and I don't get anything. Got my version from the asset store. Any help appreciated!
     
  46. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Sorry but I don't own a VR headset so I can't fix this issue, if someone with shader knowledge could help that would be great!
     
  47. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    See my post above, also always try the latest GitHub version to make sure.
     
  48. chrustol

    chrustol

    Joined:
    Sep 5, 2012
    Posts:
    2
    Just stopping by to say that you've did a great job with this effect!
    thanks man.
     
  49. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Thanks, you're welcome!
     
  50. reinfeldx

    reinfeldx

    Joined:
    Nov 23, 2013
    Posts:
    164
    Really nice tool—I've got a question/issue: I can't seem to match the color of an outline to the color of an unlit object. Here's a basic example of what I mean:



    Both the cube and the outline of the wall share the same color values, so I have been playing with the intensity meter. I can get pretty close, but I've got a need to match them exactly (it's for an effect not illustrated here).

    I'm puzzled! Any ideas?

    EDIT: As I'm thinking through this, it seems I would need to be able to match colors while being able to share the same intensity value. I can't match that light green cube with the outline while simultaneously matching the dark green walls with a dark green outline because I need to tweak the intensity values of each outline color to match the objects; there's only a single shared intensity slider.

    (I'm using the version I just pulled from github, if that matters.)
     
    Last edited: Mar 19, 2017