ladybug-tools / bsdf-viewer

🎇 A web-based viewer for BSDF files
https://www.ladybug.tools/bsdf-viewer/
GNU General Public License v3.0
2 stars 3 forks source link

add support for tensor-tree BSDF #3

Open mostaphaRoudsari opened 5 years ago

mostaphaRoudsari commented 5 years ago

I need some help for this to:

  1. Understand the TT XML file structure - Greg has shared some code and documents for this and I have Andy's source code.

  2. Support hemispherical projection for better visualization.

mostaphaRoudsari commented 5 years ago

added a parser for tensor tree files: https://github.com/ladybug-tools/bsdf-viewer/blob/master/libs/loadttbsdf.js

You can also test it from the browser: https://www.ladybug.tools/bsdf-viewer/tensor-tree

cc: @andyrew

mostaphaRoudsari commented 5 years ago

From Greg:

The depth can theoretically be anything, but I don't think you'll ever see branching past level 8 on an anisotrpic tensor tree, or level 10 on an isotropic tensor tree due to memory limits during creation. Your parser should be able to handle up to this many levels, however.

Which means the current parser won't work as it and needs to be revised! Still it is pretty doable. There will be a question about performance and if we want to user regex as it is used right now or just write a custom parser to parse the values.

Related: https://github.com/benoitvallon/computer-science-in-javascript/blob/master/data-structures-in-javascript/tree.es6.js

andyrew commented 5 years ago

Hi Mostapha, What you've done is load the raw tensor tree data. The hard part is querying the tensor tree. After a lot of hair pulling trying to do this with my original BSDFViewer, I found it easier to use JNI to incorporate greg's C code into the viewer (and JNI was no picnic for me). The key function is SDqueryTre, but to use this, we need most of the functions in the bsdf_t_striped.c file greg sent, as well as sum functions in other files in the radiance distribution (hilbert.c for example). You mentioned a method for converting C to Javascript, can you use that to convert all of the C code Greg sent? Andy

mostaphaRoudsari commented 5 years ago

Hi Andy, This is how it should be done:

https://developer.mozilla.org/en-US/docs/WebAssembly/existing_C_to_wasm

On the surface it looks easy but I'm sure there will be challenges in the process.