Using Point lights in Unity3D Android -


i trying use point light animation game. runs fine in editor diffuse, bumped specular , vertexlit shaders. doesn't work on mobile shaders provided default.

is there way use point lights in android? or there shader can work on mobiles , supports point lights too?

finally found answer - this post on unityanswer helped me. reposting custom shader here -

// specular, normal maps main texture // fragment based shader "spectest/spectest5"  {     properties      {         _shininess ("shininess", range (0, 1.5)) = 0.078125         _color ("main color", color) = (1,1,1,1)         _speccolor ("specular color", color) = (0, 0, 0, 0)         _maintex ("texture", 2d) = "white" {}         _bumpmap ("bump map", 2d) = "bump" {}         _normalstrength ("normal strength", range (0, 1.5)) = 1     } // eo properties     subshader      {         // pass 4 vertex lights, ambient light & first pixel light         tags { "rendertype"="opaque" }         lod 200          cgprogram         #pragma surface surf mobileblinnphong          fixed4 lightingmobileblinnphong (surfaceoutput s, fixed3 lightdir, fixed3 halfdir, fixed atten)         {             fixed diff = saturate(dot (s.normal, lightdir));             fixed nh = saturate(dot (s.normal, halfdir)); //instead of injecting normalized light+view, inject view, provided halfasview in initial surface shader cg parameters              fixed spec = pow (nh, s.specular*128) * s.gloss;              fixed4 c;             c.rgb = (s.albedo * _lightcolor0.rgb * diff + _speccolor.rgb * spec) * (atten*2);             c.a = 0.0;             return c;         }          struct input {             float2 uv_maintex;             float2 uv_bumpmap;         };          // user-specified properties         uniform sampler2d _maintex;         uniform sampler2d _bumpmap;         uniform float _shininess;         uniform float _normalstrength;         uniform fixed4 _color;                float3 expand(float3 v) { return (v - 0.5) * 2; } // eo expand           void surf (input in, inout surfaceoutput o) {             half4 tex = tex2d (_maintex, in.uv_maintex) * _color;                o.albedo = tex.rgb;                o.gloss = tex.a;                o.alpha = tex.a;                o.specular = _shininess;              // fetch , expand range-compressed normal             float3 normaltex = unpacknormal (tex2d (_bumpmap, in.uv_bumpmap));             float3 normal = normaltex * _normalstrength;             o.normal = normal;         } // eo surf          endcg     }          //fallback "specular"   } // eo shader 

remember increase strength though. , it's costly on frame rate. need animation, used it.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -