3D shape with a bad seam

If you only use ambient light you don’t have the problem because the surface normals are ignored. If you un-comment the directional light line the problem appears because of the way Processing estimates the normal vector.

float theta;

PVector[] s;
// Radius of Mobius strip
float r = 100;
// Width of mobius strip
float w = 40;
// Number of slices round the strip
int nbrSlices = 50;

void setup() {
  size(400, 400, P3D);
  // Calculate strip
  s = new PVector[nbrSlices * 2];
  float deltaT = TWO_PI / (nbrSlices - 1);
  // Calculate strip vertices
  for (int i = 0; i < nbrSlices; i++) {
    float t = i * deltaT;
    float t2 = t / 2;
    float cos_t2 = cos(t2);
    float sin_t2 = sin(t2);
    float cos_t = cos(t);
    float sin_t = sin(t);
    s[i] = new PVector( (r + w*cos_t2)*cos_t, (r + w*cos_t2)*sin_t, w * sin_t2 );
    s[nbrSlices + i] = new PVector( (r - w*cos_t2)*cos_t, (r - w*cos_t2)*sin_t, -w * sin_t2 );
  }
}

void draw() {
  translate(width/2, height/2);
  background(0);
  ambientLight(200,200,200);
  // directionalLight(100,100,100, 0,1,1);
  noStroke();
  fill(200, 15, 15);
  rotateX(theta);
  theta += TAU / 200;
  beginShape(QUAD_STRIP);
  for (int i = 0; i < nbrSlices; i++) {
    vertex(s[i].x, s[i].y, s[i].z);
    vertex(s[i+nbrSlices].x, s[i+nbrSlices].y, s[i+nbrSlices].z);
  }
  endShape();
}```
3 Likes