我真的是新手,这是我第一次为团结手机游戏写一个着色器。 这是着色器,在编辑器上运行良好但在我的Android设备上运行良好:
Shader "Decal" {
Properties {
_Skin("Skin (RGB)", 2D) = "white" {}
_Dirt("Dirt (RGBA)", 2D) = "black" {}
_Outfit("Outfit (RGBA)", 2D) = "black" {}
_Painting("Painting (RGBA)", 2D) = "black" {}
_Cheek("Cheek (RGBA)", 2D) = "black" {}
_LipStick("LipStick (RGBA)", 2D) = "black" {}
_Eye("Eye (RGBA)", 2D) = "black" {}
_EyeLid("EyeLid (RGBA)", 2D) = "black" {}
_ShadowHat("ShadowHat (RGBA)", 2D) = "black" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 150
CGPROGRAM
#pragma surface surf Lambert noforwardadd
sampler2D _Skin;
sampler2D _Dirt;
sampler2D _Outfit;
sampler2D _Painting;
sampler2D _Cheek;
sampler2D _LipStick;
sampler2D _Eye;
sampler2D _EyeLid;
sampler2D _ShadowHat;
struct Input {
float2 uv_Skin;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_Skin, IN.uv_Skin);
fixed4 dirt = tex2D(_Dirt, IN.uv_Skin);
fixed4 outfit = tex2D(_Outfit, IN.uv_Skin);
fixed4 painting = tex2D(_Painting, IN.uv_Skin);
fixed4 cheek = tex2D(_Cheek, IN.uv_Skin);
fixed4 lipstick = tex2D(_LipStick, IN.uv_Skin);
fixed4 eye = tex2D(_Eye, IN.uv_Skin);
fixed4 eyelid = tex2D(_EyeLid, IN.uv_Skin);
fixed4 shadowHat = tex2D(_ShadowHat, IN.uv_Skin);
c.rgb = lerp (c.rgb, dirt.rgb, dirt.a);
c.rgb = lerp (c.rgb, outfit.rgb, outfit.a);
c.rgb = lerp (c.rgb, painting.rgb, painting.a);
c.rgb = lerp (c.rgb, cheek.rgb, cheek.a);
c.rgb = lerp (c.rgb, lipstick.rgb, lipstick.a);
c.rgb = lerp (c.rgb, eye.rgb, eye.a);
c.rgb = lerp (c.rgb, eyelid.rgb, eyelid.a);
c.rgb = lerp (c.rgb, shadowHat.rgb, shadowHat.a);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Mobile/VertexLit"
}
所以任何帮助都会非常受欢迎:),还有一件事要澄清,我不确定这款着色器的性能是否足够适合移动设备?
非常感谢你!
答案 0 :(得分:1)
根据这个Unity Manual,OpenGL ES 2.0仅在一个着色器中支持最多8个纹理。 此外,如果您转到修改>图形仿真菜单并选择 OpenGL ES 2.0 ,您可以看到它的着色器警告。
我不确定这款着色器的性能是否足以满足移动设备的需求?
您在一个着色器中使用了太多 sampler2D&#39> 。您还应该避免在着色器代码中使用昂贵的数学函数。您的着色器对于移动设备而言非常昂贵。
答案 1 :(得分:0)
所以现在我觉得我做错了。这个着色器用于角色定制,我的着色器技能接近0,所以我将放弃这个解决方案。
最后我认为最好在运行时合并所需的纹理并将结果应用于移动着色器。