- Home /
iOS shader with no texture, just vertex colouring and main colour
Hi, I'm using a vertex coloured sky plane model from Blender to create a sky gradient.
I've painted near black at the bottom vertices and near white at the top, and I am controlling the sky colour itself via Playmaker/script.
So I require a mobile shader which can read the vertex colours from my Blender mesh, and it also needs a colour. The only shader I can seem to find that does this is a shader called "Simple Texture" (still has a texture slot), and I'm not sure how fast/slow this is.
It does look extremely simple:
 Shader "Simple Texture" {
    Properties {
       _Color ("Main Color", Color) = (1, 1, 1, 1)
       _MainTex ("Base (RGB)", 2D) = "white"
    }
    SubShader {
       Pass {
          SetTexture [_MainTex] {
             constantColor [_Color]
             Combine texture * constant
          }
       }
    }
 }
Since it fills the whole screen a lot of the time, I'd like to be sure! I have absolutely no idea with shaders I'm afraid! Does iOS play nice without a texture being used, and if that slot is unused, does it affect performance at all?
If you could confirm for me that this is a suitable shader, or know of something better, I'd love to hear it.
Thanks, Jay
Answer by ScroodgeM · Jul 23, 2012 at 01:14 PM
this shader as simple as possible. uses only vertex color and main color.
Shader "Unity Answers/Mobile with Vertex Color"
{
    Properties
    {
        _Color ("Main Color", Color) = (1, 1, 1, 1)
    }
    SubShader
    {
        Tags { "Queue"="Background" "RenderType"="Background" }
        Cull Off
        ZWrite Off
        Fog { Mode Off }
    Pass
    {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        fixed4 _Color;
        struct appdata
        {
            float4 vertex : POSITION;
            float4 color : COLOR;
        };
        struct v2f
        {
            float4 pos : SV_POSITION;
            fixed4 color : COLOR;
        };
        v2f vert (appdata v)
        {
            v2f o;
            o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
            o.color = v.color;
            return o;
        }
        half4 frag(v2f i) : COLOR
        {
            return i.color * _Color;
        }
        ENDCG
        }
    }
} 
              Your answer
 
 
             Follow this Question
Related Questions
Vertex colour transparency and Beast lightmapping? 3 Answers
How to add Vertex color to Emission color on this shader? 1 Answer
How much information can you store in vertex color? 2 Answers
Shader Vertex Data Format 2 Answers
Snow scene is a neon blue in an iOS build, but looks normal on the computer 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                