Created
June 16, 2020 06:37
-
-
Save unitycoder/b259d167d6479f9efcf7570e92ef78aa to your computer and use it in GitHub Desktop.
Normal Debug Shader (Show Normals)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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