Wireframe Shader
  • Wireframe Shader
  • Quick Start
  • Wireframe Mesh Creator
  • Wireframe Texture Creator
  • Dynamic Wireframe Rendering
  • Dynamic Mask Controller
  • Custom Shaders
    • Hand-written shaders
    • Shader Graphs
  • Run-time API
  • Help & Contact
Powered by GitBook
On this page

Run-time API

Last updated 6 months ago

Run-time API for calculating wireframe data for a mesh or generating wireframe texture can be brought into scope with this using directive

using AmazingAssets.WireframeShader;

Unity class now will have 2 additional extension methods:

Mesh GenerateWireframeMesh(bool normalizeEdges, bool tryQuad)

Generates new mesh with wireframe data baked inside uv4 buffer (inside shader uv4 coordinate is read using TEXCOORD3 semantic). Resultant mesh is in 16 bit index buffer format if it has less than 65,535 vertices, otherwise mesh uses 32 bit index buffer format.

Texture2D GenerateWireframeTexture(bool useGeometryShader, int submeshIndex, 
                                   bool normalizeEdges, bool tryQuad, 
                                   float thickness, float smoothness, 
                                   int resolution)

Generates wireframe texture.

useGeometryShader – If enabled, wireframe texture is generated using GeometryShaders and the source mesh does not need to have wireframe data baked inside it. For run-time use, project must include Amazing Assets/Wireframe Shader/Texture Exporter file into the build.

if useGeometryShader option is false then texture is generated based on the wireframe data baked inside the source mesh.

submeshIndex - Index of a submesh for which is rendered wireframe texture. Using -1 bakes all submesh's wireframe data into one texture.

normalizeEdges – Wireframe triangle edges will be approximately of the same size.

tryQuad – Renders wireframe in quad shape instead of a triangle. Result highly depends on a mesh vertex & triangle layout.

thickness/smoothness – Wireframe edge size (thickness) and its smoothness.

resolution - Texture resolution. Must be power of 2, in the range of 16 – 8192.

Mesh