Skip to content

VisPy volume render is blank with zoom_to_fit #97

Description

@kephale

Description

A SceneX Volume rendered through the VisPy backend produces an entirely black RGB frame, while the equivalent Image path and the PyGFX Volume path render nonblank frames.

I encountered this while validating a Lodstone/SceneX streaming adapter, then reproduced it without Lodstone using a direct SceneX model.

Reproducer

import numpy as np
import scenex as snx
from scenex.utils.projections import zoom_to_fit

snx.use("vispy")
z, y, x = np.indices((16, 16, 16))
data = (((z - 7.5) ** 2 + (y - 7.5) ** 2 + (x - 7.5) ** 2) < 36).astype(np.uint8) * 255
volume = snx.Volume(data=data, clims=(0, 255), render_mode="mip")
view = snx.View(scene=snx.Scene(children=[volume]))
canvas = snx.Canvas(width=96, height=96, views=[view])
zoom_to_fit(view, type="orthographic", letterbox=True)
rendered = canvas.render()
print(rendered.shape, rendered[..., :3].max(), np.count_nonzero(rendered[..., :3]))

On macOS with current SceneX main (bc09fcf), VisPy + native Qt prints:

(192, 192, 4) 0 0

The 2x dimensions reflect device pixel ratio and are expected. The zero max/count are not.

The same streamed volume through SceneX/PyGFX produces a nonblank frame (max=255, 12,972 nonzero RGB components), and SceneX/VisPy renders a streamed 2-D Image nonblank. Qt's offscreen platform cannot create the VisPy OpenGL context, so this reproduction uses native macOS Qt.

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