I remember a while back reading somewhere that if your target output is iOS, it’s better that you write your shaders in GLSL. As GLSL will give you better performance and more functionality.
So I wrote some shaders in GLSL just because.
But I see that every advanced shader package outputs CG code. It made me wonder. Even if my target is only iOS, Android, OSX and Linux, and I could get away with OpenGL only if I ever needed to go on Windows. Is writing my shaders in CG a good idea or not?
CG without question. GLSL won’t even work at all on some platforms, and it’s not faster in the slightest. Old news is bad news. Just avoid surface shaders like the plague if you want speed.
GLSL is better. CG compiler sometimes generates code that is not optimal for iOS GPU, specifically code that uses dependent texture reads that are not necessary.
Write it in CG unless you’re absolutely sure it’s not optimising the GLSL translation as well as it should and you’re certain you really need the speed-up from implementing it yourself.
Seems like something you can only really judge if you know the hardware/drivers better than the compiler does. And if your tests show that the code runs slower than it should.
Yeah, pretty much. But I’ve noticed it can generate code with some variables that aren’t really needed sometimes… but honestly nothing I think would be noticeably detrimental to your framerate.