PNG black shadow instead of transparency

Hello and happy coding everyone :slight_smile:

I just have a little problem: i use this class to upload every part of my 3D like layers. And to add some image to explain it.
BUT
I have one problem: i do not know why there is a black shadow of it? I try ofEnableAlphaBending() and ofEnableBlendMode(OF_BLENDMODE_ALPHA); but nothing happen and i still have this black shadow, and no transparency:

Can you help me on that, please? Here is the cpp of the class:

//
// CS3D.cpp
//
//
// Created by Vincent Marsat on 18/07/16.
//
//

#include “CS3D.h”

CS3D::CS3D(){

}
//--------------------------------------------------------------
void CS3D::load(string Type3D, string Image){

ofEnableAlphaBlending();
ofEnableBlendMode(OF_BLENDMODE_ALPHA);
Organe.loadModel(Type3D, false);
Organe.setScaleNormalization(false);
Img.load(Image);

}

//--------------------------------------------------------------
void CS3D::draw(int mode, float scale,ofColor colorRectif, bool colorR, ofColor colorSelect, ofPoint Rotate,ofPoint LeapPoint, ofPoint TouchMin, ofPoint TouchMax){

ofPushStyle();
ofPushMatrix();
ofPoint Cmin;
ofPoint Cmax;

Cmin.rotate(Rotate.x, ofVec3f(1,0,0));
Cmin.rotate(Rotate.y, ofVec3f(0,1,0));
Cmin.rotate(Rotate.z, ofVec3f(0,0,1));

Cmax.rotate(Rotate.x, ofVec3f(1,0,0));
Cmax.rotate(Rotate.y, ofVec3f(0,1,0));
Cmax.rotate(Rotate.z, ofVec3f(0,0,1));


float XCmin = TouchMin.x *scale;
float XCmax = TouchMax.x *scale;
float YCmin = TouchMin.y *scale;
float YCmax = TouchMax.y *scale;
float ZCmin = TouchMin.z *scale;
float ZCmax = TouchMax.z *scale;

ofMesh mesh;

cout << "LX = "<< LeapPoint.x << " LY = "<< LeapPoint.y<< " LZ = "<< LeapPoint.z << endl;
cout << "XCmin3 = "<< XCmin << endl;

if (LeapPoint.x > XCmin && LeapPoint.x < XCmax && LeapPoint.y > YCmin&& LeapPoint.y < YCmax && LeapPoint.z > ZCmin && LeapPoint.z < ZCmax) {
    mode = 1;
    cout << " BONJOUR " << endl;
    ofPushMatrix();
    ofTranslate(1, -TouchMin.y/200 ,TouchMin.x/200);
    ofPushMatrix();
    ofRotateX(180);
    ofRotateY(-90);
    Img.draw(0,0,0, 1, 0.3);
    ofPopMatrix();
    ofPopMatrix();
} else {
    mode = 0;
    
}

switch(mode){
        
    case 1:
        ofPushStyle();
        mesh = Organe.getCurrentAnimatedMesh(0);
        ofSetColor(colorSelect);
        ofRotateZ(180);
        mesh.drawFaces();
        ofPopStyle();
        
        break;
        
    case 2:
        Organe.drawVertices();
        break;
        
    case 3:
        Organe.clear();
        break;
        
    default:
        if(colorR == true){
            ofPushStyle();
            ofSetColor(colorRectif);
            ofMesh mesh;
            mesh = Organe.getCurrentAnimatedMesh(0);
            ofSetColor(colorRectif);
            ofRotateZ(180);
            mesh.drawFaces();
            ofPopStyle();
        } else {
            Organe.drawFaces();
        }
        break;
}

ofPopStyle();
ofPopMatrix();

}

is the “shadow” you’re talking about the black rectangle with the double diamonds and the dots in it?

Yes, this is the PNG image, but the black is normally transparent.

I’m using this class as a function or frameworks to upload 3D.

what happens when you draw it without altering its width and height?

Itis too big to see :confused:
Maybe if i let the image at the good size and scale it with ofScale… i’ll try it.

I’have just done it, it is still making the black rectangle. But thank you for the try :slight_smile:
Any ideas?

Anyone :’( ?

maybe before calling Img.draw(0,0,0, 1, 0.3); you need to set ofSetColor(255,255,255,255)?

maybe your ofPushStyle() requires you to again call ofEnableAlphaBlending()?

maybe your PNG is not truly RGBA?

?

I’ll already try it :’(

I just check my image: they are in RGBA… I really do not understand.

A good thing to try is to just try loading and drawing tha image into an empty OF project, just to make sure that its not something with the image.

Also from looking at your code ofEnableAlphaBlending() and any calls similar to that should happen right before you draw the image.

So one thing to try is replace:

  Img.draw(0,0,0, 1, 0.3);

with:

ofPushStyle();
  ofEnableAlphaBlending(); 
  ofDisableDepthTest(); 
  ofSetColor(255, 255, 255, 255); 
  Img.draw(0,0,0, 1, 0.3);
ofPopStyle();

Where you draw the image.

That will make sure alpha blending is enabled for the image.

Hope that works!
theo