1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Shader "Custom/MyShader" { // 属性,可以再Unity中修改和绑定 Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _Glossiness ("Smoothness", Range(0,1)) = 0.5 _Metallic ("Metallic", Range(0,1)) = 0.0 } SubShader { Pass { CGPROGRAM // 编写CG代码开始
#pragma vertex my_vert
// 获取上一个工位的参数 -> 语义bind float4 my_vert(float4 pos : POSITION ): POSITION{ return UnityObjectToClipPos(pos); } #pragma fragment my_frag fixed4 my_frag() : COLOR{ // 设置红色 return fixed4 (1.0,0.0,0.0,1.0); }
ENDCG// 编写CG代码结束 } } FallBack "Diffuse" }
|