Search Unity

Can not get Point Light position on Mobile, only work in Editor Mode.

Discussion in 'Shaders' started by resetme, Dec 26, 2019.

  1. resetme

    resetme

    Joined:
    Jun 27, 2012
    Posts:
    204
    I have a simple shader that get the Point Light position information, I'm not using it for real unity lighting, im just taking the Point Light world position and doing some calculations.

    It works well inside Editor but not on Android/ Ios. For working on mobile I need to send the position using c#. (not the idea).

    Pseudo Code.

    Code (CSharp):
    1.  
    2. Pass
    3. Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase" }
    4.        
    5. CGPROGRAM
    6. #pragma vertex vert
    7. #pragma fragment frag
    8. #pragma multi_compile_fwdbase
    9.            
    10.  #include "UnityCG.cginc"
    11.  #include "AutoLight.cginc"
    12.  
    13. //FRAGMENT
    14. half3 point1 = half3(unity_4LightPosX0[0],unity_4LightPosY0[0]/2,unity_4LightPosZ0[0]);
    15.  
    Why I can't get the unity_4LightPosX0[0] directly from the shader on mobile?
     
  2. resetme

    resetme

    Joined:
    Jun 27, 2012
    Posts:
    204
    kinda fixed.

    commented this 2 lines
    //#pragma multi_compile_fwdbase
    //#include "AutoLight.cginc"

    now I have the point light coord in shaders, working on editor and mobile, I also have pixel count to 0 on preferences.

    Gonna keep working on my fake light system for mobile.