我在自定义着色器中定义了一些变量:
_Emiss("emission", Float) = .5
_Albed("albedo", Float) = .9
到这里为止一切都很好,但是当我尝试在代码中使用变量时:
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * _Albed;
o.Emission = texCUBE (_Cube, IN.worldRefl).rgb * _Emiss;
}
我收到一些错误,告诉我没有声明 _Albed 和 _Emiss。
我究竟做错了什么?
这是完整的着色器:
Shader "Custom/cubemapReflShader" {
Properties {
_MainTex ("Texture", 2D) = "red" {}
_Cube ("Cubemap", CUBE) = "" {}
_Emiss("emission", Float) = .5
_Albed("albedo", Float) = .9
// _RefrColor ("Refraction color", Color) = (.34, .85, .92, 1) // color
}
SubShader {
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert
struct Input {
float2 uv_MainTex;
float3 worldRefl;
};
sampler2D _MainTex;
samplerCUBE _Cube;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * .9;
o.Emission = texCUBE (_Cube, IN.worldRefl).rgb * .5;
}
ENDCG
}
Fallback "Diffuse"
}