Autodesk / sitoa

Arnold plugin for Softimage
Apache License 2.0
33 stars 16 forks source link

Basic OptiX denoising support #45

Closed JenusL closed 5 years ago

JenusL commented 5 years ago

I had a look at MAXtoA to see how OptiX worked there and I guess it's similar to how the other plugins work. If you check Denoise on any AOV in MAXtoA, it will create a new AOV with "_denoise" as suffix. Since SItoA rely on the very limited Render Channels interface that's built in to Softimage, I had to go a different route...

What you do in SItoA is that you simply create a new Render Channel for the AOV that you want to denoise and simply name it with _denoise as suffix. So lets say you want to denoise the Main Render Channel. Then just create a new render channel called Main_denoise.

One current limitation with OptiX is that the denoised AOV can't be written to a multipart EXR. So make sure it has it's own filename output.

I also added Devices to the System tab. But only the auto selection part. It's a lot more work to add the manual selection of GPU. I don't feel it's needed for OptiX but maybe with more powerful GPU things we need manual control over the GPU selection.

caron commented 5 years ago

I will try and build this soon... very busy at work lately.

JenusL commented 5 years ago

Yeah no problem @caron You should know that I don't have OptiX working on every IPR refresh yet. It only shows when frame is done.

caron commented 5 years ago

Ya, that was clear. I am just wanting to build it and test it on another platform with another card. Provide feedback if necessary

caron commented 5 years ago

I see the denoising!

Ya, I hope @sjannuz can provide some feedback/suggestions for getting it to update the buckets and denoise each IPR step. I would be happy if it worked normally and denoised the last step but at this time it won't show any progress.

sjannuz commented 5 years ago

I'll have to spend more time on this to give a proper answer, but for what I recall, right now the display driver supports only one AOV: AiDriverInitialize(node, false); where false means NO multiple outputs. AiOutputIteratorGetNext will just return the unique AOV buffer. Accordingly, there is just one output entry for outputs when in region mode.

So, I think the solution could be to have both, say, Main and Main_denoise passed to the driver, that would display Main during the rendering and Main_denoise on completion.

JenusL commented 5 years ago

Yeah I know that the driver only supports one AOV. But what I don't understand is how I can get the Main_denoise AOV to denoise Main after every progressive iteration. It seams like Main_denoise is only "fired" after Main is completely done. Is there a way to manually tell optix to do the denoise right now or something like that?

sjannuz commented 5 years ago

The denoising happens after each AiRender, so it is possible to display the denoised pre-passes. I thought you wanted to have the buckets AND the denoised frame buffer, that's why I wrote about the multi-output drivers. It must be something in our driver, I'll have a look. And btw, I see the denoising working, too !

JenusL commented 5 years ago

But isn't just one AiRender fired in the new progressive mode? Somehow, MAXtoA is still able to show the denoised image after each progressive pass.

sjannuz commented 5 years ago

The denoiser happens on AiRender completation. regardless of the progressive flag. Here (in your branch) and in MAXtoA, we do a classic AiRender cycle over the AA_samples steps. So, after each, we should see the display updating with the denoised buffer. I see that the driver is called with increasing AA_samples, I'm not sure why the display does not update. Btw, other curious things happen when you enable a single thread, noisy and denoised buckets at the same time.

JenusL commented 5 years ago

Yeah but what I mean is if you set user option enable_progressive_render true just to try the progressive part, and disable the old -3 to 1 AA samples, AiRender is only going to run once with AA_samples but it will get there progressively. This somehow works in MAXtoA and the denoised image is shown after each progressive pass. So MAXtoA must somehow create a denoised image even before AiRender is finished. Right?

JenusL commented 5 years ago

I read the Api docs now. AiRender is deprecated and there's a bunch of new stuff there instead like AiRenderBegin, AiRenderResume, AiRenderRestart. AiRenderBegin takes a update callback argument that is fired on every pass complete. Will take a closer look later but at least I'm on the right track now.

JenusL commented 5 years ago

@sjannuz Maybe you could merge this PR and we will create a new PR if/when we add the completely new AiRenderBegin code. Would be awesome if your API example could be updated to use the new AiRenderBegin with the update_callback as well. https://docs.arnoldrenderer.com/display/A5ARP/Creating+and+Rendering+a+Scene

sjannuz commented 5 years ago

Right, I see that in progressive the denoiser is called after each progressive iteration too. However, for now I would focus on the traditional way to debug the driver, so just try to understand what goes on between two AiRender at different AA steps. And yes, Ai Render itself is deprecated, but all plugins except Katana keep using it. The new rendering api is slightly more complex and we never found the time to look at it properly. Also for that, I would keep it separated from the denoiser issue, else you'll complicate even more the problem.

sjannuz commented 5 years ago

@sjannuz Maybe you could merge this PR and we will create a new PR if/when we add the completely new AiRenderBegin code. Ok

JenusL commented 5 years ago

@sjannuz Ok great! That will probably make it easier to debug then. Will not go down the new AiRenderBegin rabbit hole :)