Simplest fastest possible particle shader on ios.

I am trying to make a particle shader for use on iOS that is as simple and fast as absolutely possible. Everything disabled that can be. All it needs is to display the color of the particle set by the Particle.Color field.

I’ve put this together:

Shader "Mobile/Particles/Flat" 
{

Properties 
{
	_Color ("Main Color, Alpha", Color) = (1,1,1,1)
}
	
Category {	
	Tags { "Queue"="Geometry" "IgnoreProjector"="True" "LightMode"="Always" }
	Lighting OFF
	ZWrite OFF
	Cull OFF
	
	BindChannels {
		Bind "Color", color
	}	

	SubShader 
	{
		Pass 
		{
			SetTexture [_Color] {
				constantColor [_Color]
				combine primary * constant
			}
		}
	}
	
}
}

This is working fine, but are there any flags, or tags, or anything in it to do differently that would make it faster on iOS devices?

That’s actually still slow :slight_smile: see my sig for the speed king of shaders. I use them myself in my game. You need cg, not fixed function shaders.

yes CG is defiantly the way to go.

Cg doesn’t run on iOS. If you write in Cg, you’re at the mercy of the GLSL converter, but in my experience, it’s going to either be a perfect translation, or close enough that it still beats letting Apple’s drivers convert from fixed function for you.

In my experience, OGLES 1.1 is still fastest if it has the features you need. Apple’s drivers are extremely fast at emulating fixed function, to the point where I have been unable to match performance using GLSL shaders. To be clear:

  • If the player is set to OGLES 1.1, then the device drivers (assuming it’s 3GS or newer) will do very efficient emulation of fixed function.
  • If the player is set to OGLES 2.0, then Unity converts your fixed function shaders to GLSL, and does a relatively poor job of it.

I would expect the above shader to be the fastest you can get if you set the player to OGLES 1.1 on iOS, assuming of course that you want both the vertex and tint colours in there. If you need OGLES 2.0 for whatever reason, then straight GLSL is currently the way to go.

In our tests, providing no pixel lights were used, cg offered the best speed over the largest amount of different devices including android, making cg still the best case that fits all. In niche cases we found that pushing 1.1 was faster, but it varied even on apple devices. And I’m not sure unity 4.x supports that anyway so it becomes a moot point going forward.

Cg doesn’t run on Android either. I just put the GLSL subshaders before the Cg when Cg is necessary.