jupyter-widgets / pythreejs

A Jupyter - Three.js bridge
https://pythreejs.readthedocs.io
Other
936 stars 187 forks source link

Add option to use webgl version 2 #244

Closed cmbruns closed 4 years ago

cmbruns commented 5 years ago

WebGL version 2 provides more advance rendering options compared to WebGL version 1. Only for those browsers that support it of course.

Maybe the syntax could be something like

renderer = pythreejs.Renderer(webgl_version='2', ...)

Three.js is gradually enhancing its support for webgl2: https://threejs.org/docs/#manual/en/introduction/How-to-use-WebGL2

Tronic commented 4 years ago

This would be more than welcome, or at least document that it is not supported. Too many hours wasted porting volume rendering code to pythreejs, only to find out that it won't be possible...

maartenbreddels commented 4 years ago

Hmm, yes, Id like ipyvolume to also be more pythreejs oriented, and I think I want to switch to webgl too.

vidartf commented 4 years ago

We could also consider to switch to using webgl2 by default (if it is available), i.e. that the trait on Renderer defaults to True.

vidartf commented 4 years ago

I made a draft PR here: https://github.com/jupyter-widgets/pythreejs/pull/289

I basically just wrote out what the guide said would be needed, but haven't had the chance to test it at all. If someone could help verify (or spot issues), that would help this along greatly!

Tronic commented 4 years ago

@vidartf Thanks for a quick fix. So far I can confirm that the mode works with your PR, although I am still having texture trouble (DataTexture3D misbehaving with the built-in preview, and not even 2d textures working in my ShaderMaterial -- the latter probably due to bugs in my code). I'll get back to this tomorrow.

vidartf commented 4 years ago

The previewer is trying to be smart, but is meant mostly for simple constructs. Let me know how it goes :)

Tronic commented 4 years ago

There is something weird going on even with 2d textures, that I cannot quite understand. Here is a minimal test: https://zi.fi/WebGL2-ShaderMaterial.ipynb WebGL2-ShaderMaterial.pdf

EDIT: I just confirmed that the texture problem occurs with webgl_version=1 too, so it is not relevant to this issue.

vidartf commented 4 years ago

I just confirmed that the texture problem occurs with webgl_version=1 too, so it is not relevant to this issue.

Ok, please open a separate issue for this if you cannot figure it out :)