u3d的shader内置了一种surf的 一种裸的
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
// apply fog
//UNITY_APPLY_FOG(i.fogCoord, col);
col=fixed4(i.uv,0.,1.);
return col;
}
裸的这种 vert就是顶点着色器 frag这个是片元着色器
void surf (Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
另外这种 只需要写片元着色器的一部分 内置了很多东西了已经
创建任意一个品种的shader文件
m_cube.GetComponent<MeshRenderer> ().material = new Material (Shader.Find("Unlit/11"));
这个路径是shader文件的第一行那个地方
这个还可以在编辑器里创建一个材质球 然后把他拖上去
U3D的shader有好多东西之前都没见过(Pass SubShader什么的) 还要慢慢学习