Commit Graph

3865 Commits

Author SHA1 Message Date
Lukas Stockner
6cd1d34dc1 Cycles Denoising: Prevent overfitting when using a very low radius
For example, when using a radius of 1, only 9 pixels (due to weighting maybe
even less) will be used, but the transform code may still decide to use a
5-dimensional (or even higher) fit.
This causes severe overfitting and therefore weird pixel values.

To avoid this, this commit limits the amount of dimensions to a third of the
pixel number. For a radius of 3 or more, this doesn't change anything, but
for 1 and 2 it can prevent fireflies and/or negative values being produced.
2017-05-19 23:33:22 +02:00
Lukas Stockner
3dee1f079f Fix T51560: Black pixels on a denoising render
Once again, numerical instabilities causing the Cholesky decomposition to fail.

However, further increasing the diagonal correction just because of a few
pixels in very specific scenes and settings seems unjustified.
Therefore, this commit simply falls back to the basic NLM-filtered pixel
if the more advanced model fails.
2017-05-19 23:31:49 +02:00
Mai Lavelle
177385dc43 Cycles: Reload kernels from Session when requested features change
This fixes T49496.
2017-05-19 16:24:19 -04:00
Sergey Sharybin
8d4aff31ce Cycles: Fix compilation error after recent changes
Spotted by Steffen Dünner, thanks@
2017-05-19 16:48:42 +02:00
Sergey Sharybin
ef549b9e55 Cycles: Cleanup, always use parenthesis
Easier to read/follow, and more robust for the further changes.
2017-05-19 12:57:51 +02:00
Sergey Sharybin
908bb8bd82 Cycles: Cleanup, indentation in preprocessor 2017-05-19 12:54:46 +02:00
Sergey Sharybin
90a62404cb Cycles: Cleanup, variable names
Don't use camel case for variable names. Leave that for the structures.
2017-05-19 12:52:12 +02:00
Sergey Sharybin
3a634524e3 Cycles: Cleanup, useless new lines 2017-05-19 12:45:22 +02:00
Sergey Sharybin
de86da521c Cycles: Cleanup, braces after function definition
I wouldn't mind switching fully to Google style, but i am against of
mixing two different styles in same project. So just stick to brace
at the new line after function definition.
2017-05-19 12:43:26 +02:00
Sergey Sharybin
803337f3f6 \0;115;0cCycles: Cleanup, use ccl_restrict instead of ccl_restrict_ptr
There were following issues with ccl_restrict_ptr:

- We already had ccl_restrict for all platforms.

- It was secretly adding `const` qualifier to the declaration,
  which is quite weird since non-const pointer can also be
  declared as restricted.

- We never in Blender are using foo_ptr or FooPtr type definitions,
  so not sure why we should introduce such a thing here.

- It is absolutely wrong from semantic point of view to put pointer
  into the restrict macro -- const is a part of type, not part of
  hint for compiler that some pointer is never aliased.
2017-05-19 12:41:03 +02:00
Sergey Sharybin
8e655446d1 Fix T51537: Light passes are summed twice for split kernel since denoise commit
Denoise commit introduced kernel_write_result() which saves light passes, so
no need to call both kernel_write_result() and kernel_write_light_passes() from
the split kernel.

Weirdly enough. kernel_write_result() does not take care about debug passes.
2017-05-19 12:14:03 +02:00
Lukas Stockner
4a04d7ae89 Fix T51553: Cycles Volume Emission turns black when strength is 0 or color is black
The problem was that Cycles implicitly uses a transparent surface shader when only
volume nodes are used, but since the black emission shader gets optimized away,
it was no longer detected and therefore no transparent surface was used.

Therefore, the shader now stores whether volume nodes were connected before
optimizing.
2017-05-19 04:59:35 +02:00
Lukas Stockner
cf1127f380 Fix T51506: Wrong shadow catcher color when using selective denoising 2017-05-19 04:04:54 +02:00
Mai Lavelle
29f4a8510c Cycles: Fix random noise pattern seen with multiscatter bsdf and split kernel
Differentials were unset if roughness was low giving undefined behavior.
2017-05-18 21:39:23 -04:00
Lukas Stockner
a21277b996 Fix T51555: Cycles tile count is incorrect when denoising is enabled
Now rendered and denoised tiles are counted and displayed separately.
2017-05-19 03:29:18 +02:00
Lukas Stockner
ffd83a34ab Fix T51502: Cycles denoising not using correctly aligned width for NLM on CUDA 2017-05-19 02:06:54 +02:00
Lukas Stockner
740cd28748 Cycles Denoising: Add more robust outlier heuristic to avoid artifacts
Extremely bright pixels in the rendered image cause the denoising algorithm
to produce extremely noticable artifacts. Therefore, a heuristic is needed
to exclude these pixels from the filtering process.

