Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Mixing shaders?

edited January 2014 in Shaders Posts: 4

Is it possible to mix multiple shaders in one mesh? I got a black/white map I generate each frame and draw it using a alpha filter, but is it possible to add an blir filter to it after the alpha?


  • IgnatzIgnatz Mod
    Posts: 5,396

    @Multinfs - if you draw the image to memory first (with setContext), you can use it as the texture for a second image with a second shader. There is a performance hit, though.

  • Posts: 505

    As @Ignatz says, unless you write your own handling of compositing of shaders.

    blackwhite = [[ vec4 blackwhite(vec4 input) { ... } ]]
    alpha = [[ vec4 alpha(vec4 input) { ... } ]]
    blur = [[ vec4 blur(vec4 input) { ... } ]]
    s = shader([[ vertexshader ]], blackwhite .. alpha .. blur .. [[
    void main() {
        gl_FragColor = blur(alpha(blackwhite(vColor)));
  • edited January 2014 Posts: 4

    @Ignatz That seems to remove the alpha effect from the first shader, I'm not sure this is thr right way though.

    Setcontext image1,
    Draw black background,
    Fill to white,
    Draw the shape with the first shader,
    Setcontext to screen,
    Draw image1 with the second shader,

  • IgnatzIgnatz Mod
    Posts: 5,396

    @Multinfs - why would it remove the alpha effect?

    Your sequence seems OK to me.

Sign In or Register to comment.