processing / processing/p5.js

[p5.js 2.0 Beta Bug Report]: vertexProperty() breaks if drawing with strokes

Open
#7,519 2 comments 0 reactions 1 assignee View on GitHub

@ImRAJAS-SAMSE is already working on this.

Since Mar 2, 2025.

Area:WebGL p5.js 2.0+
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
p5.js version

2.0 beta 1

Web browser and version

Firefox

Operating system

MacOS

Steps to reproduce this

When drawing strokes, we don't duplicate custom vertex properties to the different parts of strokes. When you try to draw strokes with per-vertex properties and use a shader that reads it, you get this warning in the browser console (not the p5 editor console though! open the browser one):

WebGL warning: drawArraysInstanced: Vertex fetch requires 51780, but attribs only supply 11526.
let snake
let snakeShader

function setup() {
  createCanvas(400, 400, WEBGL);
  
  snakeShader = baseMaterialShader().modify({
    vertexDeclarations: 'in float len;'
  })
  
  const pts = []
  for (let i = 0; i < 50; i++) {
      pts.push(createVector(random(width), random(height)))
  }
  
 snake = buildGeometry(() => {
    noFill()
    beginShape()
    for (const [i, { x, y }] of pts.entries()) {
        vertexProperty('len', [i/(pts.length-1)])
        splineVertex(x, y)
    }
    endShape()
  })
}

function draw() {
  clear()
  strokeShader(snakeShader)
  model(snake)
}

Live: https://editor.p5js.org/davepagurek/sketches/KwUdPojKW

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.