Skip to content

[p5.js 2.0+ Bug Report]: p5.strands shaders break if a hook parameter name clashes with a uniform name #8791

@davepagurek

Description

@davepagurek

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

2.x

Web browser and version

All

Operating system

All

Steps to reproduce this

Steps:

  1. Create a strands shader
  2. In it, create a uniform that clashes with a hook parameter, e.g. color
  3. Use it in the hook that has that parameter, e.g. getFinalColor

It ideally shouldn't break, since you don't know what the hook parameters are in the underlying GLSL, but it does.

Snippet:

function setup() {
  createCanvas(400, 400, WEBGL)
  let myShader = buildMaterialShader(function() {
    const color = uniformFloat(0.5)
    
    finalColor.begin()
    finalColor.set([color, color, color, 1])
    finalColor.end()
  })
  console.log(myShader.fragSrc())
  
  shader(myShader)
  noStroke()
  plane(width, height)
}

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

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Completed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions