Disappearing of Rear Texture

Hi Everyone, This is my first post, but i have been using Processing for quite a while. Usually I can find the solution of my problems by reading the forum and not bothering anyone. But this time I really can't find any quick fix.

The code is extremely simple: a rotating sphere with a semi-transparent texture. The rear side of the texture is correctly rendered most of the time, but sometimes it disappears completely or partially.

My question is: how can I always have the full render of the sphere? Thank you so much in advance.

p.s. the code hint(DISABLE_DEPTH_MASK); partially fix the problem but Processing won't be able to recognize what's in front and what's in the back.

Fig 1. Semi transparent texture (Test2.png) Test2

Fig 2. Desired solution: desired

Fig 3. Problem: problem

Fig 4. Partial fix with hint(DISABLE_DEPTH_MASK); disabled

Code:

PImage Texture;
PShape Wrap;
float X;
float Y;
void setup() {
  size(640, 360, P3D); 
  background(0, 0, 0, 0); 
  noStroke();
  fill(0, 102, 153);
  Texture = loadImage("Test2.png");
  noStroke();
  fill(255);
  sphereDetail(40);
  Wrap = createShape(SPHERE, 150);
  Wrap.setTexture(Texture);
  //hint(DISABLE_DEPTH_MASK);
}

void draw(){
  background(200);
  pushMatrix();
  translate(width/2, height/2); 
  X = float(mouseX)/width*TWO_PI;
  Y = float(mouseY)/height*TWO_PI;
  rotateY(X);
  rotateX(Y);
  shape(Wrap);
  popMatrix();

}
Sign In or Register to comment.