Hello
This is the first version of the GLSLVideoEffects patch. It is made with the Ofelia library.
It creates an effect chain of three GLSL shaders.
The effects are mainly adaptions from existing shaders.
It started as a technical issue, but I think it is a patch on its own now...
I tried to make it easy to change or substitute GLSL effects or to expand the patch.
I have some further ideas, but this is the basic concept.
The interface makes also use of the new "coords" message for canvas positions, which works very well.
-
Ofelia GLSL Video Effects
-
Thx for the fast reply! Will try that when back at the computer and edit this reply.
EDIT: Jarrrr it works with the newest ofelia from deken!! very cool!!! Thank you! but most of the shaders are not working. No problem for me, as i was just testing. If I have time, i will look into this further. I use OSX 10.11.6.
Effects that work: Angle, Bokeh, FractTexture.
To make it work here it looks like i would have to tweek the shader code. Maybe there is some OS dependend stuff?
Console gives (e.g. for AsciiArt):ofShader: setupShaderFromSource(): GL_FRAGMENT_SHADER shader failed to compile
: ofShader: GL_FRAGMENT_SHADER shader reports:
ERROR: 0:1: '<' : syntax error: syntax error: ofShader: GL_FRAGMENT_SHADER, offending line 1 :
1 //fragment program
2
3 uniform sampler2D Tex0;ofShader: checkProgramLinkStatus(): program failed to link
ofShader: ofShader: program reports:
ERROR: One or more attached shaders not successfully compiled -
@Johnny-Mauser nice that it works. but strange that some effects do not work, i thought they are os independent.
but line one is just a comment (everything with // in the beginning). you can just delete it perhaps. -
I updated the patch for Ofelia v3: GLSL_Video_Effects_V01_Ofelia3.zip
@cuinjune somehow the patch only works with Ofelia 3 if I call the module variable M with a name different than M (in my case "m").
this works:local m = require("$0-video1");
and this does not work:
local M = require("$0-video1");
I do not understand the behaviour yet because in the variable example I can still use
local M = require("$0-abc");
without any problem...
Another relating question: Is ofelia and M still the same?
-
@Jona Yes,
M
is just an alias forofelia
module table.The actual full script that runs in Lua when you create [ofelia define foo] object is like the following:
local name = "foo" package.preload[name] = nil package.loaded[name] = nil package.preload[name] = function(this) local ofelia = {} local M = ofelia -- Your written script will be here. return M end
And sending the 'bang' message to this object will run the following script:
local m = require("foo") if type(m.bang) == "function" then return m:bang() -- the object will output the returned value through its outlet end
I added
M
since it's easier to write and the script can be shorter. Also,M
is commonly used in Lua as a variable name for a module table.Therefore, you should not reassign anything to
M
orofelia
in almost any case since it can be problematic. -
I adapted the partch to ofelia v4 here.
GLSL_Video_Effects_V01_Ofelia4.zip
But still, only very few shader works on my macbook (like Bokeh... and two or three more).
Any way to make them all compatible? -
@60hz hmm. For me even the v3 version works without problems (with Windows) with Ofelia v4. And I don't think shaders need to be programmed differently for OSX. But maybe I am wrong. Maybe you need to specify the GL version in Ofelia?
Btw: I updated ofxOfelia (inofficial): https://github.com/cuinjune/Ofelia/issues/78 -
or me even the v3 version works without problems (with Windows) with Ofelia v4
Ok, strange, I found an old revision of your patch somewhere that used pdCanvas and pdClock instead of ofCanvas ofClock, and ofelia object was broken...
Maybe you need to specify the GL version in Ofelia?
Yes, I thought about it. I tried to change different shader version adding window:setGLVersion(4,1) etc in setup but had a crash or nothing...
Maybe I need to modify all shader and add a version directive on top to make them working in other systems (like: #version 410).I updated ofxOfelia
Great, this is the openFrameworks addon, but I am trying to make classic ofelia work under pd for some teaching.
-
This is the error I have on 90% of the shader...
ofShader: setupShaderFromSource(): GL_FRAGMENT_SHADER shader failed to compile : ofShader: GL_FRAGMENT_SHADER shader reports: ERROR: 0:1: '<' : syntax error: syntax error : ofShader: GL_FRAGMENT_SHADER, offending line 1 : 1 //fragment program 2 3 uniform float Bleach_Opacity; ofShader: checkProgramLinkStatus(): program failed to link ofShader: ofShader: program reports: ERROR: One or more attached shaders not successfully compiled
-
@60hz maybe just try to delete what is written in the first line of the shader?
-
Yeah, I tried already but that's not the problem. And for example Bokeh works with the same line...
-
I tried on a Intel Imac, same problems with same shaders.
Now, I tried on a windows 10 machine... same problems again, only same 3 shaders works (like Bokeh)..For bleach, the error is different from apple:
ofShader: setupShaderFromSource(): GL_FRAGMENT_SHADER shader failed to compile : ofShader: GL_FRAGMENT_SHADER shader reports: Fragment shader failed to compile with the following errors: ERROR: error(#60) Unknown char: "" ERROR: error(#273) 1 compilation errors. No code generated : //fragment program uniform sampler2D Tex0; uniform float GaussianBlur_Radius; const float total = (1. + 8. + 28. + 56.) * 2. + 70.; void main(void) { vec2 st = gl_TexCoord[0].st; vec4 color = vec4(0.0,0.0,0.0,0.0); color += (1. / total) * texture2D(Tex0, st - GaussianBlur_Radius * vec2(4. / 4., 0.)); color += (8. / total) * texture2D(Tex0, st - GaussianBlur_Radius * vec2(3. / 4., 0.)); color += (28. / total) * texture2D(Tex0, st - GaussianBlur_Radius * vec2(2. / 4., 0.)); color += (56. / total) * texture2D(Tex0, st - GaussianBlur_Radius * vec2(1. / 4., 0.)); color += (70. / total) * texture2D(Tex0, st); color += (1. / total) * texture2D(Tex0, st + GaussianBlur_Radius * vec2(4. / 4., 0.)); color += (8. / total) * texture2D(Tex0, st + GaussianBlur_Radius * vec2(3. / 4., 0.)); color += (28. / total) * texture2D(Tex0, st + GaussianBlur_Radius * vec2(2. / 4., 0.)); color += (56. / total) * texture2D(Tex0, st + GaussianBlur_Radius * vec2(1. / 4.,ofShader: checkProgramLinkStatus(): program failed to link
ofShader: ofShader: program reports:
Fragment shader(s) were not successfully compiled before glLinkProgram() was called. Link failed.