Mixing "normal" ShaderLab shaders with CG shaders in iPhone

Can I mix “normal” shaders with CG shaders on Iphone OpenGL ES 2.0?

If so, how can Unity do that? If I recall correctly, OpenGL ES 2.0 does not support fixed function pipeline at all.

Does it mean that Unity will compile “normal” ShaderLab shaders into cg/glsl if I target OpenGL ES 2.0 on Iphone/Android?

Correct, unity will compile shaderlab declarations to programmable pipeline shaders.
But you should potentially avoid doing that cause you lose control and optimization potential and significantly restrict the flexibility. (the resulting shader code at the end is always GLSL on OES, there is no cg / HLSL support)

So do you recommend me to write shaders directly in GLSL? What about CG? Doesn’t Unity compile it to GLSL? I thought they had already optimized the HLSL->GLSL converter.

Thx for the help!

CG is compiled to GLSL too.
What I wanted to tell above is that independent what you do, all ends on GLSL, so GLSL, CG and shaderlab declarations where they are related to the rendering and not state setups

And what about ShaderLab declarations related to state setups (fixed function pipeline)? They wont work with Unity iPhone?

Fixed function shaders work in OpenGL ES 2.0 (both on iOS and Android), and there are no performance drawbacks in doing that. We generate actual shaders behind the scenes, and we do generate optimal code for them. So, dreamora: there are really no drawbacks in using fixed function shaders on GLES2.0.

Cg shaders get cross-compiled to GLSL for OpenGL ES 2.0. In the current Unity version (3.1) we don’t do a very good job at optimizing shader precision, but it will be greatly improved in Unity 3.2 very soon. That is, with Unity 3.2 generally we get exactly the same shader efficiency if we write in Cg (cross-compiled to GLSL by Unity) or write in GLSL directly.