1.Standard
Shader "Custom/Surf1"{
Properties{
_DiTex("Main Tex",2D) = "white"{}
_Metallic("Metallic",range(0.0,1.0)) = 0.0
_Smoothness("Smoothness" ,range(0.0,1.0)) = 0.0
}
SubShader{
Tags{"RenderType"="Opaque"}
LOD 100
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
sampler2D _DiTex;
float _Metallic;
float _Smoothness;
struct Input
{
float2 uv_DiTex;
};
void surf(Input IN,inout SurfaceOutputStandard o){
// 从贴图中采样颜色
half4 c = tex2D(_DiTex, IN.uv_DiTex);
o.Albedo = c.rgb; // 设置漫反射颜色
o.Smoothness = _Smoothness;
o.Metallic = _Metallic;
o.Alpha = c.a; // 设置透明度
}
ENDCG
}
FallBack "Diffuse"
}
效果
物理效果的输出:
struct SurfaceOutputStandard
{
fixed3 Albedo; // 基础(漫射或镜面反射)颜色
fixed3 Normal; // 切线空间法线(如果已写入)
half3 Emission;
half Metallic; // 0=非金属,1=金属
half Smoothness; // 0=粗糙,1=平滑
half Occlusion; // 遮挡(默认为 1)
fixed Alpha; // 透明度 Alpha
};