Does WebGL work for layers?
cornerstone-core version: 2.6.0
I've faced the issue that images added with addLayer don't use WebGL. There is a code in the internal function drawImageSync which adds conditional branching:
if (layers && layers.length) {
// render when layers specified
drawCompositeImage(enabledElement, invalidated);
} else if (image) { // render when layers not specified
Currently, WebGL works only for displayImage function. But it isn't possible to combine multiple images on the same canvas with displayImage.
- Is there any workaround to use multiple layers with WebGL?
- Do you have plans to add WebGL support for layers in the nearest future?
I don't have an answer to your question, but I am curious what you are trying to accomplish with the layersApi, perhaps there is a different workaround
@shanebenlolo I want to display a CT scan and can perform windowing, panning, and zooming operations. Also, I want to put a png image overlay on top of the CT scan. CT scan and overlay should be synchronized during panning and zooming.
I am considering three solutions:
- Use layers API. Cons: cornerstone doesn't use WebGL while windowing, so FPS becomes lower
- Use two cornerstone canvases. One for CT scan and one for overlay image. Cons: cornerstone adds black background to the overlay image, but the overlay background should be transparent. I didn't find any flag to make a background transparent, so the only solution I found is to set a background transparent on each rendering frame.
- Use two canvases. Cornerstone canvas for CT scan and custom canvas for overlay image. Cons: I have to write additional code to resize, translate and synchronize the overlay image.
Maybe there is another approach that mitigates all cons?
Have you considered using the react-vtkjs-viewport? https://react-vtkjs-viewport.netlify.app/