Skip to content

Enabling lights() in WEBGL breaks vertex colors.  #4274

Closed
@johncbowers

Description

@johncbowers

Most appropriate sub-area of p5.js?

  • Color
  • Core/Environment/Rendering
  • Data
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Other (specify if possible)

Details about the bug:

  • p5.js version: both in 0.10.2 on my local machine and the latest in p5js editor on the website
  • Web browser and version: Both Safari 12.0 and Firefox 72.0.2
  • Operating System: macOS 10.14
  • Steps to reproduce this:

To see the bug, simply load the p5js editor from the p5js website and compare the following two scripts:

Script 1 (with the problem code commented out):

function setup() {
  createCanvas(400, 400, WEBGL);
}

function draw() {
  background(220);
  //lights();
  beginShape(TRIANGLES);
  fill(255, 0, 0);
  vertex(-100, -100, 0);
  fill(0, 255, 0);
  vertex( 100, -100, 0);
  fill(0, 0, 255);
  vertex( 0,  100, 0);
  endShape(CLOSE);
}

Script 2 (with the problem code uncommented):

function setup() {
  createCanvas(400, 400, WEBGL);
}

function draw() {
  background(220);
  lights();
  beginShape(TRIANGLES);
  fill(255, 0, 0);
  vertex(-100, -100, 0);
  fill(0, 255, 0);
  vertex( 100, -100, 0);
  fill(0, 0, 255);
  vertex( 0,  100, 0);
  endShape(CLOSE);
}

The expected behavior is that I would see the same triangle in Script 2 as in Script 1 colored red, green, and blue at its vertices with interpolated colors on the interior. The actual behavior is that enabling lights() causes the renderer to ignore all but the last fill color.

Everything works as expected in normal Processing.app (after appropriate modifications to convert to JavaScript and translate so the triangle is on the screen since the origin is different between p5js and Processing).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions