xeokit-sdk icon indicating copy to clipboard operation
xeokit-sdk copied to clipboard

FEATURE: Improve alpha blending for X-ray

Open xeolabs opened this issue 2 years ago • 7 comments

We currently use the same blending modes for Selection, X-Ray and Highlight effects.

The blending modes we use currently are chosen to look best for Selection and Highlight, but seem to make X-ray too dark.

Solution could be to:

  • allow different blending modes for for X-Ray, Selection and Highlight,
  • maybe expose the ability to select the blending mode for each of these effects through the API, to override them for X-ray if needed,
  • or, always apply a better blending mode for X-ray, leaving blending the current blending modes for Selection and Highlight as they are currently.

Currently

X-Ray is too dark with the current blending modes.

Screenshot from 2023-11-20 19-55-00

gl.blendEquation(gl.FUNC_ADD);
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);

Experimental Improvement, using ADD, ONE_MINUS_SRC_ALPHA for X-ray

X-ray looks better with the blending mode shown below.

Screenshot from 2023-11-20 19-50-06

gl.blendEquation(gl.FUNC_ADD);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);

xeolabs avatar Nov 20 '23 19:11 xeolabs

@xeolabs This is a very useful adjustment for X-Ray mode. But we have recognized, that the following mode doesn't work correctly when the background / canvas is transparent. In this case, transparent objects getting colored from the canvas background color.

gl.blendEquation(gl.FUNC_ADD);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);

Maybe there's a better blending mode / function to achieve the desired result?

pbbr avatar Jan 29 '24 07:01 pbbr

@pbbr I've done lots of experimentation with blending modes but haven't yet found one that works perfectly for all cases. If anyone has suggestions they would be most welcome.

xeolabs avatar Jan 29 '24 15:01 xeolabs

@xeolabs Unfortunately, we didn't find a better configuration too. But what we see is, that with this blend function, transparent objects look very "bright" in Safari (Edge and Chrome are correct, both on Windows and Mac).

Safari: Bild

Edge / Chrome: image

Interesting is, that a captured snapshot looks correct. Do you have an idea how to change this?

pbbr avatar Jan 30 '24 07:01 pbbr

https://github.com/xeokit/xeokit-sdk/issues/1251#issuecomment-1916225747

@xeolabs Did you had any idea how to improve the appearance of transparent objects in Safari?

pbbr avatar Mar 18 '24 12:03 pbbr

@pbbr I haven't looked at this issue lately on Safari, so nothing to report yet. Do you represent one of our enterprise users? If so, then if we could track this via our Jira then we can ensure that it gets prioritized properly

xeolabs avatar Mar 18 '24 13:03 xeolabs

@xeolabs Yes, we are. But we don't have access to Jira. How we can get this?

pbbr avatar Mar 19 '24 12:03 pbbr

@pbbr please contact Wlod via this link, and he should be able to set you up with Jira access: [email protected]

xeolabs avatar Mar 19 '24 12:03 xeolabs