fix(particles): use mesh UVs when texturing mesh particles (#7858)#8931
Merged
Conversation
GPU mesh particles ignored the mesh UVs, so a colorMap rendered as a flat single-texel color. The particle vertex buffer stored the mesh UV under the SEMANTIC_ATTR1 semantic, so the particle mesh instance never reported SHADERDEF_UV0. That disabled the meshUv shader path (particle_uv fell back to a constant vec2(0.0)) and, even when forced on, bound particle_uv at a location that did not match the vertex buffer. Storing the UV under SEMANTIC_TEXCOORD0 makes the mesh instance report SHADERDEF_UV0, which enables USE_MESH_UV and binds particle_uv at the matching attribute location. Fixes WebGL2 and WebGPU; the CPU path is unaffected. Also adds a "Textured" toggle to the particles-mesh example.
Build size reportThis PR changes the size of the minified bundles.
|
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.
Fixes mesh particles ignoring their mesh UVs, so a
colorMaptexture now maps across the mesh instead of rendering as a flat single-texel color. Regression from the particle shader generator refactor; reported in #7858.Root cause:
SEMANTIC_ATTR1semantic. As a result the particle mesh instance never reportedSHADERDEF_UV0, soParticleMaterial'smeshUvoption (objDefs & SHADERDEF_UV0) was always false.meshUvoff,USE_MESH_UVwas not defined andparticle_uvfell back to a constantvec2(0.0), so every particle sampled a single texel. Even if forced on,particle_uv(mapped toTEXCOORD0, location 5) did not match the vertex buffer'sATTR1(location 1).Changes:
SEMANTIC_TEXCOORD0inParticleEmitter.getVertexInfo(). This makes the particle mesh instance reportSHADERDEF_UV0, which both enables theUSE_MESH_UVshader path and bindsparticle_uvat the matching attribute location.ATTR4).Examples: