Debug Shaders

The Debug Tools package comes with several shaders to visualize different vertex data. These shaders are located under Zigurous > Debug within the shader selection menu.


UV

v2f vert (appdata v)
{
    v2f o;
    o.pos = UnityObjectToClipPos(v.vertex);
    o.uv = float4(v.texcoord.xy, 0, 0);
    return o;
}


Normals

v2f vert (appdata v)
{
    v2f o;
    o.pos = UnityObjectToClipPos(v.vertex);
    o.color.xyz = v.normal * 0.5 + 0.5;
    o.color.w = 1.0;
    return o;
}


Tangents

v2f vert (appdata v)
{
    v2f o;
    o.pos = UnityObjectToClipPos(v.vertex);
    o.color = v.tangent * 0.5 + 0.5;
    return o;
}


Bitangents

v2f vert (appdata v)
{
    v2f o;
    o.pos = UnityObjectToClipPos(v.vertex);
    float3 bitangent = cross(v.normal, v.tangent.xyz) * v.tangent.w;
    o.color.xyz = bitangent * 0.5 + 0.5;
    o.color.w = 1.0;
    return o;
}


Vertex Color

v2f vert (appdata v)
{
    v2f o;
    o.pos = UnityObjectToClipPos(v.vertex);
    o.color = v.color;
    return o;
}