I've made a post detailing this issue in the openFrameworks forum, but was directed here after we unable to resolve it there. To avoid redundancy, the full post is here, but I'll include the necessary details in this issue.
I have written a custom shader that combines frames of videos from pairs of ofVideoPlayers. It works as expected. However, since switching over to Hap files for this project, I have been unable to get the shader to work in the same way. The shader outputs a combination of the colors in the video textures when dealing with ofVideoPlayers, as detailed in the shader code below, but it outputs black for every pixel when dealing with textures from ofxHapPlayers. The video files are in standard Hap format (not Hap Q or Hap Q Alpha), so I believe that color conversion via the ofxHapPlayer's shader shouldn't be necessary.
I'm relatively new to programming in C++ and GLSL, so it's possible that I'm misunderstanding the way that GLSL uses textures or the way that pointers work, but I can't figure out what I'm doing wrong.
And here are two versions of the draw loop in my ofApp. The first is the draw loop I used when I was using ofVideoPlayer, the second is a slightly modified version to deal with the fact that ofxHapPlayer.getTexture() returns a pointer instead of a reference:
//if using ofVideoPlayers:
void ofApp::draw(){
shader.begin();
//pass textures to shader:
shader.setUniformTexture("tex0", video.getTexture(), 1);
shader.setUniformTexture("tex1", video2.getTexture(), 2);
//display a blank fbo onto which the shader will project
fbo.draw(0,0);
shader.end();
}
//if using ofxHapPlayers:
void ofApp::draw(){
//store pointers to the textures of the hap players:
ofTexture * hapTexture = hap.getTexture();
ofTexture * hap2Texture = hap2.getTexture();
shader.begin();
//pass textures into the shaders via use of dereferencing operator
shader.setUniformTexture("tex0", *hapTexture, 1);
shader.setUniformTexture("tex1", *hap2Texture, 2);
//display a blank fbo onto which the shader will project
fbo.draw(0,0);
shader.end();
}
EDIT: It's possible that the only solution to this is similar to that of #65, wherein you need to draw a video frame to an FBO and then subsequently access the texture of the FBO. I have tried this before and it does work, but I was warned that performance might quickly become a problem, so I am hoping that there is an alternative solution.
I've made a post detailing this issue in the openFrameworks forum, but was directed here after we unable to resolve it there. To avoid redundancy, the full post is here, but I'll include the necessary details in this issue.
I have written a custom shader that combines frames of videos from pairs of ofVideoPlayers. It works as expected. However, since switching over to Hap files for this project, I have been unable to get the shader to work in the same way. The shader outputs a combination of the colors in the video textures when dealing with ofVideoPlayers, as detailed in the shader code below, but it outputs black for every pixel when dealing with textures from ofxHapPlayers. The video files are in standard Hap format (not Hap Q or Hap Q Alpha), so I believe that color conversion via the ofxHapPlayer's shader shouldn't be necessary.
I'm relatively new to programming in C++ and GLSL, so it's possible that I'm misunderstanding the way that GLSL uses textures or the way that pointers work, but I can't figure out what I'm doing wrong.
Here is the fragment shader code:
And here are two versions of the draw loop in my ofApp. The first is the draw loop I used when I was using ofVideoPlayer, the second is a slightly modified version to deal with the fact that ofxHapPlayer.getTexture() returns a pointer instead of a reference:
EDIT: It's possible that the only solution to this is similar to that of #65, wherein you need to draw a video frame to an FBO and then subsequently access the texture of the FBO. I have tried this before and it does work, but I was warned that performance might quickly become a problem, so I am hoping that there is an alternative solution.