Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Antialiasing #406

Open
notEvil opened this issue Feb 19, 2022 · 1 comment
Open

Antialiasing #406

notEvil opened this issue Feb 19, 2022 · 1 comment

Comments

@notEvil
Copy link

notEvil commented Feb 19, 2022

Hi,

I did some surface and line plots recently and found the amount of aliasing rather distracting. Then I discovered SMAA and SSAA postprocessing in three.js and tried to add them to the plots. After a lot of trial and error (I'm not really familiar with js/ts and dev workflow) I was lucky and got:

2022-02-14

(from left to right: master branch, master + smaa, master + ssaa)

There is WebGLRenderer(...antialias=true...) but never saw any antialiasing applied. Are plots supposed to be antialiased? If not, optional SSAA would be a very nice feature.

Misc:

  • I had to modify three.js/postprocessing/SSAARenderPass to render multiple scenes to make it work, and ignored large parts like volume rendering and resize events, so its a rather hacky solution
  • the plot looks the same in Firefox, Chrome and Linux, Windows
@notEvil
Copy link
Author

notEvil commented Feb 21, 2022

part2
Out of curiosity I tried to figure out how SSAA would work for volume rendering and didn't find a simple solution. Then I noticed WebGLMultisampleRenderTarget which was introduced to threejs in r101. Again, dodging the obstacles as they appeared I managed to bump threejs to r137 and got a nicely multisampled output.

2022-02-14 2

r101 didn't work because of a stencil format issue which was fixed in r106. r106 didn't work because for some reason rendering to the multisampled target would force clear. So I decided to try r137 and there the issue has been resolved. The necessary adjustments to ipyvolume were minor, just one obstacle remained: pythreejs deserializes the ShaderMaterial objects without three.ShaderMaterial as prototype. I "fixed" it by using Object.setPrototypeOf just before the exception (before material.onBeforeRender in three.module.js:~27080). Obviously volume rendering is still broken, but maybe the remaining issues are easier to solve.

Long story short: I believe ipyvolume would benefit from a more recent version of threejs. Afaik the main obstacle is pythreejs which isn't going to support newer releases of threejs anytime soon (jupyter-widgets/pythreejs#359).

Anyways, it was a fun experience and maybe someday its actually useful. If anyone is interested, I will fork and push the changes.

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

No branches or pull requests

1 participant