Skip to content

[p5.js 2.0 Bug Report]: [p5.strands] Shared variable breaks when vertex and fragment shader strands are both present. #8640

@nbogie

Description

@nbogie

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.2.2

Web browser and version

145.0.7632.117 (Official Build) (arm64)

Operating system

Mac OS 14.6.1 (23G93)

Steps to reproduce this

Steps:

  1. Visit https://editor.p5js.org/neill0/sketches/ZmBjlLngO
  2. Observe sketch fails with
ERROR: 0:313: 'assign' : l-value required (can't modify an input "myVar")

Snippet:

  let myVar = sharedVec2();

  // Adding objectInputs block crashes it
  objectInputs.begin();
  objectInputs.position += [0, 0, 0];
  objectInputs.end();

  pixelInputs.begin();
  myVar = pixelInputs.texCoord;
  pixelInputs.end();

  finalColor.begin();
  finalColor.set([myVar.r, myVar.g, 0, 1]);
  finalColor.end();

Use case

  • Displaced terrain vertices - needs objectInputs
  • The terrain is coloured in finalColor based on, say, a texCoord that has to be saved from before finalColor, using a shared variable set in, say, pixelInputs.

Link to discord discussion

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions