Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity Internal Scene View / Shaded Wireframe Shader

Discussion in 'Shaders' started by shawww, Oct 31, 2016.

  1. shawww

    shawww

    Joined:
    Sep 30, 2014
    Posts:
    43
    Hey ya'll,

    I'm trying to find the source code to whatever Unity is using to render wireframes on selected objects, or what shader is being used in the "Shaded Wireframe" editor mode.

    We really want the effect and look of the Shaded Wireframe in our scene editor, but cannot reproduce it in our Game View -- in spite of using a bunch of Wireframe shaders, overlaying GL.Wires, etc etc. Our goal is essentially to reproduce the look of the scene editor inside of the Game View.

    I'm not looking for a purchasable asset -- we're tried all of the available assets, what we're looking for is something that I've only seen in the editor, and it seems like it should be pretty straightforward to reproduce in our game view-- but it hasn't been.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,208
  3. shawww

    shawww

    Joined:
    Sep 30, 2014
    Posts:
    43
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,208
    That makes everything draw as wireframe. If you want to do shaded wireframe like the editor you need to render the scene normally, then set GL.wireframe = true and render the entire scene again using a replacement shader or manual GL.DrawMesh calls that just uses a solid black shader with a minor offset.

    AFAIK that's what Unity's view does.

    The alternative, if you're running DX11, or equivalent console / desktop OpenGL, it might be faster / cleaner to use a geometry shader approach (less zfighting, "free" line anti-aliasing), like https://www.assetstore.unity3d.com/en/#!/content/11638 or https://www.assetstore.unity3d.com/en/#!/content/21897 but it depends on your use case.
     
  5. wunderri

    wunderri

    Joined:
    Apr 12, 2023
    Posts:
    1
    Hey,
    I'm currently dealing with the same problem and your first solution sounds like it might be worth a try.
    Do you have a suggestion how to implement the two-step rendering as an automatic behaviour?
    Thank you!
    Richard
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,208
    Not really, no.

    The "easiest" way might be using two cameras, and use a custom script to set GL.wireframe on and off during OnPreRender and OnPostRender.