Increasing access
Introducing KEEP_CONNECTIONS would make the behavior of computeNormals() clearer and more intuitive, especially for beginners working with custom 3D geometry.
Currently, FLAT can be misleading because it does not always produce true flat shading when faces share vertices. The new name would better communicate what the mode actually does, helping users understand and choose the appropriate normal calculation behavior.
Keeping FLAT as a deprecated alias would also ensure that existing sketches continue to work without requiring immediate changes.
Most appropriate sub-area of p5.js?
Feature enhancement details
Problem
Currently, computeNormals(FLAT) calculates vertex normals by accumulating face normals across connected vertices. Because vertices shared by multiple faces receive averaged normals, this does not always result in true flat shading.
The name FLAT can therefore be misleading, as discussed in #9205.
Proposed solution
Introduce a new shading constant, KEEP_CONNECTIONS, that represents the existing behavior of FLAT, while keeping FLAT as a deprecated alias for backward compatibility.
The proposed changes are:
- Introduce
KEEP_CONNECTIONS as a supported shading mode for computeNormals().
- Preserve the current normal calculation behavior without modifying vertex connections or geometry attributes.
- Keep
FLAT working as before throughout p5.js 2.x to avoid breaking existing sketches.
- Mark
FLAT as deprecated in the documentation and recommend using KEEP_CONNECTIONS instead.
- Add or update tests to verify that both modes produce equivalent results.
As discussed with @davepagurek, FLAT could potentially be removed in the next major version (p5.js 3.0), rather than in a minor or patch release.
Related issues
This issue focuses only on introducing KEEP_CONNECTIONS and deprecating FLAT. The proposed SEGMENTED mode for true flat shading will be tracked in a separate follow-up issue.
Increasing access
Introducing
KEEP_CONNECTIONSwould make the behavior ofcomputeNormals()clearer and more intuitive, especially for beginners working with custom 3D geometry.Currently,
FLATcan be misleading because it does not always produce true flat shading when faces share vertices. The new name would better communicate what the mode actually does, helping users understand and choose the appropriate normal calculation behavior.Keeping
FLATas a deprecated alias would also ensure that existing sketches continue to work without requiring immediate changes.Most appropriate sub-area of p5.js?
Feature enhancement details
Problem
Currently,
computeNormals(FLAT)calculates vertex normals by accumulating face normals across connected vertices. Because vertices shared by multiple faces receive averaged normals, this does not always result in true flat shading.The name
FLATcan therefore be misleading, as discussed in #9205.Proposed solution
Introduce a new shading constant,
KEEP_CONNECTIONS, that represents the existing behavior ofFLAT, while keepingFLATas a deprecated alias for backward compatibility.The proposed changes are:
KEEP_CONNECTIONSas a supported shading mode forcomputeNormals().FLATworking as before throughout p5.js 2.x to avoid breaking existing sketches.FLATas deprecated in the documentation and recommend usingKEEP_CONNECTIONSinstead.As discussed with @davepagurek,
FLATcould potentially be removed in the next major version (p5.js 3.0), rather than in a minor or patch release.Related issues
computeNormals()shading behavior.SMOOTH.This issue focuses only on introducing
KEEP_CONNECTIONSand deprecatingFLAT. The proposedSEGMENTEDmode for true flat shading will be tracked in a separate follow-up issue.