Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created June 16, 2020 06:37
Show Gist options
  • Select an option

  • Save unitycoder/b259d167d6479f9efcf7570e92ef78aa to your computer and use it in GitHub Desktop.

Select an option

Save unitycoder/b259d167d6479f9efcf7570e92ef78aa to your computer and use it in GitHub Desktop.
Normal Debug Shader (Show Normals)
// https://docs.unity3d.com/Manual/ShaderTut2.html
Shader "Tutorial/Display Normals"
{
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
fixed3 color : COLOR0;
};
v2f vert (appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.color = v.normal * 0.5 + 0.5;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return fixed4 (i.color, 1);
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment