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

New renderer in Rust using the nsi crate #22

Open
jromang opened this issue Feb 12, 2024 · 3 comments
Open

New renderer in Rust using the nsi crate #22

jromang opened this issue Feb 12, 2024 · 3 comments

Comments

@jromang
Copy link

jromang commented Feb 12, 2024

Hello, sorry if my question is trivial, but what are the steps to use this crate correctly when writing a new renderer instead of using 3dlight ?

@virtualritz
Copy link
Owner

Sorry, I completely missed this.

You need to expose the C API. I.e. what is in the nsi.h header. The API is copy. I.e. anything passed-in is copied immediately. This is the safest way to do this in C.

The main issue is that you need to actually also replicate the functionality of NSI. I would be interested in helping writing this middle layer crate. That crate would keep the node graph representation and offer hooks to convert data to whatever internal representation the renderer requires.

Then there is the biggest challenge: Open Shading Language support. For shading NSI relies on OSL.

An alternative is to use pre-defined material/texture nodes that a renderer implements. And then combine them into a shading network via NSI, just as one would with OSL nodes.

Probably MaterialX would be a good, minimal, starting point. Of course, if you have OSL, you can just use the MaterialX reference implementation. Without OSL you need to translate the MaterialX nodes to your renderer.

As a reward you renderer is immediately available in Maya, Houdini and Cinema4D via the resp. OSS plugins on GitLab.

@virtualritz
Copy link
Owner

Once you have the C-API exposed, you can then compile your renderer to a dylib and load that instead of lib3delight.

When that happens I will gladly add code that lets a user select the rendering backend both at build time as well as dynamically, at compile time. I.e. there would probably be Context:new_with_backend() method that allows selecting the rendering backend for each context it creates.

@virtualritz
Copy link
Owner

virtualritz commented May 22, 2024

Furthermore, once the middle layer exists, we could create a Rust-only version of the NSI API that offers move and borrow semantics for the data passed into a Context.

The C-FFI wrapper around that would just call the move version with a copy of the data passed in.

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

2 participants