fix: vec4 vColor compatibility for three.js r183+#158
Merged
agargaro merged 1 commit intoMar 8, 2026
Conversation
three.js r183 changed `vColor` from conditionally `vec3`/`vec4` to always `vec4`. This caused GLSL compilation errors: cannot convert from 'const 3-component vector of float' to 'out highp 4-component vector of float' Changes: - instanced_color_vertex.glsl: always assign vec4 to vColor - instanced_color_pars_vertex.glsl: always return vec4 from getColorTexture() - InstancedMesh2.ts: always define USE_COLOR_ALPHA (colorsTexture is already RGBA with alpha=1.0 by default, so this is safe) This remains backward compatible with three.js r182 and earlier because USE_COLOR_ALPHA ensures vColor is declared as vec4 in older versions too. Co-Authored-By: claude-flow <ruv@ruv.net>
|
Owner
|
Awesome, thank you! I'll test and merge it later :) |
Owner
|
Thanks! I've released a new version with the fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Closes #159
three.js r183 changed
vColorfrom conditionallyvec3/vec4to alwaysvec4(three.js PR #32509). This causes GLSL shader compilation errors when using@three.ez/instanced-mesh:Changes
instanced_color_vertex.glsl: Always assignvec4tovColor(removesUSE_COLOR_ALPHAconditional)instanced_color_pars_vertex.glsl: Always returnvec4fromgetColorTexture()(removes vec3 branch)InstancedMesh2.ts: Always defineUSE_COLOR_ALPHAinstead of conditionally settingUSE_COLORorUSE_COLOR_ALPHABackward compatibility
This remains compatible with three.js r182 and earlier because
USE_COLOR_ALPHAensuresvColoris declared asvec4in older versions too. ThecolorsTextureis already created with 4 components (RGBA) and filled with1.0, so the alpha channel is safely1.0by default when opacity is not used.Repro
three@0.182.0- https://jsfiddle.net/sdivelbiss/epmj8v5t/Test plan
npm run buildvec3(1.0)or barevColor = colorassignments in build output