- Home /
Shader no work on Android(some device)
I use simple shader from docs unity:
 Shader "Example/Diffuse Texture" {
 Properties {
   _MainTex ("Texture", 2D) = "white" {}
 }
 SubShader {
   Tags { "RenderType" = "Opaque" }
   CGPROGRAM
   #pragma surface surf SimpleLambert
   half4 LightingSimpleLambert (SurfaceOutput s, half3 lightDir, half atten) {
       half NdotL = dot (s.Normal, lightDir);
       half4 c;
       c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * atten * 2);
       c.a = s.Alpha;
       return c;
   }
   struct Input {
       float2 uv_MainTex;
   };
   sampler2D _MainTex;
   void surf (Input IN, inout SurfaceOutput o) {
       o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
   }
   ENDCG
  }
  Fallback "Diffuse"
  }
It's work fine on my computer and device HTC(Android 2.2), but when I use Sony Xperia(Android 4.2.2), I see black object. Prompt please as to correct it(black object). Thanks in advance for the help.
Are you using the $$anonymous$$obile shaders? can you post a screenshot?
@Fornoreason1000 - I don't understand your comment about mobile shaders.... the OP is using this shader - that's the whole point of the question!
@zharik86 - I can't see anything wrong with your code. Are you using deferred or forward lighting model? What _$$anonymous$$ainTex texture are you assigning to the material (make sure it's not too big for mobile to support,
@tanoshimi I use point light and default lighting model in my project(texture <1024 and not shadows). And I found solution my problem. Add o.Alpha = c.a in surf function. That' fine working on both device now. But, Sony experia working wrong with alpha chanel. Device output squares it(alpha=0.2, but output screen on device Sony alpha=0.2*0.2=0.04). Somebody knows as it to correct. Prompt please.
Answer by zharik86 · Dec 17, 2013 at 08:19 AM
I found solution. Add in surf function
  o.Alpha=c.a;
It's work fine on both device. Also it is necessary to change in settings of the unity project 32 z-buffer for 24 z-buffer. Then everything works normally at all devices.
Your answer
 
 
             Follow this Question
Related Questions
WARNING: Shader Unsupported: 'Hidden/Internal-GUITexture' - Setting to default shader. 0 Answers
Black texture on Android (shader) 0 Answers
GL.Color() has no effect on android 1 Answer
Radial Blur for Android/iOS 0 Answers
UI leads to game crash 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                