Skip to content

Conversation

@gkjohnson
Copy link
Collaborator

@gkjohnson gkjohnson commented May 4, 2023

Related issue: #25952 (comment)

Description

Updates the GPU picking example to use an integer vertex attribute, 32 bit integer target for rendering rather than the color-based approach that required using bit shifts on color values to reconstitute the id.

Note - I realized that no changes were needed to ShaderMaterial in order to enable rendering to an integer target since using GLSL3 enables control over the output type.

edit: also addresses and issue that was causing the 0th box to be selected when hovering over the background

Comment on lines +124 to +126
const position = geometry.attributes.position;
const array = new Int32Array( position.count );
array.fill( id );
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once #21606 is merged I would like to change this to an Int16 array and use the new "integer" declaration field here.

Comment on lines +258 to +259
clearColor.setRGB( - 1, - 1, - 1 );
renderer.setClearColor( clearColor );
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge deal but setting the clear color to something not representable with a hex value is a bit inconvenient here since it requires creating an intermediate color object.

@Mugen87
Copy link
Collaborator

Mugen87 commented May 4, 2023

https://rawcdn.githack.com/gkjohnson/three.js/gpu-picking-update/examples/webgl_interactive_cubes_gpu.html

@Mugen87 Mugen87 added this to the r153 milestone May 4, 2023
@gkjohnson gkjohnson merged commit b46de21 into mrdoob:dev May 4, 2023
@gkjohnson gkjohnson deleted the gpu-picking-update branch May 4, 2023 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants