- 最后登录
- 2019-12-25
- 注册时间
- 2012-8-24
- 阅读权限
- 90
- 积分
- 71088
 
- 纳金币
- 52352
- 精华
- 343
|
表面着色器(Surface Shader)的标准输出结构是这样的:
struct SurfaceOutput {
half3 Albedo; //反射率
half3 Normal; //法线
half3 Emission; //自发光,用于增强物体自身的亮度,使之看起来好像可以自己发光
half Specular; //镜面
half Gloss; //光泽
half Alpha; //透明
};
请问,这个表面结构能不能修改?
比如我现在要用的材质不需要去计算Gloss,Alpha,Specular等等,我只需要Albedo,Normal。
我直接删掉的话编译器会报错。
代码如下:
Shader "xindiban" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Diffuse (RGB) Alpha (A)", 2D) = "white" {}
_SpecularTex ("Specular (R) Gloss (G) Anisotropic Mask (B)", 2D) = "gray" {}
}
SubShader{
Tags { "RenderType" = "transparent" }
CGPROGRAM
struct SurfaceOutputAniso {
fixed3 Albedo;
fixed3 Normal;
fixed4 AnisoDir;
fixed3 Emission;
half Specular;
fixed Gloss;
fixed Alpha;
};
inline fixed4 LightingAniso (SurfaceOutputAniso s, fixed3 lightDir, fixed3 viewDir, fixed atten)
{
fixed4 c;
c.rgb = _LightColor0.rgb;
c.a = 1;
return c;
}
#pragma surface surf Aniso
#pragma target 3.0
struct Input
{
float2 uv_MainTex;
};
sampler2D _MainTex, _SpecularTex;
void surf (Input IN, inout SurfaceOutputAniso o)
{
fixed4 albedo = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = albedo.rgb;
o.Alpha = albedo.a;
o.Normal.z = 0;
o.Normal.x = 0;
o.Normal.y = 0;
}
ENDCG
}
FallBack "Transparent/Cutout/VertexLit"
}
红色部分我如果加上去,那么着色器可以通过编译,如果删掉,就会报错。
问题是我的这个shader不需要去对红色部分的数据进行什么计算。
还是说我如果不去管它的话就跟没加一样的? 它跟内置的lambert光照模式有区别么? 我不去计算的话。 |
|