Search Unity

Custom Standart Surface Shader For Mobile

Discussion in 'Shaders' started by SoftwareEngineer, Oct 24, 2016.

  1. SoftwareEngineer

    SoftwareEngineer

    Joined:
    Jan 4, 2014
    Posts:
    52
    1. Shader "Custom/MobileColor" {
    2. Properties {
    3. _Color ("Color", Color) = (1,1,1,1)
    4. _Glossiness ("Smoothness", Range(0,1)) = 0.5
    5. _Metallic ("Metallic", Range(0,1)) = 0.0
    6. }
    7. SubShader {
    8. Tags { "RenderType"="Opaque" }
    9. LOD 200
    10. CGPROGRAM
    11. // Physically based Standard lighting model, and enable shadows on all light types
    12. #pragma surface surf Standard fullforwardshadows

    13. // Use shader model 3.0 target, to get nicer looking lighting
    14. #pragma target 3.0

    15. sampler2D _MainTex;

    16. struct Input {
    17. float2 uv_MainTex;
    18. };

    19. half _Glossiness;
    20. half _Metallic;
    21. fixed4 _Color;

    22. void surf (Input IN, inout SurfaceOutputStandard o) {
    23. // Albedo comes from a texture tinted by color
    24. fixed4 c = _Color;
    25. o.Albedo = c.rgb;
    26. // Metallic and smoothness come from slider variables
    27. o.Metallic = _Metallic;
    28. o.Smoothness = _Glossiness;
    29. }
    30. ENDCG
    31. }
    32. FallBack "Diffuse"
    33. }
    Hi guys. I just created a standart surface shader and I removed texture information from this. So there are only color info, smoothness and metalic in this shader. I wonder if this is suitable for mobile games or not. Also I do not understand why while even mobile shader consist of 7 thousand of codes but this newly created shaders consist of only 40-50 lines. This means these guys are lighter? Thank you for your answers.

    King regards.
     
  2. Namey5

    Namey5

    Joined:
    Jul 5, 2013
    Posts:
    188
    This is a surface shader. Surface shaders generate a 'normal' shader in man, many variants and as such are generally less optimised than say just writing a 1/2 pass shader manually. This is using the Unity 5 Standard shader as a basis, and as such has a vast quantity of things you may or may not want on mobile, like reflections, specularity, normal/height mapping, etc (although some of these features are not always used). It all depends on what device you are using and how the materials and objects are set up.
     
  3. SoftwareEngineer

    SoftwareEngineer

    Joined:
    Jan 4, 2014
    Posts:
    52
    I just want to put materials on my models not texures. That is why I removed texture slot from that. I hope with no textures this shader will not be heavy for mobile devices also this shader has no normal map slot. Only "Color", "Glossiness" and "Metalicness".