Skip to content

How to interpret index pick info for MIP volume rendering #1251

Description

@kushalkolar

If I have a MIP volume of shape [10, 10, 10] and I pick the face of the volume towards the camera, it returns a pick index of [5, 4, 10]. I would expect it to return the z index as 9 and not 10. How do I interpret this?

To reproduce, run in an interactive session (such as ipython with %gui qt):

import pygfx
from rendercanvas.auto import RenderCanvas, loop
import numpy as np

vol = pygfx.Volume(
    geometry=pygfx.Geometry(grid=np.ones((10, 10, 10), dtype=np.float32)),
    material=pygfx.VolumeMipMaterial(pick_write=True)
)
canvas = RenderCanvas()
renderer = pygfx.WgpuRenderer(canvas)

disp = pygfx.show(vol, renderer=renderer, canvas=canvas)
loop.run()

Pick the center of the canvas:

renderer.get_pick_info((320, 240))

Returns:

{'rgba': Color(1.0, 1.0, 1.0, 1.0),
 'world_object': <pygfx.Volume  at 0x7f39b09c6a50>,
 'index': (5, 4, 10),
 'voxel_coord': (-0.4929805285967168, 0.4923701397790392, -0.5)}

Thanks! 😄

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions