Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

P3D - Something wrong with PShape shading #2018

Copy link
Copy link
@RectangleWorld

Description

@RectangleWorld
Issue body actions

(Possibly related to 2014)

Something seems to be wrong with the way lighting is being calculated (at least on the two machines where I tested my code). Note the bright areas at the bottom of the sphere (see below), which is lit from above by a directional light. The vertices at the edge of a surface seem to be the culprit (and maybe this is not an easy thing to fix). I see the same behavior with the default lights().

Simple test code is below. The camera rotates around the sphere. If you watch it running you'll see some strange abrupt change in lighting, especially at the lower sphere detail setting. The screencaps show the same code, first with the default sphere detail, the last two created with sphereDetail(10,10).

default_res_01
res_10_10_01
res_10_10_02

Full source code for the example:

float cameraAngle;
float cameraAngleInc;
PShape sphere;

void setup() {
  size(400,400,P3D);
  smooth(8);
  noStroke();
  sphereDetail(10,10);
  sphere = createShape(SPHERE, 150);
  cameraAngle = 0;
  cameraAngleInc = TWO_PI/600;
}

void draw() {
  cameraAngle += cameraAngleInc;
  camera(500*cos(cameraAngle),300,500*sin(cameraAngle),0,0,0,0,-1,0);
  directionalLight(204,204,204,0,-1,0);
  ambientLight(24,24,24);
  background(0);
  shape(sphere);
}

void keyPressed() {
  saveFrame("frame_####.png");
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.