MartinusMagneson's picture

Magneson (@MartinusMagneson)


    MartinusMagneson's picture
    Magneson commented on George_Toledo's Discussion, “GLSL Image Generator

    Yes - to both the questions I think actually. If I have understood it correctly, a fragment shader always needs a vertex shader to display anything (at least in Vuo). My guess is that the vertex shader is just a very basic quad and some default uniforms that sets up a framework for less boilerplate coding.

    At the risk of confusing you further, if you look at the code for a custom GLSL image filter node in the Vuo source (that is the C source, has nothing to do with the shader editor), you can find the following line setting up the shader:

    VuoShader_addSource(instance->shader, VuoMesh_IndividualTriangles, NULL, NULL, fragmentShaderSource);

    Looking at VuoShader_addSource in the API, it lists the inputs to the function as follows:

    void VuoShader_addSource (  VuoShader   shader,
        const VuoMesh_ElementAssemblyMethod    inputPrimitiveMode,
        const char *     vertexShaderSource,
        const char *     geometryShaderSource,
        const char *     fragmentShaderSource 

    With this in mind, it can seem like there are no vertex shader for the fragment shader that does the filters, but in the notes of the function we can also read:

    GLSL vertex shader source code. If NULL, a default vertex shader is used (it passes texture coordinates through, and projects the vertex).

    Vuo Shader example:

    VuoShader_addSource in the API:

    MartinusMagneson's picture
    Magneson commented on George_Toledo's Discussion, “GLSL Image Generator

    Oh, I see it working by running it in the shader editor (like a composition). Time and resolution are supported without declaring any uniforms. If you use the Image filter protocol/editor there is also provided an image of a bird when you run it standalone.

    The code above is the only thing you need to input for a simple shader utilizing time, resolution and inputs. It will modulate the red channel by time, the green channel by the rendered window size, and the blue channel by a published port/slider.

    MartinusMagneson's picture
    Magneson commented on Magneson's Bug Report, “Input ports of shader disappear

    There is a workaround by using the variables in the code before publishing them. It seems that they are auto removed if unused.

    MartinusMagneson's picture
    Magneson posted a new Bug Report, “Input ports of shader disappear

    Input ports of shader disappear


    Vuo version: 

    OS version: 

    • macOS 11

    CPU architecture: 

    Intel x86_64

    How severely does this bug affect you?: 

    ●●●○ — It prevents me from completing a specific task with Vuo.

    Steps causing the bug to occur: 

    1. Create new image filter shader
    2. Add a float port
    3. Right click to add an additional port
    4. First port disappears

    Have you found a workaround?: 


    MartinusMagneson's picture
    Magneson commented on George_Toledo's Discussion, “GLSL Image Generator

    Ok, so it is pretty easy, a published port is automagically declared as a uniform when you add it. The resolution is RENDERSIZE.xy, and the time input is TIME (both capitalized).

    This will make a color based on time and render size along with a published Real port named blue:

    void main()
        float red = mod(TIME, 1.0);
        float green =  RENDERSIZE.y / RENDERSIZE.x;
        gl_FragColor = vec4(red,green,blue,1);