Skip to content

Commit

Permalink
[Fix] Fix picker support in BasicMaterial (#6672)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Jun 7, 2024
1 parent 9868aa6 commit f880185
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/scene/shader-lib/programs/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ const fShader = `
#include "packDepthPS"
#endif
#ifdef PICK_PASS
uniform uint meshInstanceId;
#endif
void main(void) {
#ifdef VERTEX_COLORS
Expand All @@ -102,7 +106,14 @@ const fShader = `
alphaTest(gl_FragColor.a);
#endif
#ifndef PICK_PASS
#ifdef PICK_PASS
const vec4 inv = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
const uvec4 shifts = uvec4(16, 8, 0, 24);
uvec4 col = (uvec4(meshInstanceId) >> shifts) & uvec4(0xff);
gl_FragColor = vec4(col) * inv;
#else
#ifdef DEPTH_PASS
gl_FragColor = packFloat(vDepth);
Expand Down

0 comments on commit f880185

Please sign in to comment.