Hello…
I am making a game on iOS and I need certain objects to have a glossy sheen to them. What is the best/cheapest method for doing this? I am currently using the default Specular shader. I imagine this is pretty expensive, but there doesn’t seem to be a Mobile/Specular shader…
I tried writing a mobile specular shader, using examples I found around the web…
Shader "Mobile/Specular" {
Properties {
_Shininess ("Shininess", Range (0.01, 1)) = 0.5
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 300
CGPROGRAM
#pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap noforwardadd halfasview novertexlights
inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten)
{
fixed diff = max (0, dot (s.Normal, lightDir));
fixed nh = max (0, dot (s.Normal, halfDir));
fixed spec = pow (nh, s.Specular*128) * s.Gloss;
fixed4 c;
c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * (atten*2);
c.a = 0.0;
return c;
}
sampler2D _MainTex;
half _Shininess;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = tex.rgb;
o.Gloss = tex.a;
o.Specular = _Shininess;
}
ENDCG
}
Fallback "VertexLit"
}
…but Unity still warns me that the shader might be expensive on this platform.
So, my questions are…
- Would the above shade be faster than the default Specular, or the Mobile/Bumped Specular?
- Is there a cheap way of getting shiny objects for a mobile/tablet game?
Thanks,
Dan