Massive Lag

After working with Unity for a while, I decided to start using Unity for my iPhone games. Once I bought it however, I noticed many of the features didn’t work half as well as on a computer.

For instance, running at 11.4k Tris and 22 drawcalls, It’s nearly impossible to navigate around due to the lag.

Next, I’ve noticed many shaders don’t work either

Shader "Terrain/AlphaBlended" {
	Properties {
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_DetailTex ("Detail (RGB)", 2D) = "white" {}
		_LowTex ("Low (RGB)", 2D) = "white" {}
		_BlendMap ("BlendMap (RGBA)", 2D) = "white" {}
		_LightMap ("LightMap (RGB)", 2D) = "white" {}
	}
	SubShader {
		Pass {
			Material {
				Diffuse (1,1,1,1)
				Ambient (1,1,1,1)
			}
			Lighting On
			BindChannels {
             	 Bind "vertex", vertex
           		 Bind "color", color
           		 Bind "texcoord", texcoord

        	}

			
			SetTexture [_BlendMap] {
				Combine texture
			}
			
			SetTexture [_DetailTex] {
				Combine texture * previous
			}
			


			SetTexture [_MainTex] {
				Combine previous lerp (previous) texture
			}
			
			SetTexture [_LightMap] {
				Combine previous * texture
			}
			
			
		}
	} 
	FallBack "Diffuse", 1
}

Next, when I add trees to the random terrain generator I coded, it lags to about 2 frames/second. Am I missing something, or did I just get ripped off?

well IOS is a whole another beast you can’t expect it will just run like on your PC out of the box , it won’t ,

you need to doc yourself on it and learn how to optimize your stuff regarding the platform you target ( with it constraint ) be it artwork side or code side.

there various level of opti in this regard.

shader wise o am not expert , but well in general idea , you need to optimize them for iOS or at least use what unity provide for mobile shader and do not rely on shader provided in PC or MAC stuff

You need to optimise all the shaders. You don’t actually need to worry much about draw calls but a quick guide what to avoid:

  • all terrain stuff
  • textures bigger than 512x512
  • shaders which aren’t in the mobile folder
  • alpha test (big no no)
  • overdraw / fill rate (lots of transparent stuff)
  • more than one light

You’ve got several things in that shader that are doing nothing but eating performance and/or being useless. You’re saying that you want vertex colors, but then you overwrite them with vertex lighting, and you never use the lighting anyway. _LowTex isn’t used anywhere.

What is in _BlendMap that necessitates a blend with _DetailTex? If nothing, then you can make this easy. Otherwise, you can at least save a multiply; the POWERVR hardware is scalar, not vector, so it does matter.

Chiefly, though, you need to know that you can’t use more than two texture combiners if you emulate/target the MBXLite.