07-30-2016, 08:31 AM
Hello,
I've uploaded the .beam of the work in progress (but working, I think) yafaray plugin:
https://github.com/DavidBluecame/YafaRay...p?raw=true
This beam is updated up to the commit https://github.com/DavidBluecame/wings/c...54b9b121fb (inclusive)
There are many changes respect to the original, as you can see in the GitHub commits. An important change is that in the original, the AA processing was not really correct even for older YafaRay versions. This is how it should work:
* The first pass (rendering all pixels) renders the number of samples specified in "aa_minsamples". This was ok.
* You can specify additional passes with "aa_passes". For subsequent passes, it would only render the pixels detected by the AA Threshold, and it would render a number of samples per subsequent pass specified in "aa_incsamples". This parameter was missing in the original plugin, so even for old YafaRay or Bounty versions that would cause Core to assume aa_incsamples=1, and therefore it would only render 1 sample per subsequent pass even if you had set minsamples to 20, for example (only the first pass would have rendered 20 samples, and the subsequent passes only 1 sample/pass)
So, I fixed it adding the missing "aa_incsamples" parameter and I also added quite a few AA/Noise control new parameters I added to Core v2.1.1 and v3.0.2:
* Detect color noise: the original AA algorithm only detected noise based on the brightness of the pixel and surrounding pixels. I found this not good enough when color noise was present where the brightness was similar but the color was different. I added a "naive" color detection algorithm (very simple, but it seems to work ok) that you can enable to better detect color noise even if the brightness of the pixels is similar. I recommend this to be enabled.
* Dark AA Threshold compensation: I also found AA was unable to detect noise in dark areas because it was a "constant" threshold. So, I added two "variable AA threshold" options:
- Linear: the AA theshold is calculated per-pixel based on the AA threshold parameter, the pixel brightness and the parameter "Dark Factor" which is more or less the slope of the AA linear transformation depending on pixel brightness. If used, the AA Threshold needs to be increased a bit. For good results, I would suggest: Enable Color detection, Set AA Threshold Compensation to Linear, AA Threshold = 0.1, Dark Factor = 0.9. That should detect noise in dark areas nicely. For detecting noise in near-black areas, you can use Dark Factor = 1.0
- Curve: the AA threshold is calculated based on the pixel brightness and a fixed curve (in this case the AA threshold parameter is not used at all). I'm not sure if it works well or not, but it was a suggestion from one member of the YafaRay team and I thought it was worth implementing. In any case I've left it in YafaRay v3.0.2 so you can try it.
* Variance pixel detection: I noticed in the past that normal AA didn't detect well certain types of noise, where bright pixels are separated. Only the bright pixels were re-rendered but many of the pixels in between were not. I added an option called "variance" which is basically a "moving window" that counts how many pixels vary in that window more than AA threshold. If it reaches a certain value, it would render additional samples for the entire window and add more samples to it. So, there are two parameters: the size of the window (lenght of the edge), and the number of pixels over which it will trigger the additional samples rendering. If pixels = 0, this function is disabled. You can experiment for example with pixels = 4.
* Multiplier Factors: this was a request from a YafaRay team member. He said that to reduce Montecarlo noise we should increase the number of samples we render in each pass. So, if the multipliers are = 1, it will render the same (aa_incsamples) number of samples per each pass. If the multiplier is, for example, 2, then it will render 2x samples respect to the previous pass (exponential!). For example multiplier 2 and incsamples=1: pass2 : samples 2, pass3: samples 4, pass4: samples8 and so on...
The first multiplier factor would affect the aa_incsamples value in each pass. There are two more multiplier factors: one would affect the Lights samples and the other the Indirect samples (Final Gather in Photon Mapping mainly).
* AA Resampling Floor: this comes from a YafaRay team member request. He said that, the more passes you put, the more difficult to remove noise. I added a parameter I called Resampling Floor that is in % of the image total size. When the number of pixels rendered in a certain pass is lower than the "floor", it will automatically lower the AA_Threshold for the next pass to try to render a bigger amount of pixels. I think it's an interesting feature, but it's for you to test and explore.
Also I added the new v3.0.2 Parameters Badge, Logging and the new TXT and HTML log files. I think they are more or less straightforward, I hope you like them. Now you can control the verbosity of the Console and the TXT/HTML log files with parameters and no longer need to set them in the YafaRay plugin preferences options.
I hope you like these changes, but this is still a work in progress. Best regards!
I've uploaded the .beam of the work in progress (but working, I think) yafaray plugin:
https://github.com/DavidBluecame/YafaRay...p?raw=true
This beam is updated up to the commit https://github.com/DavidBluecame/wings/c...54b9b121fb (inclusive)
There are many changes respect to the original, as you can see in the GitHub commits. An important change is that in the original, the AA processing was not really correct even for older YafaRay versions. This is how it should work:
* The first pass (rendering all pixels) renders the number of samples specified in "aa_minsamples". This was ok.
* You can specify additional passes with "aa_passes". For subsequent passes, it would only render the pixels detected by the AA Threshold, and it would render a number of samples per subsequent pass specified in "aa_incsamples". This parameter was missing in the original plugin, so even for old YafaRay or Bounty versions that would cause Core to assume aa_incsamples=1, and therefore it would only render 1 sample per subsequent pass even if you had set minsamples to 20, for example (only the first pass would have rendered 20 samples, and the subsequent passes only 1 sample/pass)
So, I fixed it adding the missing "aa_incsamples" parameter and I also added quite a few AA/Noise control new parameters I added to Core v2.1.1 and v3.0.2:
* Detect color noise: the original AA algorithm only detected noise based on the brightness of the pixel and surrounding pixels. I found this not good enough when color noise was present where the brightness was similar but the color was different. I added a "naive" color detection algorithm (very simple, but it seems to work ok) that you can enable to better detect color noise even if the brightness of the pixels is similar. I recommend this to be enabled.
* Dark AA Threshold compensation: I also found AA was unable to detect noise in dark areas because it was a "constant" threshold. So, I added two "variable AA threshold" options:
- Linear: the AA theshold is calculated per-pixel based on the AA threshold parameter, the pixel brightness and the parameter "Dark Factor" which is more or less the slope of the AA linear transformation depending on pixel brightness. If used, the AA Threshold needs to be increased a bit. For good results, I would suggest: Enable Color detection, Set AA Threshold Compensation to Linear, AA Threshold = 0.1, Dark Factor = 0.9. That should detect noise in dark areas nicely. For detecting noise in near-black areas, you can use Dark Factor = 1.0
- Curve: the AA threshold is calculated based on the pixel brightness and a fixed curve (in this case the AA threshold parameter is not used at all). I'm not sure if it works well or not, but it was a suggestion from one member of the YafaRay team and I thought it was worth implementing. In any case I've left it in YafaRay v3.0.2 so you can try it.
* Variance pixel detection: I noticed in the past that normal AA didn't detect well certain types of noise, where bright pixels are separated. Only the bright pixels were re-rendered but many of the pixels in between were not. I added an option called "variance" which is basically a "moving window" that counts how many pixels vary in that window more than AA threshold. If it reaches a certain value, it would render additional samples for the entire window and add more samples to it. So, there are two parameters: the size of the window (lenght of the edge), and the number of pixels over which it will trigger the additional samples rendering. If pixels = 0, this function is disabled. You can experiment for example with pixels = 4.
* Multiplier Factors: this was a request from a YafaRay team member. He said that to reduce Montecarlo noise we should increase the number of samples we render in each pass. So, if the multipliers are = 1, it will render the same (aa_incsamples) number of samples per each pass. If the multiplier is, for example, 2, then it will render 2x samples respect to the previous pass (exponential!). For example multiplier 2 and incsamples=1: pass2 : samples 2, pass3: samples 4, pass4: samples8 and so on...
The first multiplier factor would affect the aa_incsamples value in each pass. There are two more multiplier factors: one would affect the Lights samples and the other the Indirect samples (Final Gather in Photon Mapping mainly).
* AA Resampling Floor: this comes from a YafaRay team member request. He said that, the more passes you put, the more difficult to remove noise. I added a parameter I called Resampling Floor that is in % of the image total size. When the number of pixels rendered in a certain pass is lower than the "floor", it will automatically lower the AA_Threshold for the next pass to try to render a bigger amount of pixels. I think it's an interesting feature, but it's for you to test and explore.
Also I added the new v3.0.2 Parameters Badge, Logging and the new TXT and HTML log files. I think they are more or less straightforward, I hope you like them. Now you can control the verbosity of the Console and the TXT/HTML log files with parameters and no longer need to set them in the YafaRay plugin preferences options.
I hope you like these changes, but this is still a work in progress. Best regards!