The new approach calculates the 75% percentile of the 5x5 neighborhood of
each pixel and flags the pixel if it is more than twice as bright.

During the reconstruction process, flagged pixels are skipped. Therefore,
they don't cause any problems for neighboring pixels, and the outlier pixels
themselves are replaced by a prediction of their actual value based on their
feature pass values and the neighboring pixels.

Therefore, the denoiser now also works as a smarter despeckling filter that
uses a more accurate prediction of the pixel instead of a simple average.
This can be used even if denoising isn't wanted by setting the denoising
radius to 1.
2017-05-18 21:55:56 +02:00
Lukas Stockner
b3a3459e1a Cycles Denoising: Fix wrong order of denoising feature passes 2017-05-18 21:55:56 +02:00
Lukas Stockner
9586cc4708 Cycles: Cleanup MultiGGX closure implementation
The implementation originally handled four different cases:
Regular glossy, glass, metallic fresnel glossy and diffuse.

However, only the first two are actually used currently. Therefore, this commit
removes the other two, which allows to simplify the code.

Additionally, due to the Principled BSDF, the function arguments are now
identical for glossy and glass, which allows to get rid of some ugly #ifdefs.
2017-05-18 21:55:56 +02:00
Sergey Sharybin
49bd3d3a1a Cycles: Fix crash loading single channel texture
Was  typo in recent isfinite check.
2017-05-18 15:49:03 +02:00
Pascal Schoen
32c9d2322c Fix T51408: Cycles - Principled BSDF Shader - Transparency is not working as expected
Renamed the "Transparency" input of the Principled BSDF to
"Transmission" and "Refraction Roughness" to "Transmission Roughness".
2017-05-18 13:18:19 +02:00
Sergey Sharybin
c4d122e305 Cycles: Optimize expansion of headers in the source
Use smarter check of where the file is coming from instead of
attempting to replace same source twice with different settings.

Brings down processing time from 3.6sec to 1.8sec.
2017-05-17 17:26:35 +02:00
Sergey Sharybin
9a910443c4 Fix compilation error in Cycles
Was caused by recent fix with finite checks.

Fixes T51536.
2017-05-17 17:23:32 +02:00
Sergey Sharybin
1d49205b1a Fix T51529: Black boxes on a denoising render when using a .exr image as a environmental texture
It is caused by NaN value in the input texture. Now we check for all the pixels
having proper finite values.

Should also help here in the studio,
2017-05-17 15:29:47 +02:00
Sergey Sharybin
cc2755b443 Revert "Cycles: Fix wrong shading on GPU when background has NaN pixels and MIS enabled"
This reverts commit 581c81901363176b1ce775472ea7c9f97ee504a9.

Seems we do need to do finite check early on, this is incoming.
2017-05-17 15:06:05 +02:00
Hristo Gueorguiev
40e6f65ea1 Fix T50937: baking with OpenCL and CPU have slightly different brightness
OpenCL baking with SSS and Volume are not supported.
2017-05-17 12:24:16 +02:00
Mai Lavelle
966a2681f9 Cycles: Fix building with native only option
Approach suggested by Lukas S.
2017-05-16 16:05:04 -04:00
Mai Lavelle
e14a2e87dc Revert "Cycles: Fix native only kernel since denoiser commit"
Fix didn't work in debug mode due to undefined references.

This reverts commit 53195715119e294e1a0d89831ebab716c9f7fee6.
2017-05-16 16:03:27 -04:00
Sergey Sharybin
5319571511 Cycles: Fix native only kernel since denoiser commit 2017-05-15 18:37:33 +02:00
Sergey Sharybin
ef8ad66aa2 Fix T49324: True displacement crashes when shader returns NaN 2017-05-15 15:45:19 +02:00
890d871bc3 Fix T51314: crash cancelling Cycles bake during scene sync and update. 2017-05-13 07:15:25 +02:00
Hristo Gueorguiev
90b9467861 Cycles: fix AO approximation for split kernel 2017-05-11 11:58:25 +02:00
Lukas Stockner
58a0c27546 Cycles: Fix occasional black pixels from denoising with excessive radii
Numerical inaccuracies would cause the XtWX matrix to be no longer
positive-semidefinite, which in turn caused the LSQ solver to fail.
2017-05-11 03:21:54 +02:00
Sergey Sharybin
4d38932cb4 Cycles: Use more stable version of integer square root function
Old code was working quite unreliable in combination with fast math
flag, especially when compiling with Clang. It seems we were hitting
result of the following bug submitted to Clang [1].

