Hey All,
It’s the first time I’m porting over a glsl shader from Processing OSX to run on Processing Pi running on a Raspberry Pi 3 B+. I have a very basic shader that dissolves between two videos playing. It runs totally fine on my mac but when it’s ported to Processing Pi and updated to use the Processing video library GLvideo instead it is throwing an error.
The shader was converted from a ShaderToy post so maybe there’s some compatibility issues? I looked around and wasn’t able to find anything specific that I think would cause this problem. So any references, pointers or help would be greatly appreciated.
The error that I am getting is below:
Cannot link shader program:
ERROR:LEX/PARSE-2 (fragment shader, line 27) Undefined identifier
I’ve added a more verbose error output, apologies that it’s a screenshot… Processing Pi wasn’t allowing me to copy the full error message.
I’ve pased the code sample below but I’ve also linked to a Dropbox folder w/ the source example that I’m working on. It’s: https://www.dropbox.com/sh/z1spn3bv1jkq233/AABsQGFLsM-cdeBeyrMi47KOa?dl=0
_
shaderDisolve_4.pde
import gohai.glvideo.*;
PShader secondShader;
PGraphics pg;
PGraphics pg2;
GLMovie movie;
GLMovie movie2;
void setup() {
size(600, 600, P2D);
noSmooth();
pg = createGraphics(600, 600, P2D);
movie = new GLMovie(this, "Timelapse_HD_Sunrise_Sunset_France_1080p.mp4");
movie.loop();
movie2 = new GLMovie(this, "y2mate.com-10MinuteRealtimeBurningFireplaceinFullHD1080p_mFcSPt0sEuk_360p.mp4");
movie2.loop();
pg = createGraphics(width, height, P2D);
pg2 = createGraphics(width, height, P2D);
secondShader = loadShader("secondShader.glsl");
secondShader.set("iResolution", float(width), float(height));
secondShader.set("iTime", millis()/1000.);
}
void movieEvent(GLMovie m) {
m.read();
redraw();
}
void draw() {
pg.beginDraw();
pg.image(movie, 0, 0, width, height);
pg.endDraw();
pg2.beginDraw();
pg2.image(movie2, 0, 0, width, height);
pg2.endDraw();
secondShader.set("iTime", millis()/1000.);
secondShader.set("iChannel0", pg);
secondShader.set("iChannel1", pg2);
shader(secondShader);
rect(0, 0, width, height);
}
_
secondShader.glsl
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
// Type of shader expected by Processing
#define PROCESSING_COLOR_SHADER
uniform float iTime;
uniform sampler2D iChannel0;
uniform sampler2D iChannel1;
uniform vec2 iResolution;
void mainImage( out vec4 fragColor, in vec2 fragCoord );
void main() {
mainImage(gl_FragColor,gl_FragCoord.xy);
}
#define TEXTURED 1
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 q = fragCoord.xy/iResolution.xy;
// https://www.shadertoy.com/view/4s3XRf
vec2 uv = fragCoord.xy / iResolution.xy;
vec4 color0 = texture(iChannel0, uv);
vec4 color1 = texture(iChannel1, uv);
float duration = 10.0;
float t = mod(float(iTime), duration) / duration;
fragColor = mix(color0, color1, t);
}
On a more general note, is there a difference between .glsl written for a mac vs. Linux machine?
I appreciate the help,
Cheers,