Is it possible to set the vertex shader without overriding the fragment shader? I'd like to make vertices of an object randomly move around a little. To do this, I created a vertex shader.

I assigned the vertex shader to the object's material with shader.setSource() like so:

import bge

cont = bge.logic.getCurrentController()

VertexShader = """

uniform float time;

void main() {
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex + sin(time + gl_Vertex.z);
}

"""

# dummy fragment shader
FragmentShader = """

void main() {
    gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
}

"""


mesh = cont.owner.meshes[0]
for mat in mesh.materials:
    if mesh.getMaterialName(mat.getMaterialIndex()) == "MAleaves":
        shader = mat.getShader()
        if shader != None:
            if not shader.isValid():
                shader.setSource(VertexShader, FragmentShader, 1)
            shader.setUniform1f('time', bge.logic.getRealTime())


However I'd prefer to use the blender material shading instead of the fragment shader. How can I do this?
While I was digging through the docs one day, I stumbled upon the gpu.export_shader(scene, material) function, which seems to allow exporting the shader code of blenders internal materials. Note that this call eats non BGE types. Here is an example which extracts the code for a simple material on a lovely blue cube (*.blend below)




It should be possible to combine this extracted fragment shader with your own vertex shader (e.g. copy from console and paste in your BGE script).