p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

fixed no_tint issue while rendering

Open NavyaNayer opened this issue 7 months ago • 2 comments
trafficstars

Fix: Framebuffer Rendering Issue After noTint() Call

Resolves #7677

Summary of Changes

This PR fixes a bug where calling noTint() before rendering a framebuffer would cause an error and prevent correct rendering. The fix ensures that noTint() correctly updates shader uniforms without breaking the framebuffer rendering pipeline.

Key Fixes:

  • Fixed framebuffer rendering failure after noTint() by setting its default value to [255, 255, 255, 255] (white) instead of null.

Bug Description

When calling noTint() before rendering a framebuffer, the following error was thrown:
Uncaught TypeError: Cannot read properties of null (reading 'slice')

This happened due to how noTint() was modifying the tint uniform value, causing the shader pipeline to fail when rendering framebuffers.

Root Cause:

  1. noTint() was setting the tint value to null.
  2. The shader uniform system attempted to slice the null value, resulting in an error.
  3. This error prevented framebuffers from being rendered correctly.

Fix Implementation

The following changes were made to resolve the issue:

Updated noTint() Implementation

  • Instead of setting tint to null, it now defaults to [255, 255, 255, 255] (white).
  • This ensures valid uniform data is always provided to the shader.

Testing & Verification

Manual Testing

  • Verified that calling noTint() no longer causes framebuffer rendering to fail.
  • Confirmed that all tint-related operations function correctly.

Automated Testing

  • Updated unit tests to validate correct behavior when noTint() is applied before rendering framebuffers.

PR Checklist

  • [x] npm run lint passes
  • [x] Inline reference is included/updated
  • [x] Unit tests are included/updated

NavyaNayer avatar Apr 02 '25 08:04 NavyaNayer