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,982
    It is very strange, non of the HDRP shaders have 'cullFace' property. I was not able to reconstruct this problem at my side.

    All package included shaders are built using ShaderGraph. After moving shaders into new location Unity may not recompile them (must, but sometimes it does not. May be it is a bug). This breaks shader connections to the custom nodes used there. Try manually recompile shaders.
    First recompile Wireframe nodes (Amazing Assets\Wireframe Shader\Shaders\Unity Shader Graph folder). Open each one and click on Save button. This will force Unity to adjust new paths in generated shader.
    upload_2020-11-25_14-7-37.png

    After that recompile shaders Amazing Assets\Wireframe Shader\Shaders\Custom folder).



    Amazing Assets - YouTube Facebook Twitter
     
  2. OBJVISION

    OBJVISION

    Joined:
    Oct 5, 2020
    Posts:
    7
    HI,
    I have purchased the new version of your plugin, il like it.. i've tried to open empty scene and test runtime generation and seems working with my model also on webgl... good.
    But when i import the asset in my project(not empty project) it does not work becouse multiple errors relative to shaders, for example:

    upload_2020-11-25_14-55-57.png


    Can you help me please?

    ######### RESOLVED ########
    My error, i've moved all generated folder into a plugin folder...deleted and imported again and now it's working.
     

    Attached Files:

    Last edited: Nov 25, 2020
  3. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    thanks, The custom shader function uses an absolute path, and strange errors will occur once the directory is moved.

    Mainly used the feel path for cginc/WireframeShader
     
    Last edited: Nov 25, 2020
  4. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Looks like a bug in Unity shader compiler that does not update ShaderGraph files when they are moved.

    Custom functions just use one source file containing wireframe calculating methods. This file has no dependency on any other external resource.
    upload_2020-11-25_20-18-34.png

    Try: Remove from project folders:
    Amazing Assets\Wireframe Shader\Shaders\Custom and
    Amazing Assets\Wireframe Shader\Shaders\Unity Shader Graph
    Then re-import package. Unity should compile shaders correctly now.

    Also check shader file itself. Are there any errors in inspector?
    upload_2020-11-25_21-2-37.png



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Nov 25, 2020
    LostPanda likes this.
  5. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173

    thanks,all is ok.
     
  6. orangetech

    orangetech

    Joined:
    Sep 30, 2017
    Posts:
    50
    I don't know why cube display incorrect, both have same matrial.

     
  7. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Did you generate wireframe data for Cube mesh? Without that data baked inside mesh shader will not render wireframe.



    Amazing Assets - YouTube Facebook Twitter
     
  8. orangetech

    orangetech

    Joined:
    Sep 30, 2017
    Posts:
    50
    My mesh is generate procedurally. is there a way to draw wireline?
     
  9. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    You have to bake wireframe data inside mesh, without it shader will not render wireframe.

    Wireframe data can be baked inside mesh in editor or run-time (procedural). You can find more details about using run-time API in included documentation and example scenes.



    Amazing Assets - YouTube Facebook Twitter
     
  10. Squeyed

    Squeyed

    Joined:
    Aug 26, 2016
    Posts:
    38
    Hey @Arkhivrag I've just picked up your shader package, I'm hoping to use it purely with Amplify Shader, just wondering if I have to import the whole built-in package or if I can forego everything other than the Amplify folder?
     
  11. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    If do not need example and default shaders.
    upload_2020-12-15_20-13-7.png



    Amazing Assets - YouTube Facebook Twitter
     
  12. Squeyed

    Squeyed

    Joined:
    Aug 26, 2016
    Posts:
    38
  13. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Any word on this supporting HDRP version 10.2.2
     
  14. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Just tested with Unity 2020.2 HDRP v10.2.2 and shaders work as expected.
    Did you find any bugs or problems?



    Amazing Assets - YouTube Facebook Twitter
     
  15. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Nope, works great, wanted to check here before trying it out though.

    Awesome asset that isn't bad on performance !!!
     
  16. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Can this be used to lerp between the normal shader and the wireframe? I would like to try a "teleport in" effect where the monster has its wireframe alpha in (with transparency), then after a moment the body fades in and the wireframe fades out.

    Doable in HDRP?
     
  17. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    upload_2021-2-3_19-5-46.png

    Using ShaderGraph or ASE - Yes!
    Wireframe node returns value in the range of [0 - 1] and you can use it for any effect.



    Amazing Assets - YouTube Facebook Twitter
     
  18. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Looking at buying this asset for my project (Quest 2, standard render pipeline). My big unknown: is there any way to color certain edges a different color (e.g. to show that part of the model is selected)? Maybe by using vertex colors or similar?
     
  19. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    For wireframe color there are several options: Color, Texture, Vertex Color.
    Additional color transparency can be controlled using: Distance Fade and Fresnel effects.
    upload_2021-3-1_21-51-18.png


    Additional option for dynamic mask using parametric: Plane, Sphere and Box equations.
    upload_2021-3-1_21-50-29.png


    And if some special effect is required, asset supports Unity ShaderGraph and Amplify Shader Editor using just one node.




    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Mar 2, 2021
    JoeStrout likes this.
  20. VictorinoOgura

    VictorinoOgura

    Joined:
    Nov 22, 2020
    Posts:
    3
    Hi,
    I've just bought it and no matter what I do it keeps saying an error about the UnityEngine.Rendering.HighDefinition (Erro CS0234). Can you help me @Arkhivrag ?
     
  21. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Unity version?
    HDRP version?
    Build target?



    Amazing Assets - YouTube Facebook Twitter
     
  22. sktkgw

    sktkgw

    Joined:
    Apr 18, 2021
    Posts:
    1
    Hello!
    Is it possible to use Wireframe Shader with unity2019.3.6f1?
    I'd like to use it down from the latest installed Version: 2021.1.
     
  23. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    It is developed using Unity 2019.4.0 API. Can not guarantee it will work with previous versions.



    Amazing Assets - YouTube Facebook Twitter
     
  24. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    Hi, currently I am struggling to use the mask feature when I create a new material. If I try to create a new object and a Dynamic or Standard wire material in one fo the demo scenes and select the mask option of plane or sphere etc nothing seems to work correctly. If I duplicate a working material from the demo it works fine, if I copy and paste the working material properties to new material is doesn't work either.

    Am I missing something with the way masks are assigned to the mask object? Thanks

    Ahh im on 2019.3.6 so maybe its that....
     
    Last edited: Apr 21, 2021
  25. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Do you use WireframeMaskController script for updating mask properties inside materials (Manual file page 13) ?



    Amazing Assets - YouTube Facebook Twitter
     
  26. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    I have tested 2019.4.17 and I am still getting the above issue. I can assign examples materials fine but I cannot duplicate materials. I am using the sphere demo scene. The mask controller is in there. The shader seems to work fine but whenever I switch the Dynamic Mask setting I see no wireframe when at the sphere boundary.

    Is there anywhere I can check to see references to mask? It's as though something isnt picking up the mask setting changes.
     
  27. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Dynamic Mask Type inside material and controller script must be the same.
    Target material must be in the Materials array property of the controller script too.
    Make sure there is only one controller script updating target material.



    Amazing Assets - YouTube Facebook Twitter
     
  28. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    Don't worry, I'm being a complete idiot. For some reason, I got confused about the material list on the controller. I thought it was referencing types of the mask shapes due to the list but it's in fact the materials to mask. Durrrrr! Thanks for responding and sorry for the time waste.
     
  29. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I need to highlight certain faces (I am making a runtime model editor). Any suggestions on how I would do that?

    I would like this highlight to appear above (on top of) the normal texture, but below the wireframe. So it seems like it would require modifying the wireframe shader. I might be able to use vertex colors, though I'm not sure if that will work in all cases (there may be shared vertices). So in that case, I might need to use SV_PrimitiveID to check the triangle number in the fragment shader, and compare that to some map of triangles to highlight.

    But all that sounds like a lot of work, so if there is a simpler solution, I'd love to hear it!

    (EDIT: I just found the bit in the docs explaining that Amazing Wireframe generates unique vertices for each triangle as part of the "baking" process. So I guess vertex colors should work fine.)
     
    Last edited: Apr 22, 2021
  30. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    Is it possible to fade the edges of the dynamic mask somehow so there is feathered blend at the boundary? I would ideally like to be able to fade along the boundary of the mask. I own Dissolve and Dynamic Mask as well if helpful.
     
  31. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    If using Wireframe shader's dynamic mask then it has property inside material editor to fade mask edges.
    If you are using it with DRM, then you have full control over radial masks, their edges and intensity.



    Amazing Assets - YouTube Facebook Twitter
     
  32. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    DRM docs say code needs to be written into shaders. I'm looking at code and BuiltinRPCore seems like it might be the best place to add the mask, do I have to write DRM into WF? Thanks again
     
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    It is better to use Amplify Shader Editor or Unity ShaderGraphI it is much easier using those tools, instead of modifying hlsl code.



    Amazing Assets - YouTube Facebook Twitter
     
  34. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    Me again, sorry. Plugging away with Amplify, life is getting easier finally...

    I have one simple question, does the geometric shader support Amplify, as I don't seem to get any frames unless baked? Thanks
     
  35. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Not sure about GeometryShaders support in ASE. It is better to ask ASE developer.



    Amazing Assets - YouTube Facebook Twitter
     
  36. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    I can confirm it doesn't work out of the box, not to worry I see if I can hack it in later... Thanks
     
  37. maatvee

    maatvee

    Joined:
    Oct 4, 2014
    Posts:
    5
    Hi Arkhivrag, I've been messing with the possibility of using a compute shader to render the procedural mesh, since ideally I would like to be able to generate the mesh on every frame, and currently using the CPU is far too slow (and is even worse on the Oculus Quest.)

    I've been looking at the source code for the latest version of the Amazing Wireframe Shader (AWS), to see if it might be possible to somehow get the wireframe mesh to render without having to copy the mesh data back from the GPU again, but It appears to require pre-processing on the CPU before the data gets passed to the actual shader. Ideally I would do all the processing on the GPU instead.

    I want to avoid a solution using any geometry shaders if possible since they aren't supported on the Oculus Quest ,and are too slow (AFAIK).

    Do you have any advice on how to approach this, and if it's even possible using compute shaders to generate the mesh and render the wireframe with your current AWS implementation?

    Cheers Maatvee
     
  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    For wireframe rendering shader reads barycentric coordinates baked inside mesh UV4 (TEXCOORD3 for shader).
    You can check BakeTriangleMassToUV method in WireframeGenerator.cs file and try to copy its logic inside compute shader.
    Same method is WireframeShaderCalculateTriangleMass from WireframeShader.cginc file used by GeometryShaders.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: May 25, 2021
  39. maatvee

    maatvee

    Joined:
    Oct 4, 2014
    Posts:
    5
    Awesome, thanks for the quick reply! I'll have to dig into your code and see what I can learn.

    Cheers Maatvee
     
  40. maatvee

    maatvee

    Joined:
    Oct 4, 2014
    Posts:
    5
    Hi Arkhivrag,

    I've been trying to eliminate some nasty jaggies using the URP AmazingWireFrameShaderthat seem to appear on the edges of objects and a few random quads that still get triangulated. (highlighted in the image below).

    You can see that the general wireframe rendering looks great on the Oculus Quest, but the nasty edges really spoil the wireframe effect.

    I've tried increasing the wire thickness settings, MSAA settings and PostProcessing camera anti-aliasing with no luck.

    Bgolus provides some clues that using MSAA isn't the solution and mentions a steam article in this thread: https://forum.unity.com/threads/white-jagged-edges-based-on-angle.491775/

    the PDF mentions some shader code that might help, but I haven't had any luck getting it to work.

    I've been playing with the basic unlit wireframe shader code to see if I can improve things.

    Code (CSharp):
    1. float3 vNormalWsDdx = ddx( vGeometricNormalWs.xyz );
    2. float3 vNormalWsDdy = ddy( vGeometricNormalWs.xyz );
    3. float flGeometricRoughnessFactor = pow( saturate( max( dot( vNormalWsDdx.xyz, vNormalWsDdx.xyz ), dot( vNormalWsDdy.xyz, vNormalWsDdy.xyz ) ) ), 0.333 );
    4. vRoughness.xy = max( vRoughness.xy, flGeometricRoughnessFactor.xx ); // Ensure we don’t double-count roughness if normal map encodes geometric roughness
    See Page 43: http://media.steampowered.com/apps/valve/2015/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf


    Anyways some tasty tips on how to proceed or what else to try would be much appreciated.

    Cheers Maatvee

    nasty_edge_jaggies.jpg
     
  41. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    Quad rendering is not 100% perfect as inside a shader it is not possible to detect whether rendered pixel is part of a triangle or quad. It can be done by improving script algorithm that generates wireframe data for mesh. Currently I have no better and faster solution. :oops:

    As for seems on the edges, I'll check Steam article, thanks.



    Amazing Assets - YouTube Facebook Twitter
     
  42. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    upload_2021-6-30_14-39-47.png

    Here's to another 7 years.


    Be well
     
    Arkhivrag likes this.
  43. appleboxman

    appleboxman

    Joined:
    Apr 17, 2020
    Posts:
    5
    Can Wireframe shader Effect only show the vertices only?
     
  44. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
  45. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Hello, I had the same question and it would be really useful and awesome that this asset could be able to ONLY paint or show just the lines of the vertices of an object mesh, but unfortunately the answer is no

    It seems that you need to have a curvature map to make show only vertices as it happens with the "Worn Edges" asset available in asset store, you can try it, but is not a always a good alternative that only works sometimes depending on the object mesh
     
  46. megapode

    megapode

    Joined:
    May 4, 2021
    Posts:
    10
    Hi there, first of all thank you for the tools and shaders that you are producing they are excellent!
    I have just bought the Amazing Shaders Bundle in the sale (even though I already had the wireframe one) and I am now trying to create an effect combining your Dissolve shader and the Wireframe one.

    Essentially, I am trying to create an effect inspired by the double sided dissolve where you have the trees on one side and the building materials on the other.

    I would like to start with the wireframe and dissolve in the 'filled-in' version and ideally I would like to keep the glow line effect from the dissolve shader too. Is this possible/simple to do?

    Alternatively, do I need to experiment with the plane filter in Wireframe shader and the plane filter in Dissolve and essentially fake the effect?

    (I should point out that I am a complete novice at shaders and texturing in general...)

    I hope this makes sense?

    Thanks again,
    Matt
     
    Last edited: Nov 6, 2021
  47. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,982
    It is easy to combine Advanced Dissolve and Wireframe Shader, if you know how to use ShaderGraph and are familiar with both shader assets and their controller scripts.

    Here is example of implementing wireframe effect into Lit (Cutout) shader from Amazing Assets\Advanced Dissolve\Shaders\ShaderGraph folder.
    Only wireframe nodes have been added here:
    Untitled.png

    And here is the result:
    3.gif

    Wireframe plane mask is controlled from Wireframe Mask Controller script.



    Amazing Assets - YouTube Facebook Twitter
     
  48. megapode

    megapode

    Joined:
    May 4, 2021
    Posts:
    10
    Hi, Arkhivrag,
    thank you! I currently have no understanding of how shader graph works, I don't think I have even ever looked at one before :D but the fact that you have shown what to do is inspirational and very helpful, thank you so much, really appreciated!
    The effect above is not quite what I envisage, in my head, but this is the inspiration that I need to dig in further and understand what is happening and work out how to get the effect that I am looking for.

    Learning from people, who know what they are doing is the way forward.

    Yet another thanks and all the best...

    Matt
     
  49. megapode

    megapode

    Joined:
    May 4, 2021
    Posts:
    10
    OK, so it turns out that I really have no clue (yet) on shaders and shader graph...
    What I am trying to do is the following...
    Above the plane it shows the wireframe.
    At the plane it shows the glow/dissolve effect
    Below the plane it shows the coloured texture but without the wireframe.
    In other words the wireframe is visible above the plane and no wireframe is visible below the plane.
    Above the plane there is no filled in graphics, below the plane the graphics are filled in.

    I hope that makes sense? So many thanks in advance for any help you can give me.

    showingEffect.png
     
  50. megapode

    megapode

    Joined:
    May 4, 2021
    Posts:
    10
    Sometimes, trying everything and keeping going also works...
    In WireframeMaskController, I replaced the transform as:


    materials.SetVector("_WireframeShaderMaskPlaneNormal", maskObject.up * -1);

    this then gets exactly the effect that I am looking for... I don't know if it is the proper way, but it works for now...

    correctVersion.png