NormalSmoothing

From Unify Community Wiki
Revision as of 10:46, 1 June 2008 by MrJoy (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This shader shows you the normals on your mesh so you can see the result of normal smoothing more explicitly.

An icosahedron with normal smoothing set to 35 degrees: File:Smooth35.jpg The same object with normal smoothing set to 40 degrees: File:Smooth40.jpg The same object with normal smoothing set to 45 degrees: File:Smooth45.jpg

<shaderlab> Shader "MrJoy/Debug/Normal Smoothing" {

 Properties { }  
 SubShader {
   Pass {
     CGPROGRAM
       #pragma vertex vert
       #pragma fragment frag
       #pragma fragmentoption ARB_fog_exp2
       #pragma fragmentoption ARB_precision_hint_fastest
       #include "UnityCG.cginc"
       #include "AutoLight.cginc"
       struct v2f {
         V2F_POS_FOG;
         float3 normal : COLOR;
       };  
       v2f vert(appdata_tan v) {
         v2f o;
         PositionFog( v.vertex, o.pos, o.fog );
         o.normal = (v.normal + 1) * 0.5;
         return o;
       }
       
       half4 frag(v2f i) : COLOR {
         i.normal = normalize(i.normal);
         return half4(i.normal.rgb, 1);
       }
     ENDCG
   }
 }

} </shaderlab>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox