How to get image dimensions in a GLSL node?

In the context of the Image Filter Plugin example, is there a varying variable or attribute …or something else in the Vuo SDK that can be used to retrieve the image dimensions of the input image?

Can you show a simple example of getting the image dimension resolution, and using it in a shader?

I know there is already the built in node for getting the image dimensions, and that can be passed to the shader manually, and that works for me. I’m just speculating that if it’s a built in value I can access, that two ports can be shaved off some nodes.


You can define a uniform and populate it with data from the VuoImage. Check out the documentation on the VuoImage type.

So, in nodeInstanceEvent, you could do something like this:

    VuoShader_setUniform_VuoReal((*instance)->shader, "pixelsWide", image->pixelsWide);
    VuoShader_setUniform_VuoReal((*instance)->shader, "pixelsHigh", image->pixelsHigh);

Then, in your GLSL shader code, add:

    uniform float pixelsWide;
    uniform float pixelsHigh;

Cool, I should have tried that… I suspected something like that would work because of the way the output image was happening.