processing/p5.js

[p5.js 2.0+ Bug Report]: p5.strands breaks if uniforms have two underscores in them

已關閉

#8,794 建立於 2026年5月13日

 (7 則留言) (2 個反應) (1 位負責人)JavaScript (3,178 個分叉)batch import
Area:WebGLArea:WebGPUHelp Wantedp5.js 2.0+p5.strands

倉庫指標

星標
 (20,784 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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 p5.strands shader
  2. Create a uniform containing two underscores
  3. Use it in the shader

We currently try to make uniform variables in the shader code named the same as the variable in your javascript. However, GLSL doesn't let you have two underscores:

Yikes! An error occurred compiling the vertex shader: ERROR: 0:47: '__val' : identifiers containing two consecutive underscores (__) are reserved as possible future keywords

We would need to rename these internally to not have this issue.

Snippet:

function setup() {
  createCanvas(400, 400, WEBGL);
  const myShader = buildFilterShader(() => {
    const __val = uniformFloat(() => 0.5)
    filterColor.begin()
    filterColor.set([__val, __val, __val, 1])
    filterColor.end()
  })
  filter(myShader)
}

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

貢獻者指南