NormalSmoothing

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: 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: [[Image:Smooth35.jpg]...)
 
Line 2: Line 2:
  
 
An icosahedron with normal smoothing set to 35 degrees:
 
An icosahedron with normal smoothing set to 35 degrees:
[[Image:Smooth35.jpg]]
+
[[Image:Smooth35.png]]
 
The same object with normal smoothing set to 40 degrees:
 
The same object with normal smoothing set to 40 degrees:
[[Image:Smooth40.jpg]]
+
[[Image:Smooth40.png]]
 
The same object with normal smoothing set to 45 degrees:
 
The same object with normal smoothing set to 45 degrees:
[[Image:Smooth45.jpg]]
+
[[Image:Smooth45.png]]
  
 
<shaderlab>
 
<shaderlab>

Revision as of 10:47, 1 June 2008

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: Smooth35.png The same object with normal smoothing set to 40 degrees: Smooth40.png The same object with normal smoothing set to 45 degrees: Smooth45.png

<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