Basically, it was happening so that (int)sqrtf(64) was 7 when Cycles
is built with Clang but was correct 8 when built with GCC.

This commit works this around. Annoying, but don't see other way to
keep sampling pattern the same for Clang and GCC.

[1] https://bugs.llvm.org//show_bug.cgi?id=24063
2017-05-09 17:07:17 +02:00
Sergey Sharybin
e20eb2dec0 Cycles: Properly free memory used by KernelGlobals
Previous logic did not free memory used by vector classes
which were storing images, causing memory leaks.
2017-05-09 17:07:17 +02:00
Jens Verwiebe
98ab2c682d Fix denoiser tooltip 2017-05-09 14:44:59 +02:00
Sergey Sharybin
06b2f10ad1 Cycles: Enable BPT for NVidia OpenCL 2017-05-09 11:44:18 +02:00
Sergey Sharybin
49523c4d0e Cycles: Fix compilation error with gcc-6.3.0 and debug mode 2017-05-08 15:41:28 +02:00
Lukas Stockner
e518ea9b5e Cycles: Fix transform addressing in the denoiser code 2017-05-07 18:50:24 +02:00
lazydodo
c9451f1cff [Cycles] Fix math problems in safe_logf
log(0) is undefined and should not have been included
log(1) == 0, dividing by zero is not recommended
2017-05-07 09:16:14 -06:00
Lukas Stockner
43b374e8c5 Cycles: Implement denoising option for reducing noise in the rendered image
This commit contains the first part of the new Cycles denoising option,
which filters the resulting image using information gathered during rendering
to get rid of noise while preserving visual features as well as possible.

To use the option, enable it in the render layer options. The default settings
fit a wide range of scenes, but the user can tweak individual settings to
control the tradeoff between a noise-free image, image details, and calculation
time.

Note that the denoiser may still change in the future and that some features
are not implemented yet. The most important missing feature is animation
denoising, which uses information from multiple frames at once to produce a
flicker-free and smoother result. These features will be added in the future.

Finally, thanks to all the people who supported this project:

- Google (through the GSoC) and Theory Studios for sponsoring the development
- The authors of the papers I used for implementing the denoiser (more details
  on them will be included in the technical docs)
- The other Cycles devs for feedback on the code, especially Sergey for
  mentoring the GSoC project and Brecht for the code review!
- And of course the users who helped with testing, reported bugs and things
  that could and/or should work better!
2017-05-07 14:40:58 +02:00
Sergey Sharybin
2eb906e1b4 Cycles: Fix access array index of -1 in SSS and volume split kernels 2017-05-05 17:54:03 +02:00
Sergey Sharybin
850bb7a50b Cycles: Cleanup, indentation 2017-05-05 16:54:37 +02:00
Hristo Gueorguiev
8b97e42eca Cycles: Split kernel SSS & Volume data definitions cleanup 2017-05-05 13:42:26 +02:00
Hristo Gueorguiev
b9fda4480f Cycles: Show samples progress for OpenCL split kernel 2017-05-05 13:37:21 +02:00
Hristo Gueorguiev
f3c3483242 Cycles: Workaround for AMD GPU OpenCL compiler
Fix for SSS in BPT.
2017-05-05 13:00:43 +02:00
Pablo Vazquez
d29e3ebcc6 Typo: 'Signle program' -> 'Single program' 2017-05-04 22:15:53 +02:00
Lukas Stockner
ed688e4843 Cycles: Fix crash when assigning KernelGlobals
The memory isn't initialized during allocation, so calling the assignment operator is a bad idea.
2017-05-04 20:49:04 +02:00
Sergey Sharybin
a523dfd2fd Fix T51412: Instant crash with texture plugged into the Displacement output
The issue was caused by unlimited textures commit, root of the issue is that
displacement code updates some of the image slots directly, so it needs to
ensure device vectors are all proper size.
2017-05-04 16:28:22 +02:00
Sergey Sharybin
5fde78dcad Cycles: Fix unused argument warning when building without debug passes 2017-05-04 09:33:51 +02:00