Search code examples
opengl-es-2.0shaderpixel-shaderfragment-shadervertex-shader

Use one vertex/fragment shader in multiple programs


In OpenGL ES 2.0, is it possible to use a compiled vertex/fragment shader in multiple linked programs?

For example, let's say I have 1 compiled vertex shader and 5 compiled fragment shaders. Can I create 5 different programs(vsh1+fsh1, vsh1+fsh2, etc)?

As far as my knowledge goes, this should be possible but it never hurts to ask.

Thanks


Solution

  • Yes, you can, but as I understand it you will still have to set all the uniforms separately. I think this is why the separable programs were born but you don't have access to them in Es 2.0 (it's a OpenGL 4.0 feature) so I think this is the only way.

    Some discussion about it here.