Is there anything like ofxShadertoy or any block to quick load a .glsl or .frag shader into an object on MacOS? Something straightforward close to openframeworks where we can embed the file into an object. (i.e. ofShader).
Regarding the use of ShaderToy files: their format has changed since I last updated the sample. ShaderToy shaders now have a void mainImage( out vec4 fragColor, in vec2 fragCoord ) function, instead of a void main(void), so you can’t use the shaders directly. There’s also a bunch of uniforms you need to supply for the shaders to function.
At the very least, you need to provide some additional code in your fragment shader:
#version 330 core
uniform vec3 iResolution; // viewport resolution (in pixels)
uniform float iTime; // shader playback time (in seconds)
uniform float iTimeDelta; // render time (in seconds)
uniform int iFrame; // shader playback frame
uniform float iChannelTime[4]; // channel playback time (in seconds)
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube
uniform vec4 iDate; // (year, month, day, time in seconds)
uniform float iSampleRate; // sound sample rate (i.e., 44100)
out vec4 fragColor;
// ...paste the shadertoy code here...
void main(void)
{
mainImage( fragColor, gl_FragCoord );
}
If you’re unsure about how to load and use shaders, have a look at the SimpleShader sample.
You need to ping-pong between two textures using a gl::Fbo. That functionality is hidden from you in shadertoy but is implied by having multiple buffers. Search for fbo ping pong and you should find some examples.