
##############################################################################################
#                                                                                            #
#                    Support for NVidia's OptiX denoiser in JWildfire                        #
#                                                                                            #
##############################################################################################  
1. Introducing NVidia's OptiX AI-Accelerated Denoiser
The OptiX denoiser, developed by NVidia, is included in most of the common 3D rendering
software like Arnold, Blender, Lightwave.
I was enjoying it for a longer time, but did not really think about an integration into
JWildfire, because such an integrationg (GPU rendering and Java programs) is always somewhat
weak or unstable.

But then, user [Phaser Rave] at the JWildfire forum, introduced us to the a command-line version
of the denoiser, made by Declan Russell [2]. I was immediately hooked and created some "dirty"
integration of the tool into the render-flow to play around. I was really excited and the
results where amazing, so I kept stuck to the idea and improved the implementation.

Now, it is loosely coupled and can not crash your JWildfire process. You will only see
the options, when your system can run it. So, it will not confuse users who can not
make use of it, either. All others will probably love it.
And, by using the way of utilizing a command-line-tool you are even able to denoise your
already rendered images!

1.1 Cutting down render times in a significant way
The denoiser allows to cut down render times in a really significant way, especially for
animations, where many details never would become visible, because they would be removed
by animation compression. So, by computing them in a lower quality and then denoise the
result, often leads to similar results like before (computing in higher quality and
applying animation-compression).

But, the new feature may also be very interesting for still images containing much noise.
Some flames need a very large render time in order to become smooth.
With the denoiser this may become a matter of seconds now.

To help with this, there is preview-button on the preview area, where you can easily
make visible the effect of the denoiser and compare it with the raw image.

See also Chapter 3.5 Rethink your quality settings

1.2 Limitations
Currently, only Windows is supported, but Linux support could be added later.
Support for macOS is more unlikely, because NVidia has dropped support for CUDA.

1.3 Requirements
- Windows
    - sucessfully tested: Windows 10
- a recent NVidia graphics card which supports the OptiX denoiser
    - sucessfully tested: GTX 980, GTX 1060, GTX 1080
- a recent driver for your graphics card (which supports the OptiX denoiser)
    - sucessfully tested: 445.87 (see NVidia control panel -> Help -> System Information)

##############################################################################################
2. Installation
There is no additional installation required, everything is included.

For stability and flexibility reasons, JWildfire utilizes the OptiX command-line denoiser,
made by Declan Russell[2].
This makes it possible to execute the denoiser on already rendered flames (by execution
of the tool via the command-line). You can find the tool inside the Denoiser-folder
inside the lib-folder of your JWildfire-installation.

2.1 Automatic Self-Test
JWildfire automatically performs a self-test at startup. Only when the requirements are met,
the OptiX-Denoiser can be selected and executed.
You will see this as "OPTIX"-option for "AI-based denoiser" at the "Anti-Aliasing/Filter"-tab.
When you don't see this option", but think your system does meet the requirements, please
see Chapter 4. Troubleshooting.

##############################################################################################
3. Rendering flames using the OptiX Denoiser
3.1 Denoiser preview
If your system meets the requirements and you selected "OPTIX" for the parameter "AI-based denoiser"
at the "Anti-Aliasing/Filter"-tab, you will see a small green button (with the NVidia-logo)
in the right upper of the preview area.
Pressing this button causes the OptiX denoiser applied to the current preview image.
The left part of the image is kept unchanged, so that you can see the difference.
There is a light green line to separate the raw (left) and denoised (right) part of the image.

To achieve better results, you may perform a full preview render before executing the denoiser.
On the other side, performing it one a very low quality preview will demonstrate you the power
of the denoising effect.

The preview also works this way when denoising of the flame is actually disabled.
See Chapter 3.2 to activate denoising for a final render.

3.2 "OptiX filter blend" parameter
Usually, you want a strong denoising effect, but sometimes it removes too many details.
You can blend over the original image to bring details back again.
This is the purpose of the "OptiX filter blend" parameter at the "Anti-Alising/ Filter"-tab.
By setting it to 0.0, you will get the denoised image.
By setting it to 1.0, you will get the original image.
By setting it to any value in between, you will get a mix of both images.

The preview (see Chapter 3.1 Denoiser preview) always respects this setting when generating
an image. Therefore this option is always enabled, even when denoising of the final image
is disabled.

3.3 Applying the denoise to final images
You must select the option "OPTIX" for the parameter "AI-based denoiser" at the "Anti-Aliasing/Filter"-tab
to apply the denoiser when a final image is created. This applies to single-rendering as well
as to the interactive renderer as well as to batch rendering.
To generate a preview of the denoising effect, see Chapter 3.1 Denoiser preview.

3.4 Preferences
Per default the OptiX denoiser is deactivated for new flames. You can overwrite this behaviour
in the Preferences by changing the property tinaDefaultAIPostDenoiser.
Here you can also change the default filter blend value (which is 1/9) by changing the
property tinaDefaultPostOptiXDenoiserBlend.

3.5 Rethink your quality settings
The use of this denoiser may be game-changing, especially for rendering animations.
You can now try out very low quality settings like 100, 50 or even 5.
This cuts down rendering times amazingly.

When creating videos for platforms like Youtube, usually a lossy compression occurs.
So, it often makes not much sense to compute details in first place which get lost
when you assemble your video. So, when rendering at low quality and using the denoiser
to "ramp up quality" you will probably often see not much difference in the final
result, but it will allow you to be more creative by allowing to try out more ideas
in the same time.

##############################################################################################  
4. Troubleshooting
When you do not see the OPTIX-option for the parameter "AI-based denoiser" at the "Anti-Aliasing/Filter"-tab,
but think your system does meet the requirements, please ferform the following steps:
1. open a windows explorer and locate the folder of your JWildfire installation,
    e.g. D:\j-wildfire-6.00
2. copy the path into your clipboard
3. press <Windows>+<R> to execute a command
4. type "cmd" into the field and press <Enter>
5. enter the command "cd /d <Press STRG+V or RMB>", so that there now appears something
   like "cd /D D:\j-wildfire-6.00"
6. Press enter
7. Enter the command: "java -jar lib\j-wildfire.jar >diagnostics.txt"
8. Press enter, JWildfire should open
9. Close JWildfire, go back to the console
10. Enter the command "notepad diagnostics.txt"
11. Press <Enter> and look for an error message
12. Try to resolve it, e. g. by installing the latest driver for your graphics card
13. When you can not resolve it, report the error, but please include the file diagnostics.txt
14. Good luck!

##############################################################################################  
5. References
[1] NVidia's OptiX AI-Accelerated Denoiser: https://developer.nvidia.com/optix-denoiser
[2] Commandline Denoiser by Declan Russell:  https://declanrussell.com/portfolio/nvidia-ai-denoiser/
