Shader "BasicDiffuse"
{
// 属性
Properties
{
_MainTex ("_MianTex", 2D) = "white" {}
}
SubShader
{
// 标签
Tags
{
// 渲染类型 : 不透明物体
"RenderType" = "Opaque"
}
// 层次细节 200
LOD 200
// CG代码
CGPROGRAM
// 预处理指令
// surface surf : 指定这是一个surface类型的shader,其函数名为surf
// Lambert : 指定所使用的光照模型为Lambert兰伯特光照模型
#pragma surface surf Lambert
// 属性:这是CG代码段使用的属性,需保持和Properties一样的属性名
sampler2D _MainTex;
// 输入结构体
struct Input
{
// 纹理的UV
float2 uv_MainTex;
};
// 着色函数
void surf(Input IN, inout SurfaceOutput o)
{
// tex2D : 纹理采样函数
half4 c = tex2D(_MainTex, IN.uv_MainTex);
// 将采样到的颜色进行输出
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
}
漫反射着色 - 创建基本的表面着色器
最新推荐文章于 2022-09-15 13:15:50 发布