# 3D shape with a bad seam

**URL:** <https://discourse.processing.org/t/3d-shape-with-a-bad-seam/13218>\
**Category:** Coding Questions\
**Created:** [August 6, 2019, 9:23pm UTC](https://discourse.processing.org/t/3d-shape-with-a-bad-seam/13218 "2019-08-06T21:23:35Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [August 11, 2019, 4:07pm UTC](https://discourse.processing.org/t/3d-shape-with-a-bad-seam/13218/16 "2019-08-11T16:07:58Z")

</div>

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.

````auto
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();
}```
````

---

_[View the full topic](https://discourse.processing.org/t/3d-shape-with-a-bad-seam/13218)._
