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

Add an NSI C binding #103

Open
virtualritz opened this issue Apr 14, 2021 · 6 comments
Open

Add an NSI C binding #103

virtualritz opened this issue Apr 14, 2021 · 6 comments

Comments

@virtualritz
Copy link

NSI is a replacement for RenderMan Ri/RIB that was developed by Illumination Research for their 3Delight renderer.

3Delight used to be RenderMan compliant from 1999–2019.

The NSI API is completely open and very minimal. It's a single header.

An NSI parser will be made OSS soon too. But it's fine to just have the C-API at the beginning. It's just 11 functions.

Having the C-API implemented for c-ray will instantly allow you to hook up the renderer to these apps:

  • Maya
  • Houdini
  • Katana
  • Cinema 4D
  • USD Hydra

All of the NSI plug-ins for these apps are OSS and hosted here:
https://gitlab.com/3Delight

@vkoskiv
Copy link
Owner

vkoskiv commented Apr 14, 2021

Very cool! Now I know what I'm doing this weekend 😄

@virtualritz
Copy link
Author

You will be the first 'other' renderer to add an NSI API. 😄
I sent you an invite for the 3Delight slack per Twitter PM.

@virtualritz
Copy link
Author

virtualritz commented Apr 14, 2021

So the caveats.

Scene Edits

The NSI API supports scene edits via NSIRenderControl("sync",...). To support this, too, you will need to add this bit that I saw on your todo list

  • Built a more robust API with an interactive scene state.

But this is not mandatory. The DCC plug-ins have support for IPR viewport rendering which won't work w/o scene edits but that feature can probably be isolated with some #ifdefs to make everything work if this feature is not implemented.

Shaders

NSI's shading system is built around the idea that the renderer supports OpenShadingLanguage (OSL) to describe shader graphs.
Integrating OSL is no weekend project.

Again, that being said: the API makes no assumptions in that regard. It's just that shaders are assumed to exist outside the renderer.

Workarounds:

  1. 3Delight ships with a set of artist friendly OSL shaders and these are well integrated with the DCC plug-ins. The most used one is a Disney Principled based Uber shader called dlPrincipled. They also recently added an implementation of Autodesk Standard Surface – dlStandard.
    If you map what you have in the renderer to these two shaders and intercept dlTexture nodes plugged directly into their slots you will have something that is 90% useful w/o adding OSL support. A bit of a hack but should be good enough.
    Same for lights which are just geometry with a surface shader emitting, in OSL. It's based on reality – it doesn't have a concept of a light as something special.

  2. A bit more work: in your version/fork of the DCC plugins you can expose shader nodes only mirroring what your renderer supports.

Subdivision Surface Support

NSI also supports subdivision surfaces via extra attributes on the mesh node.

Workaround: ignore these attributes and just render the control cage as a polygon mesh.

If you wanted to add support for subdivs, Pixar's OpenSubdiv is a painless dependency (as in: as painless as it gets in C/C++ land).
It uses CMake, can be built with the (default) CPU backend only and then has no further dependencies.
Add it as a git submodule and a bit of CMake and you should be good to go.

Being C++ It uses some template classes that require a specialization, each, to be usable.

You can grab specializations that expose a C-only API from an OpenSubdiv Rust wrapper.

In general, if you are interested in using C++ dependencies but with a C-API, watch this project – C++--.

@odil24
Copy link

odil24 commented Apr 15, 2021

Hmm. So whith this can we integrate to Blender also?

@virtualritz
Copy link
Author

virtualritz commented Apr 15, 2021

There is no NSI Blender plug-in yet. 3Delight have said they want to do one, at some point.

That said, no one stops you from making a plugin yourself. A good start may be the source code of the Appleseed or Cycles integration as they will cover the OSL part.

NSI was developed with both VFX production demands for a scene description and plugin developers mind.

This is not easy as these two groups sometimes have orthogonal requirements.

RenderMan RIB/the RenderMan Interface was the industry standard for many years but it can't serve this purpose any more, with the demands of today's productions. USD is both an asset container and a scene description. But it is not there yet and also didn't concern itself with the requirements of plugin developers.

@odil24
Copy link

odil24 commented Apr 16, 2021 via email

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

3 participants