Attempting to make ofxPostProcessing on Raspbian


#1

Hi there,

I built OF v.0.10 Release Candidate 4 on my Raspberry Pi 3 B+ (Running Raspbian Stretch) and I’m trying to make a project that works on my Mac that uses the ofxPostProcessing addon.

I feel like I might have not setup something properly because a lot of the core OF headers are not being seen:

/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp: In member function ‘itg::LUTPass* itg::LUTPass::loadLUT(std::__cxx11::string)’:
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp:60:37: error: ‘ofToDataPath’ was not declared in this scope
             path = ofToDataPath(path);
                                     ^
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp:98:19: warning: comparison betweensigned and unsigned integer expressions [-Wsign-compare]
    if (lut.size() != (LUT_3D_SIZE * LUT_3D_SIZE * LUT_3D_SIZE)) ofLogError() << "LUT size is incorrect.";
        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp:98:76: error: ‘ofLogError’ was notdeclared in this scope
    if (lut.size() != (LUT_3D_SIZE * LUT_3D_SIZE * LUT_3D_SIZE)) ofLogError() << "LUT size is incorrect.";
                                                                            ^
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp:105:22: error: ‘GL_TEXTURE_3D’ wasnot declared in this scope
             glEnable(GL_TEXTURE_3D);
                      ^~~~~~~~~~~~~
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp:113:63: error: ‘GL_CLAMP’ was not declared in this scope
             glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
                                                               ^~~~~~~~
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp:115:44: error: ‘GL_TEXTURE_WRAP_R’was not declared in this scope
             glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
                                            ^~~~~~~~~~~~~~~~~
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp:119:119: error: ‘glTexImage3D’ wasnot declared in this scope
 ge3D(GL_TEXTURE_3D, 0, GL_RGB, LUT_3D_SIZE, LUT_3D_SIZE, LUT_3D_SIZE, 0, GL_RGB, GL_FLOAT, &lut[0]);
                                                                                                   ^
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp: In member function ‘void itg::LUTPass::dispose()’:
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp:152:23: warning: converting to non-pointer type ‘GLuint {aka unsigned int}’ from NULL [-Wconversion-null]
             lut_tex = NULL;
                       ^~~~
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp: In member function ‘virtual void itg::LUTPass::render(ofFbo&, ofFbo&)’:
/home/pi/openFrameworks/addons/ofxPostProcessing/src/LUTPass.cpp:165:45: error: ‘GL_TEXTURE_3D’ wasnot declared in this scope
         shader.setUniformTexture("lut_tex", GL_TEXTURE_3D, lut_tex, 1);
                                             ^~~~~~~~~~~~~
/home/pi/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:358: recipe for target '/home/pi/openFrameworks/addons/obj/linuxarmv6l/Release/ofxPostProcessing/src/LUTPass.o' failed
make[1]: *** [/home/pi/openFrameworks/addons/obj/linuxarmv6l/Release/ofxPostProcessing/src/LUTPass.o] Error 1
make[1]: Leaving directory '/home/pi/openFrameworks/apps/myApps/interpretat_io'
/home/pi/openFrameworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:124: recipe for target 'Release' failed
make: *** [Release] Error 2

if I type

#include "ofLog.h"

In LUTPass.h to get rid of the message of it complaining about ofLogError() not being found, it still gives me the same error.

If anyone can point me in the right direction I would greatly appreciate it!

Thanks,

-Chris


#2

the raspberry pi run openGLES, that should not have those calls. Anyway, even using shaders it is really difficult to make post processing GLSL code (that make many dependent texture reads) work well on ARM processor.

I’m trying to make post-processing code that runs both on GL and GLES, but it’s still very alpha and probably it won’t have the kind of FX you were using:


#3

Ah, thanks for pointing that out. I was only using the Bloom and Kaleidoscope fx in ofxPostProcessing, so maybe I should be looking out for alternatives I know will for sure work on the Pi. I’ll check out your library soon — I see it has a “Mirror” effect, would it be easy to turn that into a kaleidoscope?


#4

nope, that mirror is really basic, it mirrors horizontally or vertically. Anyway a kaleidoscope effect is doable in openGLES, but the bloom would be very hard, given the limitations of the hardware.


#5

That’s fine, I can live without the bloom. Would you be able to point me in the direction to some source code or example projects that I can use to learn how to implement the kaleidoscope effect?

On another note, I have been having trouble getting GL projects to run in general unless I switch off the GL driver entirely. I’ve seen a few threads about it here, so I will investigate more; but I get this error (when running with the GL driver enabled with full KMS):

[ error ] ofAppEGLWindow: getScreenSize(): tried to get display size but failed
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): screenRect: 0x0
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): windowRect: 0x0
[ error ] ofAppEGLWindow: setupRPiNativeWindow(): dispman_element == DISPMANX_INVALID
[warning] ofAppEGLWindow: getNativeDisplay(): window not initialized, returning NULL
[warning] ofAppEGLWindow: getNativeDisplay(): window not initialized, returning NULL
[notice ] ofAppEGLWindow: createSurface(): setting up EGL Display
* failed to add service - already in use?

#6

if you are new to shaders i’d reccomend you:


(in my addon i also follow some of the conventions teached in the book)
If you are already into shaders just search for some kaleidoscope fx on shadertoy. I’d also like to try to implement a kaleidoscope fx for ofxDotFrag, but i’m busy at the moment.

for the rpi setup part, i’m using the method 1 written in this post (obviously i’m not using any desktop enviroment, i use the raspbian lite version):


#7

Thank you very much! This is extremely helpful! :smile:


#8

Hi there!

I’ve been reading the book of shaders (really cool) and playing around with your example project a bit in ofxDotFrag. Can you give me any tips on how I could modify the Mirror shader to reflect the image horizontally around the center of the screen?

I’ve tried making variations to this line as follows:

if( u_horizontal ) st.x = (st.x < 0.5) ? 0.5 - st.x : st.x;

However I can’t seem to find the right values that don’t either cause horizontal lines to appear the width of the screen or stretching the image in a strange way.


#9

i don’t know why the mirroring won’t work if you put that condition in the vertex shader, anyway you can write just the fragment shader like this and it will work:


    #ifdef GL_ES
    precision mediump float;
    #endif

    uniform vec2 u_resolution;
    uniform float u_time;
    uniform sampler2D u_tex0;

    uniform bool u_vertical;
    uniform bool u_horizontal;

    void main (void) {
        vec2 st = gl_FragCoord.xy/u_resolution.xy;
        
        if( u_horizontal ){
             st.x = (st.x < 0.5) ? 1.0 - st.x : st.x;
        }
        
        if( u_vertical ){
             st.y = (st.y < 0.5) ? 1.0 - st.y : st.y;
        }
        
        vec4 source = texture2D( u_tex0, st );

        gl_FragColor = source;
    }
    

i’ve just added this shader to the repo with the name MirrorAxis you can git pull and test it