Shader顶点程序片段程序及参数

Shader "Custom/VFShader"
{
    
    SubShader
    {
		pass {
			CGPROGRAM
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it uses non-square matrices
#pragma exclude_renderers gles
			//定点程序
			#pragma vertex vert
			//片段程序
			#pragma fragment frag
			//定义宏
			#define MACROFL FL4(fl4.ab,fl3.zy);

			typedef float4 FL4;


			//定点类型的输出必须是float4的形式
			void vert(in float2 objPos:POSITION,out float4 pos:POSITION,out float4 col:COLOR)
			{
				pos = float4(objPos,0,1);
				col = pos;
			}
			//最终呈现的颜色进行计算,对颜色的输出最优化使用fixed
			void frag(inout float4 col:COLOR0) 
			{
				//col = float4(0,1,0,1);

				fixed r = 1;
				fixed g = 0;
				fixed b = 0;
				fixed a = 1;

				col = fixed4(r, g, b, a);

				bool bl = false;

				col = bl ? col : fixed4(0, 1, 0, 1);

				float2 fl2 = float2(1, 0);
				float3 fl3 = float3(1, 0, 1);
				float4 fl4 = float4(1, 1, 0, 1);

				float4 fl = MACROFL //swizzle操作 xyzw rgba .xy .yx 可以颠倒

				col = fl;

				float2x4 M2x4 = { {0,0,1,1},{0,1,0,1} };

				col = M2x4[0];

				float arr[4] = { 1,0.5,0.5,1 };
				col = float4(arr[0], arr[1], arr[2], arr[3]);
			}
			//基本数据类型:float half fixed bool int sampler*
			//while(){}
			//do{}while()
			//for(){}
			//switch(){case:break;}
			ENDCG
		}
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值