-接上篇-修改逐顶点的漫反射高光为逐像素类型
首先:法线与顶点在世界空间下的矩阵与位置保留在顶点中计算
其次:环境光+漫反射+高光光照计算移动到frag片元函数中
Shader "Davia/08_Specular Fragment"{
Properties{
_DiffuseColor("Diffuse Color",color) = (1,1,1,1)
_SpecularColor("Specular Color",color) = (1,1,1,1)
_SpecularPow("Specular Pow",Range(1,20)) = 1.0
}
SubShader
{
Pass
{
Tags{"Lightmode" = "ForwardBase"}
CGPROGRAM
#include"Lighting.cginc"
#pragma vertex vert
#pragma fragment frag
fixed4 _DiffuseColor;
fixed4 _SpecularColor;
fixed _SpecularPow;
//application to vertex
struct a2v{
float4 vertex:POSITION;
fixed3 normal:NORMAL;
};
//vertex to fragment
struct v2f{
float4 position:SV_POSITION;
float3 worldnormal:TEXCOORD0;