Game Development Reference
In-Depth Information
//Specular - Gloss
fixed3 h = normalize (lightDir + viewDir); // Get the Normalize
of the lighting direction and view direction
float nh = saturate(dot (s.Normal, h)); //Make sure that
the return number isn't lower than 0 or greater than 1
float specPower = pow (nh, _Glossiness);
fixed3 specular = _LightColor0.rgb * specPower * _
SpecularColor.rgb;
//Result
fixed4 c;
c.rgb = (ambient + diffuse + specular) * (atten * 2);
c.a = s.Alpha + (_LightColor0.a * _SpecularColor.a * specPower
* atten);
return c;
}
ENDCG
}
We have finished this step. We can now go back to Unity, and click Play to see our result with
the specular relecion, as shown in the following screenshot:
 
Search WWH ::




Custom Search