Search Unity

lerp textures iOS 6

Discussion in 'Shaders' started by robhuhn, Mar 20, 2013.

  1. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    Hi,

    I would like to lerp textures in a shader depending on the world position. My shader works so far in the editor and on iOS 5.1.1 but on iOS 6 the bottom texture (_SecondTex) is not visible.

    @edit the second texture is not 'not visible', it's just black.

    Code (csharp):
    1. Shader "Custom/TestShader" {
    2.     Properties {
    3.         _MainTex("Top", 2D) = "white" {}
    4.         _SecondTex("Bottom", 2D) = "white" {}
    5.     }
    6.     SubShader {
    7.         Tags { "RenderType"="Opaque" }
    8.         LOD 200
    9.        
    10.         CGPROGRAM
    11.         #pragma surface surf Lambert
    12.        
    13.         sampler2D _MainTex;
    14.         sampler2D _SecondTex;
    15.  
    16.         struct Input {
    17.             float2 uv_MainTex;
    18.             float2 uv_SecondTex;
    19.             float3 worldPos;
    20.         };
    21.  
    22.         void surf (Input IN, inout SurfaceOutput o) {
    23.        
    24.             float4 Tex2D0 = tex2D(_MainTex, IN.uv_MainTex);
    25.             float4 Tex2D1 = tex2D(_SecondTex, IN.uv_SecondTex);
    26.            
    27.             float4 Lerp0 = lerp(Tex2D1, Tex2D0, clamp(IN.worldPos.y * 10, 0, 1));
    28.        
    29.             o.Albedo = Lerp0.rgb;
    30.             o.Alpha = Lerp0.a;
    31.         }
    32.         ENDCG
    33.     }
    34.     FallBack "Diffuse"
    35. }
    Did I do something wrong or is there an issue on iOS6?

    I also tried to use ShaderLab but don't know how to get the world position then.
     
    Last edited: Mar 21, 2013
  2. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    I just figured out that this only happens when the player setting 'orientation' is set to landscape. When portrait mode is set, it also works on ios6.

    Bug report sent
     
    Last edited: Mar 21, 2013
  3. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    I would recommend, as you already started forum thread, to post case number along - this way if stuff catches attention of some dev (me in that case) he can check it right away without qa in the middle.
     
  4. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    Okay, it's case 533786
     
  5. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    hm, it works for me (though i'm using dev version sure - something like 4.2)
    i can see what you mean if i simply run your project, though it was build with 4.0. Did you try 4.1?
     
  6. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    You're right, it works with Unity 4.1. Thank you very much for your support!