Search Unity

► Wireframe shader - The Amazing Wireframe shader ◄

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

  1. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Only triangle and quad rendering.



    VacuumShaders - Facebook Twitter YouTube
     
  2. haijun

    haijun

    Joined:
    Feb 4, 2015
    Posts:
    8
    Hi, I was trying to render a quad wireframe, which is pretty cool. I was trying to create a quad-based mesh at run-time, and apply the geometry shader directly. However, the wireframe I got is still in triangles, which seems to be a unity thing, as I turn on the wireframe view of unity, I can see my mesh are triangulated. It is still triangulated even after I called GenerateQuads function from you library with geometry shader. It only work when when I call the GenerateQuads function and apply the physically based shader. But then I run into this threshold of the number of triangles when calling the GenerateQuads function and it is super slow with a low of meshes. Is there a way to achieve the speed the geometry shader but still preserve the quad-based mesh?
     
  3. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Quad wireframe generator is a little bit slower than triangle. It completely relies on mesh vertex/triangle structure.
    Geometry and Tessellation shaders can not render quad wireframe, they calculate it from income mesh triangles.



    VacuumShaders - Facebook Twitter YouTube
     
  4. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Working on update for Geometry shaders. They will be able to render dynamic quad wireframe.



    VacuumShaders - Facebook Twitter YouTube
     
  5. haijun

    haijun

    Joined:
    Feb 4, 2015
    Posts:
    8
    This is fantastic news and will save my life! Looking forward to the updates!
     
  6. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Update will be available next week.
    Quad wireframe calculation in geometry shader is very fast, but is not as accurate as editor script.
    Works well on meshes with good vertex/triangle structure.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Mar 5, 2017
  7. UDN_b5b73dbf-38b8-40c3-ba68-509b3dd33415

    UDN_b5b73dbf-38b8-40c3-ba68-509b3dd33415

    Joined:
    Jul 1, 2016
    Posts:
    2
    Hi, I just purchased your shader - brilliant work! Many thanks for providing this.

    I am trying use script to change _V_WIRE_DynamicMaskEffectsBaseTexEnumID, but it seems to break the shader. When I set this value in my code, the whole shader stops working.

    I am using the shader "Physically Based/Cutout/Simple/Bumped (Fixed)".

    I set "Effect Base Texture' to On, and everything works really nicely. But when I add this line of code, everything stops working.

    targetObject.material.SetInt("_V_WIRE_DynamicMaskEffectsBaseTexEnumID", 0);

    Can you please help me figure out why this happens? Many thanks.
     
  8. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    _V_WIRE_DynamicMaskEffectsBaseTexEnumID - is an editor draw parameter not used by shader.

    If you need Base Texture to be effected by dynamic mask enable shader keyword - V_WIRE_DYNAMIC_MASK_BASE_TEX_ON

    Note, that it is a shader_feature and if you need it dynamically changing using script in the final build, inside shaders change all:
    #pragma shader_feature V_WIRE_DYNAMIC_MASK_BASE_TEX_OFF V_WIRE_DYNAMIC_MASK_BASE_TEX_ON
    to
    #pragm multi_compile V_WIRE_DYNAMIC_MASK_BASE_TEX_OFF V_WIRE_DYNAMIC_MASK_BASE_TEX_ON



    VacuumShaders - Facebook Twitter YouTube
     
  9. UDN_b5b73dbf-38b8-40c3-ba68-509b3dd33415

    UDN_b5b73dbf-38b8-40c3-ba68-509b3dd33415

    Joined:
    Jul 1, 2016
    Posts:
    2
    Arkhivrag - thank you. That has worked. And thanks for the quick response - excellent service!
     
  10. Phenomonaut

    Phenomonaut

    Joined:
    Sep 30, 2012
    Posts:
    61
    Love this asset so far, but you really need to update the ReadMe.pdf. It says:

    "Quick Start
    Create material and set wireframe shader VacuumShaders/The Amazing Wireframe/Mobile/Unlit. Apply material to a mesh. Mesh will be rendered completely black (color of wireframe by default), it means that mesh has no barycentric coordinates for wireframe rendering. For generating mesh with barycentric coordinates select mesh inside scene (Hierarchy window) and inside material editor click on ‘Gear’ icon, choose Generate Wireframe Mesh option."

    The Gear Icon doesn't behave this way anymore. Took me awhile to find the actual place for mesh generation, Windows/Vacuum Shaders/ Wireframe Generator.
     
  11. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Just tested in Unity 5.4 and 5.5.
    Everything works correctly.
    wire.png



    VacuumShaders - Facebook Twitter YouTube
     
  12. Phenomonaut

    Phenomonaut

    Joined:
    Sep 30, 2012
    Posts:
    61
    Thanks, I stand corrected. I was clicking on the wrong gear icon in that component.
     
    Last edited: Mar 12, 2017
  13. Phenomonaut

    Phenomonaut

    Joined:
    Sep 30, 2012
    Posts:
    61
    @Arkhivrag, I'm still trying to narrow down this issue, but are there any known problems with applying this shader to skinned, rigged meshes? I have a humanoid mesh with a skeleton, and the wireframe generator runs, but no wireframe is created. Works fine on the same mesh without a skeleton though.

    Having a ton of fun with this asset so far. It's fantastic.

    Edit: added video:

     
    Last edited: Mar 12, 2017
  14. Phenomonaut

    Phenomonaut

    Joined:
    Sep 30, 2012
    Posts:
    61
    I spent a little more time with this. Once I add a bone to the mesh in Max and export it, it stops generating a wireframe once I open it in Unity. any ideas?
     
  15. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Can you send me the mesh, I'll check it.



    VacuumShaders - Facebook Twitter YouTube
     
  16. bonesliu

    bonesliu

    Joined:
    Oct 26, 2016
    Posts:
    1
    Hi,

    The nature of the Quad wireframe is fantastic, and I very much want to use this feature, but the unity version of our product is 5.3, can you provide a support for 5.3 version of the Quad wireframe?
     
  17. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    No, sorry.



    VacuumShaders - Facebook Twitter YouTube
     
  18. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Pretty interesting. @Arkhivrag

    3 Questions

    1. Does it work with animated skinned mesh?
    2. Does it come with shader source code?
    3. I would like to control the color of the line by vertex color and it's transparency using the vertex alpha. Is this possible? For instance, I only would like to have one corner of cube to have line starting and then fade away towards the other vertices.

    Thanks!
     
  19. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    1. Yes
    2. Yes
    3. Only RGB values of vertex color can be used. Line transparency can be controlled by:
    1. WireColor alpha value
    2. Additional wire transparent texture alpha value
    3. Distance fade feature
    4. Fresnel feature
    5. Dynamic mask


    VacuumShaders - Facebook Twitter YouTube
     
  20. tachyon-particle

    tachyon-particle

    Joined:
    Jan 5, 2016
    Posts:
    79
    Hi,

    Wireframe v2017.4
    Unity Pro v5.5.2p4

    Getting errors when using Wireframe Generator and choosing "Use Selected Objects" for Skinned Meshes. I have tried Skinned Meshes with various vertices count (~10,000 vertices to ~3,000 vertices) and still get these errors. Please see the attached image for the error.

    Some skinned meshes seemed to work for a previous version of Wireframe v2017.2, but in this new v2017.4 these errors show on the Console.

    Can you confirm if these errors are showing for Skinned Meshes when pressing the "Use Selected Objects" button ?

    Thanks

    upload_2017-4-1_6-44-33.png
     
  21. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Confirm, working on fix.
    For now use gear icon inside material editor window.




    VacuumShaders - Facebook Twitter YouTube
     
    tachyon-particle likes this.
  22. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    Can I change the "Render Only Wire" parameter at runtime?
     
  23. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Checking "Render Only Wire" checkbox inside material editor switches current shader to another.
    For run-time changing just create two materials, one with enabled "Render Only Wire" and another without it, and use those materials.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Apr 3, 2017
  24. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    k thanks!
     
  25. Infrid

    Infrid

    Joined:
    Jan 14, 2012
    Posts:
    67
    I've purhcased and downloaded your asset and I'm in the process of installing it into my test project. I'm waiting about 30 minutes so far (and it looks like it's only 20% of the way through importing shaders). I have a fast, modern pc. WTH is going on? Don't want to leave you a 1 star review; but eating up what looks like will be 1-2 hours of my time just to import your asset is not going to result in anything else, I'm afraid.
     
  26. Infrid

    Infrid

    Joined:
    Jan 14, 2012
    Posts:
    67
    To add to that - it finally imported (took an hour); not saying it's your fault; but it's the only asset package that's ever happened on. I'm guessing it's coz the default settings are for all platforms, and compiling takes an age for linux/osx and windows? Not sure.

    In any case I have another question - the projector; I'd like it to be able to fade out the textures on the objects hit by the projector.. is that possible?
     
  27. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Untitled-1.png

    On my old i7 3630QM with 2.4GHz and 8GB ram it takes about 15 min.

    To speed up importing you can uncheck shader groups inside import window, e.g importing Legacy or Geometry shaders, etc.



    VacuumShaders - Facebook Twitter YouTube
     
  28. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    With current shaders - no. Added to a 'wishlist'.



    VacuumShaders - Facebook Twitter YouTube
     
  29. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Thanks for the reply.

    Having read your reply, can you tell me if A value of vertex color is used anywhere? If not can I modify the shader so that vertex alpha can control the transparency of the wireframe? If it is used somewhere else, can I at least know where any why so I can tell if I don't need that particular effect where vertex alpha is used for, I can modify it to use for the transparency?

    Also having said that, if the blend mode is set to additive, setting vertex color to 0 will effectively have the similar effect as having vertex alpha to zero?
     
  30. createthiscom

    createthiscom

    Joined:
    Dec 19, 2016
    Posts:
    67
    I'm currently using a script that draws the wireframe with GL. It draws the triangle normals, which is handy for me. Does this shader have an option to render normals?
     
  31. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    Really love this asset. I can't say that enough. Okay 2nd question for me...

    I'm using the Transparent -> simple shader on a 3D cube in my scene. The shader has a Default Visual Color/texture in addition to the wireframe color. I want the shader to initially display the wireframe only. Then at runtime, when the cube game object receives an event, I want the wireframe to fade out (completely) and the default color/texture to fade in. This all works except that when I initially setup the shader, I can't get the color/texture to be 100% transparent. I figured that turning the alpha value to 0 for the Default Visual Options -> color would result in no visible color or texture. There is a slight hue showing through and I need it to disappear completely until I trigger the alpha value change.

    I'm lerping the alpha for a smooth transition from the wireframe to the color/texture. Is there a better way to achieve this?

    Thanks.

    Edit: This is simple to test. Leave the Render Only Wire un-checked and set color to Red with alpha 0. Then in the Wire Options set Color to black and alpha to 1. You can see the red is showing through the wireframe. I'd like this to be transparent (not red) since I'm using the Transparent -> Simple shader.
     
  32. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Vertex color alpha value is not used. I'm not sure it will be easy for you to modify shader to support it.

    Yes.



    VacuumShaders - Facebook Twitter YouTube
     
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    o_O



    VacuumShaders - Facebook Twitter YouTube
     
  34. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Enable Improved Rendering (2 pass) option inside material editor.



    VacuumShaders - Facebook Twitter YouTube
     
  35. createthiscom

    createthiscom

    Joined:
    Dec 19, 2016
    Posts:
    67
    I'm asking if your shader renders triangle normals. Wireframe.cs renders them as lines that start at the center of the triangle and go out in the direction of the triangle normal. This is useful for me, so I'm curious if your wireframe shader has an option to render these as well, but judging from your response I'm guessing the answer is no.
     
  36. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
     
  37. createthiscom

    createthiscom

    Joined:
    Dec 19, 2016
    Posts:
    67
    Here is the effect I need (green lines sprouting from centers of triangles):



    Would this be easy for me to add myself? I'd really like to offload my wireframe code to the GPU via a shader and this looks like the best one.

    UPDATE: bought it. initial testing indicates I'll be using the Geometry Shader as my meshes are 100% dynamic in nature. Looks like I've got source code for that shader, so... cool. I'll probably make the choice of wireframe rendering a user choice for now so the user can turn triangle normals back on at a cost of performance.
     
    Last edited: Apr 7, 2017
  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Now it is clear for me what were you asking for.
    That effect can be achieved with shader, but only using custom geometry shader.

    It is completely out of boundaries of the Wireframe shader and will never be added to the pack.

    However, as it a simple effect I did one custom shader for you and it is up to you to implement it in Wireframe shaders (check attached file).
    Shader renders triangle normal as pyramid (consisting of 3 triangles) instead of original triangle.
    Untitled-2.png

    If you use it with Wireframe shader effect will be like this:
    Untitled-1.png


    Here are very simple steps:
    1. Inside any Wireframe shader at the end of the SubShader add:
    Code (CSharp):
    1. UsePass "GeometryNormal/MAIN"
    like this:

    Untitled-3.png

    2. For controlling GeometryNormal shader parameters inside Wireframe shader, add controllers inside shaders Properties group, like this:

    Untitled-4.png


    That's all.

    Note! Above example is not part of the Wireframe package support and can not help with it if has any questions.
    Check shader file and modify it for your needs.



    VacuumShaders - Facebook Twitter YouTube
     

    Attached Files:

  39. createthiscom

    createthiscom

    Joined:
    Dec 19, 2016
    Posts:
    67


    Oh man. This is totally awesome! Thank you so much. Best purchase ever!
     
  40. createthiscom

    createthiscom

    Joined:
    Dec 19, 2016
    Posts:
    67
    This is working great in the Unity Editor, but I just realized the wireframe shader isn't making it into my production build. Here's the error from the debug log:
    Code (CSharp):
    1. NullReferenceException
    2.   at (wrapper managed-to-native) UnityEngine.Material:Internal_CreateWithShader (UnityEngine.Material,UnityEngine.Shader)
    3.   at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00009] in C:\buildslave\unity\build\artifacts\generated\common\runtime\ShaderBindings.gen.cs:313
    4.   at MaterialCache.ColorAndStateToMaterial (Color color, Boolean renderMesh, Boolean renderWireframe, Boolean renderNormals) [0x00012] in C:\Users\jesse\Documents\Mesh Maker VR\Assets\scripts\MaterialCache.cs:63
    And here's the line in MaterialCache.cs:
    Code (CSharp):
    1.             materialInstance = new Material(Shader.Find("VacuumShaders/The Amazing Wireframe/Geometry Shader"));
    2.  
    I'm a little stumped as to why this is breaking, given that there is a Resources folder here:


    Is this a side effect of adding the GeometryNormal shader? Any ideas?

    UPDATE: I worked around this issue temporarily by creating two materials in the editor and applying them to disabled game objects in my scene.
     
    Last edited: Apr 14, 2017
  41. NEOMORPH_STUDIO_SRL

    NEOMORPH_STUDIO_SRL

    Joined:
    Jan 5, 2016
    Posts:
    12
    Hi @Arkhivrag !
    Would it be possible to extend the WireFrame shader and support generating flat normal (faceted) faces of the underlying geometry? Or even adjust the normal threshold angle so the geometry shader create hard edges using it? Of course, with an option to also show the wireframe on top (or not). Would that be feasible? Thank you! Please see the attached image for what I have in mind.

    EDIT: Sorry, I've just discovered your other asset, the Low Poly Shader https://www.assetstore.unity3d.com/en/#!/content/69971 that seems to do pretty much what I was looking for. Still, is it possible to set the Smoothing Normal Threshold and control feature smoothing like this?
     
    Last edited: Apr 17, 2017
  42. simplemisunderstanding

    simplemisunderstanding

    Joined:
    Apr 19, 2017
    Posts:
    3
    I'm not sure if I'm missing something out but I'm attempting to create a wireframe shader cutout 2-sided with Global Illumination in Unity v5.6.

    I've based my shader from the example (9) by creating a new material for the game object I want the wireframe mesh on and I've turned Global Illumination on. For some reason this doesn't create the lit up effect like you see in the example. I've baked the lighting too. The wireframe mesh works otherwise as fully intended.
     
  43. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Mostly no.
    You can render one mesh with flat normals, and above it same mesh with wireframe shader (transparent or cutout).



    VacuumShaders - Facebook Twitter YouTube
     
  44. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Object must be static.



    VacuumShaders - Facebook Twitter YouTube
     
  45. Deleted User

    Deleted User

    Guest

    Given your last reply to another question, it makes me wonder if I can use this product. I create Mesh terrain elevations on the fly. Can this product be used with geometry created at runtime?
     
  46. pechaut

    pechaut

    Joined:
    Apr 24, 2017
    Posts:
    14
    Hi,
    `
    Just downloaded the package, imported it, read the doc and wanted to bake a wireframe texture for my first test.

    So the doc says: "Tool available from Menu/VacuumShaders/Wireframe Texture Exporter."
    But what menu ? It's not in the tools menu, not in the material menu, nothing in the GameObject..

    where should I look for ?

    Thanks in advance for your help
     
  47. pechaut

    pechaut

    Joined:
    Apr 24, 2017
    Posts:
    14
    Found it ! For some reason I had to quit and launch .. and it was there in the Window Menu.
    (Maybe you can specify which menu in the doc ;-) )

    Cheers !
     
    Arkhivrag likes this.
  48. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,978
    Yes.

    Package includes two type of shaders:
    1. Shaders that require mesh with wireframe data baked inside mesh. (Works on any device).
    Baking API is very fast and is guaranteed on meshes with less than 21.000 vertices.
    For meshes with more than 21.000 vertices, baking is not 100% guaranteed, as mesh goes through some optimization process and it may fail.
    Quad wireframe calculation is slower then Triangle.

    2. GeometryShaders - no data baking is required. Wirefame is calculated directly inside shader and is ultra fast for both triangle or quad effects.
    Requires device with GeometryShaders support.



    VacuumShaders - Facebook Twitter YouTube
     
  49. wunjox

    wunjox

    Joined:
    May 4, 2017
    Posts:
    2
    Hello!
    I am currently using your shader on my student projet.
    I have a problem, I use the Transparent/Wired Only Two Sided version and on different mobiles I have different renders.

    The following images illustrate the problem :
    Screenshot_20170504-144958.png Screenshot_2017-05-04-14-49-23.png

    As you can see, on the first screenshot the render is totally messed up.

    Do you have any idea how could I fix this?

    Thanks a lot and have a nice day!
     
  50. simplemisunderstanding

    simplemisunderstanding

    Joined:
    Apr 19, 2017
    Posts:
    3
    I've set the object to static and it's still not generating a lightmap.

    When I copy over the body material from example 9 to a capsule object I've made then the lighting works. I've created a new material and set all the values identical to what the body had. What could I be missing?

    2017-05-09.png