Invert Y axis within GLSL code?

T. Mulard's icon

While trying to import and tweak a shader in order to manipulate it through the patcher and variables controlled by specific keys, I came across a problem : the flame origin and direction is determined by gl_FragCoord, but I couldn't find a way nor a function within the code to invert the Y axis in order to reverse the display of the shader, much like the @rotate 180. 0. 0. would do in the patcher.

Is it even possible to do so?

Here's the patcher for reference (Shadertoy link in the shader jxs file):

add.js
application/x-javascript 0.19 KB

fireShader.jxs
jxs 13.58 KB

fireShader.maxpat
Max Patch

sub.js
application/x-javascript 0.19 KB

Regards,

Theo

Rob Ramirez's icon

easiest may be to invert the ypart variable, e.g.
float ypart = 1. - (gl_FragCoord.y/resolution.y);

and any other place that uses that calculation.

T. Mulard's icon

Thanks, that does it for the smoke only but it gives me new ideas to approach it.

I'll keep in touch for updates.

T. Mulard's icon

Yes! finally, it works!

Had to change a variable and add a couple of if statements but in the end it just works.

As usual, here's the end result, and thanks for the help again.

Regards,

Theo

fireShader.maxpat
Max Patch

fireShader.jxs
jxs 13.99 KB