Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

► Wireframe shader - The Amazing Wireframe shader ◄

Discussion in 'Assets and Asset Store' started by Arkhivrag, Jun 11, 2014.

  1. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    It's looks like fine no?

     
  2. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    YES, I am also very interested in the update, BUT according to the post below it seems that we will be waiting many months to get a possible update with new features or version 2.0, as it has just been started the work on Fragmentum 3 update and this will take some time, and then after finishing it, must start and begin to make the update for this Wireframe shader, and will also take some time, so maybe there could be some months before we can see an update for this.

    As I of course do not know how much would it take to make it, I want to ask the author, will it be Wireframe Shader 2 (or any update) for 2016 or could be perhaps at the end of 2015?

    I know that you may not know because it depends on many things and how the evolution of the updates goes, but roughly a possible date based on your experience.

    Thanks very much and I wish you the best for the Fragmentum 3 that looks very good and for Wireframe Shade 2

     
  3. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    May be by the end of October.



    VacuumShaders - Facebook Twitter YouTube
     
  4. rtrimble

    rtrimble

    Joined:
    Nov 21, 2014
    Posts:
    3
    Hello, I was playing around with the shaders and noticed that the wireframe renders only on the inside of the mesh. Is it possible to have the wireframe extend past the mesh itself?
     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    What you mean by 'renders only on the inside of the mesh' - on the back face of the mesh?
    Wireframe is rendered on the surface of the mesh, if it is flipped or inverted then the same will be with wireframe, of course.



    VacuumShaders - Facebook Twitter YouTube
     
  6. rtrimble

    rtrimble

    Joined:
    Nov 21, 2014
    Posts:
    3
    Sorry, it is a little hard to explain what I mean. I wanted to test out a technique to see if it would work in Unity. The idea is to render a silhouette outline of an object by first rendering the object and then using a stencil buffer to render a thick version of the wireframe where the object isn't. (similar to what is described here: http://www.flipcode.com/archives/Object_Outlining.shtml but not with OpenGL).

    In order for this to work, the wireframe that is rendered needs to be a little bit larger than the actual mesh (in other words, the wireframe has to extend past the mesh itself)

    example.png

    In the image above, let's say that A is the front of a cube mesh. The shader appears to render the wireframe within the mesh only like in example B. I want to know if it is possible to have the wireframe render like example C (so that the wireframe is actually rendering outside the edges of the mesh). If not, it's fine and I'll figure something out :) I don't want to take up too much of your time. Thanks! Great shader by the way.
     
  7. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Currently such thing is not included. But may be possible by combining it with outline shader.



    VacuumShaders - Facebook Twitter YouTube
     
  8. rtrimble

    rtrimble

    Joined:
    Nov 21, 2014
    Posts:
    3
    Okay. thank you :)
     
  9. Klamore74

    Klamore74

    Joined:
    Jun 17, 2013
    Posts:
    103
    HI Arkhivrag, is the plug-in Unity 5 compatible?

    Thanks you
     
  10. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Wireframe shader is done in Unity 4 and works without problem in Unity 5.
    However update to Unity 5 is in development.





    VacuumShaders - Facebook Twitter YouTube
     
  11. Rotary-Heart

    Rotary-Heart

    Joined:
    Dec 18, 2012
    Posts:
    813
    Hello,

    I have one question, the effect that appears at the video 0:33 of the promo video can it be done in a diagonal direction instead of X, Y and Z only?

    Also can it be use to only show a small piece of the lines? Like if it was being scanned:

    I hope that it's clear with this ugly Photoshop try to show what I meant.

    Capture.PNG
     
  12. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Arbitrary direction axis gradient and 'scanned' effects are not available, but I'll add them to a 'wish list' for upcoming update.



    VacuumShaders - Facebook Twitter YouTube
     
    Rotary-Heart likes this.
  13. darrencperry

    darrencperry

    Joined:
    Jan 22, 2014
    Posts:
    20
    One more vote for Quads or ability to select/deselect edges for render...

    I don't yet understand how your generator tool works, is it a process I could achieve in something like Blender?
     
  14. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Generator calculates vertex barycentric coordinates (for Wireframe shader). I do not know if Blender can do it.



    VacuumShaders - Facebook Twitter YouTube
     
  15. ernbot

    ernbot

    Joined:
    Nov 2, 2009
    Posts:
    81
    Hi, I've bought your wire frame shader as I want to produce some wireframe renderings of some game levels for my portfolio. I need the ability to apply the shader to an entire scene (100s of objects). Reading the documentation it seems as though it is applied to 1 object at a time, is there a workflow you recomend to suit my needs?
     
  16. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Wireframe shader is common per mesh shader. If you need to render all scene objects as wireframed, of course all of them must have Wireframe shader, + (as written in description) shader requires mesh with vertex barycentric coordinates saved inside 'color' or 'tangent' buffers.



    VacuumShaders - Facebook Twitter YouTube
     
  17. alemke

    alemke

    Joined:
    Feb 26, 2013
    Posts:
    12
    Is there a simple way to fade out transparency through script?
     
  18. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    If mean control/animate material parameters through script, yes of course.



    VacuumShaders - Facebook Twitter YouTube
     
  19. alemke

    alemke

    Joined:
    Feb 26, 2013
    Posts:
    12
    OK what do i use to control transparency?
     
  20. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Transparent can be controlled for:
    Base mesh (Default Options group)
    1. Main color - parameter inside shader - _Color (alpha value)
    2. Main texture - parameter inside shader - _MainTex (alpha value)
    Wire Tranparensy (Wire Options group)
    1. Wire color - parameter inside shader - _V_WIRE_Color (alpha value)
    2. Wire transparency by texture - _V_WIRE_Transparent_Tex (texture uses MainTex's uvs)
    3. Gradient transparency - _V_WIRE_GradientColor (alpha value)
    All above shader parameters can be animated or controlled from script.
    How to get/set material properties from script: http://docs.unity3d.com/ScriptReference/Material.html



    VacuumShaders - Facebook Twitter YouTube
     
  21. sonofbryce

    sonofbryce

    Joined:
    May 19, 2009
    Posts:
    111
    Arkhivrag, I know fixes for Unity 5 are coming but I just got your shaders for a project and they work beautifully except that the editor component has problems. Properties start disappearing for some reason. I'm using Unity 5.2.1p3 .

    Here's a shader from the demo scene. Looks fine in the editor, all properties appear and function.

    Image 018.png



    Next, I switch to Unlit/Transparent/No Tex shader. Properties still appear while the object is still selected.

    Image 019.png

    After deselecting the model and reselecting, the editor material properties don't display.
    Image 020.png

    I'm able to switch to some shaders (the preview shader) and modify the wireframe color still and the results are still saved when switching back. But they properties still won't display.

    When I first started using it in the project it worked as expected but Unity crashed at some point. I'm not sure if it's related, but after loading up Unity again the shaders stop displaying. I tried re-importing the asset as well.

    Any ideas for a way to get around this?

    Thanks.
     
  22. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Material properties disappearing from custom material editor is Unity bug.

    Custom material editor does not get call if shader has extra pass for rendering depth buffer.
    If you open "VacuumShaders/The Amazing Wireframe/Unlit/Transparent/NoTex.shader" it has additional pass
    Code (CSharp):
    1.  
    2. Pass
    3. {
    4.     ZWrite On
    5.     ColorMask 0
    6. }
    Delete that pass and custom material editor will work.

    Unfortunately as it is Unity bug, material properties disappearing will happen on all shaders where is used above pass. Even in other shaders (not wireframe) with other custom material editor.

    I'll submit bug report to Unity.


    VacuumShaders - Facebook Twitter YouTube
     
    sonofbryce likes this.
  23. sonofbryce

    sonofbryce

    Joined:
    May 19, 2009
    Posts:
    111
    Thanks for the help!
     
  24. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Custom material begin working properly after deleting Library folder and restarting Unity.



    VacuumShaders - Facebook Twitter YouTube
     
  25. sonofbryce

    sonofbryce

    Joined:
    May 19, 2009
    Posts:
    111
    Is there any way to draw Canvas elements (Sprites or Text) on top of the wireframe shader? I'm trying with the "No Tex 2 Sided" shader and I'm having no luck. The wireframe is always drawn in front.
     
  26. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Shaders with 'textures' have Wire Transparency paramter, with that you control wire transparency using texture. So you can make part of wire invisible.



    VacuumShaders - Facebook Twitter YouTube
     
  27. sonofbryce

    sonofbryce

    Joined:
    May 19, 2009
    Posts:
    111
    Hey Arkhivrag, I'm not sure if I explained correctly. I've attached an image to help demonstrate.

    I have a Sprite image that's close to the camera, clearly in front of the sphere wireframe surrounding the whole scene. But from the camera perspective, the wireframe is still drawn on top. Is there a way to make it have the correct Z-depth when dealing with Canvas-based objects (Sprites, images, text)?

    Image 022.png

    Here's another image with some 3d cubes in the scene and showing how they're properly occluded.
    Image 023.png

    It's okay if this functionality isn't built in, but if you have some guidance about how to make tweaks to the shader to draw behind Sprites, I'd appreciate that.

    Thanks!
     
    Last edited: Oct 23, 2015
  28. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Reason may be different render queue of that shaders.
    Open wire shader and check "Queue"="Transparent" tag. Try increase or decrease it to adjust it for your needs.
    To increase:
    "Queue"="Transparent+1" or "Queue"="Transparent+2" or "Queue"="Transparent+10"
    To decrease
    "Queue"="Transparent-1" or "Queue"="Transparent-2" or "Queue"="Transparent-10"

    More info about render order: http://docs.unity3d.com/462/Documentation/Manual/SL-SubshaderTags.html



    VacuumShaders - Facebook Twitter YouTube
     
  29. sonofbryce

    sonofbryce

    Joined:
    May 19, 2009
    Posts:
    111
    You are the best! Thanks a lot! That worked perfectly.
     
  30. thesims1004

    thesims1004

    Joined:
    Oct 29, 2015
    Posts:
    1
    I have a problem.

    I draw bound box of the mesh like this.


    BoundBox code is.
    Code (CSharp):
    1.     void DrawBondBox()
    2.     {
    3.         Renderer renderer = transform.GetComponent<Renderer> ();
    4.         if (renderer != null)
    5.             bonds = renderer.bounds;
    6.         else
    7.             bonds = GetChildRendererBounds (gameObject);
    8.  
    9.         // Drawing Box
    10.         GL.Begin(GL.LINES);
    11.         //....
    12.     }
    13.  
    14.    Bounds GetChildRendererBounds(GameObject go)
    15.     {
    16.         Renderer[] renderers = go.GetComponentsInChildren<Renderer>();
    17.         if (renderers.Length > 0)
    18.         {
    19.             Bounds bounds = renderers[0].bounds;
    20.             for (int i = 1, ni = renderers.Length; i < ni; i++)
    21.                 bounds.Encapsulate(renderers[i].bounds);
    22.             return bounds;
    23.         }
    24.         else
    25.             return new Bounds();
    26.     }
    However, after assigning TheAmazingWireframeGenerator script to the object, the size of the bounds becomes large.


    Can you help me?
     

    Attached Files:

  31. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Wireframe generator stores additional two vertex inside mesh that contain some 'coded' data.
    Each vertex size is in the range of [-1; 1]
    Increase original mesh scale size inside import settings or add scale parameter inside your script to control bounds size.

    'Coded' data is just a marker for editor to know where is stored wireframe, inside color buffer or tangent.



    VacuumShaders - Facebook Twitter YouTube
     
  32. donuan

    donuan

    Joined:
    Apr 29, 2015
    Posts:
    3
    Hi, Maybe Im stupid but how do I open the editor window in unity 5?
     
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Is question related to Wireframe shader? Cause it has no any editors.




    VacuumShaders - Facebook Twitter YouTube
     
  34. donuan

    donuan

    Joined:
    Apr 29, 2015
    Posts:
    3
    My bad,
    I deleted it and reimported it and now it works.
    Thanks for the nice shader!
     
  35. Carrotpie

    Carrotpie

    Joined:
    Sep 25, 2014
    Posts:
    30
    Hey,
    I am new with your shader asset, trying to make a two sided wireframed plane here. Currently I'm stuck with this:
    One side (its fine):
    Capture.PNG
    But the other side looks like this (not rendered, not good):
    Capture.PNG
    How can i fix this?
     
  36. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Need more info:
    1. Shader name
    2. Unity version
    3. Target device



    VacuumShaders - Facebook Twitter YouTube
     
  37. Carrotpie

    Carrotpie

    Joined:
    Sep 25, 2014
    Posts:
    30
    1. Shader doesnt matter, I tried all 2 sided variants, all looks like this (violet form bottom side, though they should be double sided imho). THis one in particular is Unlit/Transparent/No Tex 2 Sided
    2. Unity 5.2.3f1 (current version). It was the same at 5.1.2 though.
    3. Target Device = android, but the pics I posted are seen in editor and also windows build.
     
  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Can not reconstruct at my side, tested in Unity 5.2.3f1 and everything works.

    Does it happen if you turn on Antialiasing (SM3) checkbox inside material editor?
    Also try, select shader and inside inspector window click Compile and show code button (with All platforms enabled), Unity will recompile shader and if there are some problems with shader will print about it in Console window.
    shader_compile.png



    VacuumShaders - Facebook Twitter YouTube
     
  39. Carrotpie

    Carrotpie

    Joined:
    Sep 25, 2014
    Posts:
    30
    Hey, sorry for such slow reply. Gotta lots of work to do.
    So I tried what you suggested, nothing helped, no errors were thrown:
    // Compiled shader for all platforms, uncompressed size: 853.4KB
    Antialiasing changed nothing either. All platforms selected.
     
  40. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    If shaders are compiled and Unity does not throw any errors it means that problem is not with shader, and I can not help.
    It may be Unity bug or graphics cards driver issue.



    VacuumShaders - Facebook Twitter YouTube
     
  41. Carrotpie

    Carrotpie

    Joined:
    Sep 25, 2014
    Posts:
    30
    I'm really sorry @Arkhivrag, I messed up. The fault was actually in my inattentiveness to the objects children - it was their textures that got messed up, not the one's I thought. It was so dumb of me, I am really sorry for wasting your time. Your asset, however, is awesome! Saved a lot of time for me and looks very cool. My application's whole graphics is based on it :)
     
  42. Carrotpie

    Carrotpie

    Joined:
    Sep 25, 2014
    Posts:
    30
    Ok, I am seeing a new version of this asset came out (sometimes a pop-up in unity shows up with info about it), but when I click the button, which says - download asset, nothing happens. Is this Unity bug?
     
  43. lakex24

    lakex24

    Joined:
    Dec 20, 2015
    Posts:
    2
    @Arkhivrag I downloaded your free sample scripts to test on my machine and it didn't work. If you can see the attached picture, the only thing I got is a solid pink silhouette. Could you please help? I'm testing both on desktop and mobile (Samsung Note 5). by the way, do you know whether it will work on Gear VR ? Thanks!

    Environment: Windows 8, Unity 5.3.1
    Target: Ideally Gear VR with SamSung Note 5, but I first tested on desktop and didn't work.

    Is there any special settings? I just create a new project and import your sample scene.

    P.S: The other dropbox link you provided for testing is expired.
     

    Attached Files:

    • Pink.PNG
      Pink.PNG
      File size:
      143.6 KB
      Views:
      857
    Last edited: Dec 30, 2015
  44. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    Fixed, download link is updated. Before importing new package delete old one from project.



    VacuumShaders - Facebook Twitter YouTube
     
  45. lakex24

    lakex24

    Joined:
    Dec 20, 2015
    Posts:
    2
    Thank you Arkhivrag. The fix works perfectly.
     
  46. sameer-mirza

    sameer-mirza

    Joined:
    Nov 14, 2011
    Posts:
    36
    How can I use this asset to work as an overlay to any other shader. For example a custom standard shader?
     
  47. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    You can render wireframed mesh with transparent or cutout shaders above normal mesh using any shader.
    Asset includes transparent and cutout shaders too.



    VacuumShaders - Facebook Twitter YouTube
     
  48. sameer-mirza

    sameer-mirza

    Joined:
    Nov 14, 2011
    Posts:
    36
    Thanks for the reply. So if I have a mesh with a copy of the Unity standard PBR shader, would I need to add the transparent (wireframe) shader code as a new pass at the end of the standard PBR shader?
     
  49. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,972
    If you know shader programming good enough than you can do so, but my suggestion was to use another mesh (wireframed) above normal mesh (that use custom shader).



    VacuumShaders - Facebook Twitter YouTube
     
  50. sameer-mirza

    sameer-mirza

    Joined:
    Nov 14, 2011
    Posts:
    36
    Thanks, I got it to work by adding the Wireframe shader material in the materials list (basically draws the mesh twice now, once with standard PBR and second with overlay transparent wireframe).

    However, I'm getting issues working with high poly meshes, is there a vertex/tri limit to this?