Image texture with alpha possible?
in
Programming Questions
•
2 years ago
this should be possible shouldn't it:
take a PImage, load pixels, make an array for masking, apply masking, set as texture.
when i do this the image is completely transparent or at least the middle.
- for (int i = 0; i < imageLength; i++)
{
if(imageArray != null)
{
PImage wrkImage = imageArray[i];
wrkImage.loadPixels();
int[] masking = new int[wrkImage.pixels.length];
for(int p = 0; p < wrkImage.pixels.length; p++)
{
masking[p] = 198;
}
wrkImage.mask(masking);
wrkImage.updatePixels();
beginShape();
textureMode(NORMALIZED);
texture(wrkImage);
vertex(-(imgWidth/2), -(imgHeight/2), 0, 0, 0);
vertex(imgWidth/2, -(imgHeight/2), 0, imgWidth, 0);
vertex(imgWidth/2, imgHeight/2, 0, imgWidth, imgHeight);
vertex(-(imgWidth/2), imgHeight/2, 0, 0, imgHeight);
endShape();
} - translate(0,0,25);
}
Am I doing something wrong?
tried textureMode(NORMALIZED); & textureMode(IMAGE);
Should the masking[p] = 198; be some other format? hex?
Thanx, Im so close yet so far away ;)
1