shader 关键字

//http://blog.csdn.net/poem_qianmo/article/details/49556461
Shader "Custom/Surface/MainText_1"
{
	Properties
	{
		//2D、Rect、Cube的默认值后面可以跟上{}
		//TexGen texgenmode : 自动生成贴图的uv坐标。texgenmode参数可以是:ObjectLinear, EyeLinear, SphereMap, CubeReflect, CubeNormal; 都直接对应到OpenGL的texgen模式。如果用户用了自定义的顶点方法,那么TexGen会被unity忽略。
		_Range("Range",Range(0,1)) = 0
		_Color("Color",Color) = (1,1,1,1)
		//创建一个图片选择框,可以让用户选择贴图
		_2D("2D",2D) = "white"
		//创建一个non-power-of-2贴图选择框,功能基本跟2D想同
		_Rect("Rect",Rect) = "white"
		//创建一个选择Cubmap的框
		_Cube("Cube",Cube) = "white"
		_Float("Float",Float) = 1
		_Vector("Vector",Vector) = (1,1,1,1)


		_MainTexture("MainTexture",2D) = "white"
	}

	SubShader
	{
		//Camera.RenderWithShader 或 Camera.SetReplacementShader
		//RenderType Opaque Transparent Background Overlay
		//Queue Background Geometry AlphaTest Transparent Overlay + 1
		//ForceNoShadowCasting
		//IgnoreProjector
		Tags{"RenderType" = "Opaque" "Test" = "1" "Queue" = "Geometry"}

		//Shader.globalMaximumLOD
		//VertexLit kind of shaders = 100
		//Decal, Reflective VertexLit = 150
		//Diffuse = 200
		//Diffuse Detail, Reflective Bumped Unlit, Reflective Bumped VertexLit = 250
		//Bumped, Specular = 300
		//Bumped Specular = 400
		//Parallax = 500
		//Parallax Specular = 600
		LOD 200

		//http://blog.csdn.net/ecidevilin/article/details/52864349.
		//Blend Off     不混合
		//Blend SrcFactor DstFactor  SrcFactor是源系数,DstFactor是目标系数
		//Blend SrcAlpha  OneMinusSrcAlpha:
		//...
		Blend One One
		
		//On/Off,默认值为On
		ZWrite On

		//Greater/GEqual/Less/LEqual/Equal/NotEqual/Always/Never/Off,默认值为LEqual
		//当ZTest取值为Off时,表示的是关闭深度测试,等价于取值为Always
		ZTest Off

		//Cull Off 不剔除
		//Cull Back 剔除背面(背向摄像机的面)
		//Cull Front 剔除前面 (朝向摄像机的面)
		Cull Back

		//read
		//Lighting Off On

		//read
		//1.Fog{ Fog Commands }
		//2.Mode Off | Global | Linear | Exp | Exp2(雾的模式,缺省值是Global)
		//3.Color ColorValue(雾的颜色)
		//4.Density FloatValue(雾的浓度,影响Exp / Exp2)
		//5.Range FloatValue, FloatValue(雾的开始和结束距离,影响Linear)
		//Fog{ Mode Linear Color[_Color] Range[_From],[_To] Density[_Density] }
		Fog{ Color(0,0,0,0) }

		CGPROGRAM
		//http://blog.csdn.net/ecidevilin/article/details/52879485
		#pragma surface surf Standard

		//2.0, Direct3D 9 (默认缺省值)。支持32张贴图 + 64个计算
		//有限的算术和材质说明 , 没有顶点纹理采样 , 在片段着色器没有衍生品
		//3.0, Direct3D 9。支持512张贴图 + 512个计算
		//4.0, 只支持DirectX 11。
		//5.0, 只支持DirectX 11
		#pragma target 3.0
		

		sampler2D _MainTexture;

		struct Input {
			float2 uv_MainTexture;
		};

		void surf(Input IN, inout SurfaceOutputStandard o) 
		{
			fixed4 c = tex2D(_MainTexture, IN.uv_MainTexture);
			o.Albedo = c.rgb;
		}
		ENDCG
	}
	FallBack "Diffuse"

	//CustomEditor "StandardShaderGUI"
}

  

原文地址:https://www.cnblogs.com/AlanCheng/p/7735472.html