about migrate built-in shaders.unity version 4 -> 5

Technically speaking,this is a SurfaceShader based on physically-based rendering.So it was different way.

About migrate your built-in shaders you must know:

1.Shaders no longer apply a 2x multiply of light intensity

[lang:C#] [Shader Example] [http://vrast.cn] [example unity4->5]
1
2
3
4
5
// A common pattern in shader code that has this problem will look like this
c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
// You need to fix the code so it looks more like this
c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten);

2.Surface shaders alpha channel change
By default all opaque surface shaders output 1.0 (“white”) into alpha channel now.
If you’re using custom lighting functions, you probably want to add something like “c.a = s.Alpha” towards the end of #pragma surface line.

3.Sorting by material index has been removed
The order depends on what reduces the most state changes to render the scene.

4.Fixed function TexGen, texture matrices and some SetTexture combiner modes were removed

5.Mixing programmable & fixed function shader parts is not allowed anymore

6.“unity_Scale” shader variable has been removed

1
2
3
4
5
6
7
8
9
10
11
12
// Unity 4.x
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal * unity_Scale.w);
// Becomes this in Unity 5.0
float3 norm = normalize(mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal));


// Unity 4.x
temp.xyzw = v.vertex.xzxz * unity_Scale.xzxz * _WaveScale4 + _WaveOffset;

// Becomes this in Unity 5.0
float4 wpos = mul (_Object2World, v.vertex);
temp.xyzw = wpos.xzxz * _WaveScale4 + _WaveOffset;

The detail: http://docs.unity3d.com/Manual/UpgradeGuide5-Shaders.html