Ok so I have answered my own question, this ‘black’ is part of the texture. I put together a glsl contrast shader to be able to brighten the texture and you can see more than black - not clear on why most of it is black but perhaps that’s to do with the uv mapping.
I think I found a solution now to be able to drop out the ‘black’ for transparent. It’s not as precise as I wanted as it removes parts of the image as well but it works for me.
Below is solution sketch, shader and texture image.
Sketch
import com.jogamp.opengl.*;
com.jogamp.opengl.GL3 gl;
PImage currentphoto;
PShader contrast_shader;
void setup()
{
size(1000, 800, OPENGL);
background(255, 0, 0);
currentphoto = loadImage("mars1.jpg");
contrast_shader = loadShader("contrast.glsl");
gl = GLContext.getCurrentGL().getGL3();
noStroke();
textureMode(NORMAL);
}
void draw()
{
background(255, 0, 0);
gl.glEnable(GL3.GL_BLEND);
gl.glDisable(GL3.GL_DEPTH_TEST);
gl.glBlendFunc(GL3.GL_SRC_ALPHA, GL3.GL_ONE_MINUS_SRC_ALPHA);
resetShader();
contrast_shader.set("contrast", 0.5);
shader(contrast_shader);
fill(255, 0, 0);
beginShape(TRIANGLE_FAN);
texture(currentphoto);
vertex(200, 100, -1, -1);
vertex(480, 700, 1, 0);
vertex(200, 500, 1, 1);
vertex(200, 100, 0, 1);
endShape();
}
GLSL shader called contrast.glsl
#ifdef GL_ES
precision mediump float;
#endif
#define PROCESSING_TEXTURE_SHADER
varying vec4 vertTexCoord;
uniform sampler2D texture;
uniform float contrast;
void main()
{
vec4 textureColor = texture(texture, vertTexCoord.xy).rgba;
highp float contrastScaled = 4.0 * contrast;
if (textureColor.r < 0.2 && textureColor.g < 0.2 && textureColor.b < 0.2)
{
discard;
}
gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * contrastScaled + vec3(0.5)), (textureColor.r+textureColor.g+textureColor.b)/3.0 * 3.1 - 0.1);
}