Search Unity

diffuse curve world shader

Discussion in 'Shaders' started by Georgeh200, Oct 1, 2014.

  1. Georgeh200

    Georgeh200

    Joined:
    Apr 17, 2014
    Posts:
    1
    Code (CSharp):
    1. Shader "Custom/CurvedWorld"
    2. {
    3. Properties {
    4.     _MainTex ("Base (RGB)", 2D) = "white" {}
    5. }
    6. SubShader {
    7.     Tags { "RenderType"="Opaque" }
    8.     LOD 150
    9.  
    10. CGPROGRAM
    11. #pragma surface surf Lambert noforwardadd  vertex:vert
    12.  
    13. sampler2D _MainTex;
    14.  
    15. struct Input {
    16.     float2 uv_MainTex;
    17. };
    18.  
    19. void surf (Input IN, inout SurfaceOutput o) {
    20.     fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
    21.     o.Albedo = c.rgb;
    22.     o.Alpha = c.a;
    23. }
    24.  
    25. void vert( inout appdata_full v)
    26.         {
    27.         float4 _QOffset= float4(-5,-5,0,0);
    28.         float _Dist=100.0;
    29.         vv.xyz -= _WorldSpaceCameraPos.xyz;
    30.           float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
    31.                 float zOff = vPos.z/_Dist;
    32.             vPos += _QOffset*zOff*zOff;
    33.             v.vertex = mul (vPos, UNITY_MATRIX_IT_MV);
    34.             v.texcoord = mul( UNITY_MATRIX_TEXTURE0, v.texcoord );    
    35.         }
    36. ENDCG
    37. }
    38.  
    39.  
    40. }
    Hi all
    I try to make a my objects to appear curved like Subway game, so I use this shader, it's working Editor, but doesn't produce any thing on Android device