How optimized is this shader for mobile?

Hey guys,

I’ve been using this shader that I pieced together and messed around with, but I never thought of how optimized it was for mobile platforms and I am trying to get some more frame rates into my app. So could anyone take a look and let me know if it needs optimization…

Shader "My Shaders/AlphaSelfIllumTrans" {
    Properties {
        _Color ("Color Tint", Color) = (1,1,1,1)
        _MainTex ("SelfIllum Color (RGB) Alpha (A)", 2D) = "white"
    }
Category {
	Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
	
	//Cull Back
	Alphatest Greater 0
	Blend SrcAlpha OneMinusSrcAlpha
	//Tags {Queue=Transparent}
	SubShader {
	    Material {
	       Emission [_Color]
	    }
	    Pass {
		    Lighting On
			ZWrite On
			Cull Back
	       	SetTexture [_MainTex] {
	              Combine Texture * Primary, Texture * Primary
	        }
	        SetTexture [_MainTex] {
	            constantColor [_Color]
	            Combine previous * constant , previous * constant
        	}  
	    }
	}
}
}

I’m not sure what you mean by “Mobile”. I can tell you about iOS, though. Alpha testing on PowerVR chips does not bring a speed benefit in transparent shaders; it’s the opposite. So UT disables “Alphatest Greater 0” on iOS. Aside from that, you’ve got some redundant or unnecessary code. You can make it faster by fixing that, writing a GLSL or Cg version for OpenGL ES 2.0, and if you can, get rid of the tint.

Category {
	Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
	Blend SrcAlpha OneMinusSrcAlpha

	SubShader {Pass {
		GLSLPROGRAM
		varying lowp vec2 uv;
		
		#ifdef VERTEX
		void main() {
			gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
			uv = gl_MultiTexCoord0.xy;
		}
		#endif
		
		#ifdef FRAGMENT
		uniform lowp sampler2D _MainTex;
		uniform lowp vec4 _Color;
		void main() {
			gl_FragColor = texture2D(_MainTex, uv) * _Color;
		}
		#endif		
		ENDGLSL
	}}
	
	SubShader {Pass {
		SetTexture[_MainTex] {Combine texture * constant ConstantColor[_Color]}
	}}
}

Hey Jesse,

Mobile as in iOS and Android…Unity puts it’s mobile friendly Shaders in the “Mobile” category so that’s why I used mobile in description…

Anyways, I know I have bad code since I’m still relatively new to coding, thanks for this I will give it a try. I hope you understand what I was going for with this shader. I wanted selfilluminaton with alpha transparency…

Hey Jessy, I am back testing this code you gave me. But why am I getting a parsing error?

EDIT: NVM, the code needed another } bracket.