关于Shader的学习记录


float4 _EmissiveColor; float4 _AmbientColor; float _MySliderValue; void surf (Input IN, inout SurfaceOutput o) { // Albedo comes from a texture tinted by color float4 c; c = pow((_EmissiveColor + _AmbientColor), _MySliderValue); o.Albedo = c.rgb; // Metallic and smoothness come from slider variables o.Alpha = c.a;

1.如果没注意将_MySliderValue的数据类型声明成float4,那么shader将不会起作用并且不会报错。

CGPROGRAM
			#pragma surface surf BasicDiffuse

		inline float4 LightingBasicDiffuse(SurfaceOutput s,fixed3 lightDir, fixed atten)
	{
		float difLight = max(0, dot(s.Normal, lightDir));
		float4 col;
		col.rgb = s.Albedo * _LightColor0.rgb * (difLight * atten * 2);
		col.a = s.Alpha;
		return col;
	}

2.自建光照模型 定义要在#下

<1> 疑问:关于rgb的运算方式,是如何进行运算得出颜色值的,0,1对它的运算影响。

3. 报错Too many texture interpolators would be used for ForwardBase pass at line

错误原因是在报错Shader里,在结构体Input中定义了大于等于3个的额外的uv变量信息。?

struct Input {  
            float2 offset1;  
            float2 offset2;  
            float2 offset3;  
            float4 pos;  
            fixed4 color;  
        };  

<2> shader入门资料

http://www.360doc.com/content/13/0923/15/12282510_316492286.shtml

转载于:https://www.cnblogs.com/white-L/p/6523383.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值