opengl-esshaderglslesopengl-es-3.0

Is it possible to use a vertex shader as a compute shader?


I would like to use a compute shader before my vertex shader stage, but I'm using OpenGL es 3.0, and compute shaders are only available in 3.1. My idea would be to use a vertex shader as a compute shader by feeding varyings as data.

I know that I could use a vertex shader and retreive its output with transform feedback, but I've heard that it's slow and it would defeat the advantage of the highly parallelized compute shader.

So is it possible to feed the result of the vertex shader into another vertex shader?

If not, is there a way to use a vertex shader as a compute shader?


Solution

  • Using transform feedback, coupled with rasterizer discard to skip fragment shading, should work fine.

    It was quite a common technique in mobile renderers to implement skinned mesh animation (animate once into a transform feedback buffer, use the output of that multiple times as an input into vertex shaders e.g. shadow pass and 3D pass).

    Like anything, it's not always the best solution, but that's very context sensitive.