Hi everyone!
First a huge THANK YOU! to Eric and John for the amazing recent work on adding significant functionality to Gaffer’s 3Delight support and to Aghiles and the 3Delight team for making an awesome renderer with an excellent API that is at the same time so easy to work with and so flexible.
After tinkering with adding some of the missing 3Delight features by post-processing and then rendering the Gaffer exported NSI scene with a batch of Python Command and System Command nodes (which worked surprisingly well, mostly due to the amazing power and flexibility that Python Command, System Command and the general Gaffer Dispatch structure provides, but was limited to simpler scenes), I decided to take a deep dive and try implementing the features directly in Gaffer.
Working with and compiling Gaffer’s source code turned out to be much simpler than I feared it would be (once again thanks John!) and I’m happy to present you a Linux build of Gaffer that has the following functionality added:
- Importance sample filter option enabling the rendered image to be compatible with ML based denoisers like OIDN.
- Gaffer’s Output node parameters create both output layer and output driver attributes in 3Delight. This enables direct control of the rendered image bit-depth format, color space and filter (and a lot of other things). The old Quantize parameter is no longer used for this.
- Updated 3Delight output presets exposing the above functionality by default.
- Scene graph dl: attributes are exported as both geometry attributes and shader attributes in 3Delight. This enables 3Delight’s shaders to read any custom Gaffer attributes. Among other things, this is for ex. very useful when doing instancing where you would want to attach per-instance custom data.
- Camera overscan support.
- Automatic ASCII or binary NSI export from the DelightRender scene description output. This is based on the file name extension - .nsia for ASCII, anything else for binary output.
- Light groups (i.e. lightsets in 3Delight terminology) enabling rendering of one or multiple subsets of lights into separate images from a single render. This can be achieved by creating a custom Output string parameter called lightgroup and then adding a space separated list of light locations from the active scene.
While I tried to contain the main code changes to IECoreDelight/Renderer.cpp, in order to enable light groups I had to change the order of the scene data output processing in the GafferScene/Render.cpp file, so that outputs are processed last, instead of second after options (this is due to the lightset connection requiring the lights to be declared before the connection is made). I haven’t tested if this negatively affects Cycles or Arnold renders.
Finally, although this is not directly related to the changes in the Gaffer source code, I’ve noticed that two following tricks that can help a lot with creating complex shader networks in Gaffer. Since Gaffer doesn’t allow OSL surface shaders to be connected to OSL shader plugs, I simply changed the shader type directly in the compiled .oso file from surface to shader and this enabled complex layered surface shader networks to be built in Gaffer. Similarly changing a displacement shader from a shader type to a displacement type directly in the .oso file enables Gaffer to correctly recognize the shader as a displacement shader instead of a surface shader.
I’ve added an example of the adapted OSL shaders in the below Gaffer build, along with an AOV shader that uses single data inputs instead of arrays, which enables custom AOV creation and render with 3Delight.
Linux build (compiled under the suggested CentOS 7 environment – tested both with CentOS 7 and Ubuntu 22.04):
https://drive.google.com/file/d/1dQI5ximuA0wrgV6xsZ2KJTwUDkgxglCN/view?usp=drive_linkThe adapted source code for the above build:
https://drive.google.com/file/d/1cX7EG2E23KzHnr6Zt0aYx4-yj_WijEN9/view?usp=drive_link