Commit Graph

2925 Commits

Author SHA1 Message Date
Sergey Sharybin
21f31e6054 Fix T47856: Cycles problem when running from multi-byte path
This is a mix of regression and old unsupported configuration.

Regression was caused by some checks added on Blender side which was
checking whether python function returned error or not. This made it
impossible to enable Cycles when running from a file path which can't
be encoded with MBCS codepage.

Non-regression issue was that it wasn't possible to use pre-compiled
CUDA kernels when running from a path with non-ascii multi-byte
characters.

This commit fixes regression and CUDA parts, but OSL still can't be
used from a non-ascii location because it uses non-widechar API to
work with file paths by the looks of it. Not sure we can solve this
just from our side by using some codepage trick (UTF-16?) since even
oslc fails to compile shader when there are non-ascii characters in
the path.
2016-03-23 13:58:31 +01:00
Sergey Sharybin
b20f12d835 Cycles: Some typo fixes 2016-03-12 15:01:20 +05:00
Sergey Sharybin
d652833a17 Cycles: Support parallel convergence mode for spherical stereo 2016-03-12 15:01:20 +05:00
Sergey Sharybin
6b91fb706d Cycles: Optimize derivatives calculation by using pre-calculated dx/dy
We've got pixel-wide world-space derivatives which we can use in the
perspective camera sampling. This allows to get rid of two calls to
transform_direction() function.

In theory we can save two transform_perspective() calls if we'll also
save pre-calculated camera-space dx/dy.
2016-03-12 15:01:20 +05:00
Sergey Sharybin
a8c87bad22 Cycles: Cleanup, spherical_stereo_direction will return normalized direction
Previously each call of this function was followed by a normaliztion, now it
is done in the function itself with an according note around the function.
2016-03-12 15:01:20 +05:00
Thomas Dinges
93895420eb Cycles: Do no limit viewport samples to USHRT_MAX when value is at 0.
We don't limit manually setting higher values, this was probably overlooked here.

Found by @Blendify in IRC.
2016-03-11 21:36:07 +01:00
Sergey Sharybin
758b20b8ca Cycles: One more optimization fix, derivatives used to be calculated without aperture
At this point it's totally unclear why we're ignoring aperture and and rolling shutter
now for derivatives calculation but do not ignore direction change caused by stereo.
2016-03-11 15:23:31 +05:00
Sergey Sharybin
e7eb91365b Cycles: Fix bug calculating dP for perspective camera
Was introduced by recent optimization. Not really sure derivatives are
intended to work like this, but better to stick to what Dalai had
originally for now.
2016-03-11 14:45:35 +05:00
Sergey Sharybin
ebe306b8d2 Cycles: Cleanup, redundant normalization 2016-03-11 14:45:35 +05:00
Martijn Berger
b5b269ac11 Fix compilation of cycles standalone and network device 2016-03-11 10:00:47 +01:00
Sergey Sharybin
0922b6d6de Cycles: Fix border render after spherical stereo commit
Buffer params needs to know camera's border, otherwise it'll create full buffer.

There might be some issues with stereo camera still, but in worst case it'll
only update camera twice as far as i can tell. Not ideal, but better than no
border render at all.
2016-03-11 12:58:28 +05:00
Sergey Sharybin
814fa06851 Cycles: Optimize spherical stereo position when no spherical stereo is used 2016-03-10 22:03:03 +05:00
Sergey Sharybin
59a7204797 Cycles: Simplify perspective camera derivatives calculation
Probably some further simplification is possible, will look into this later.
Alternatively will get rid of KernelCamera.{dx, dy}.
2016-03-10 21:48:12 +05:00
Dalai Felinto
de7a8af793 Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices

The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)

Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).

* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER

* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)

* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).

* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.

* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.

* We have no support for interocular distance attenuation based on the proximity of the poles  (which helps to reduce the pole rotation effect/artifact).

THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451

This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.

All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case	 Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332

Reviewers: sergey, dingto

Subscribers: #cycles

Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
Sergey Sharybin
5adfdd965a Fix T47681: Bump node doesn't work with SSS shader when using OSL 2016-03-07 15:32:46 +05:00
Sergey Sharybin
3d3d491d40 Cycles: Fix wrong default value for volume samples 2016-03-02 14:53:36 +05:00
Sergey Sharybin
87c8ff0164 Cycles: Fix compilation error of certain OpenCL split kernels 2016-02-28 16:53:38 +01:00
Thomas Dinges
79c8eed843 Cleanup: Update Cycles standalone copyright info. 2016-02-27 13:07:32 +01:00
Sergey Sharybin
b6d9cbe654 Cycles: Fix bug in CMJ pattern when number of samples is 1
It was wrongly considering 1 is a power of 2. While it is a correct thing
(1 == 2^0) it's not what the math in some later formulas expects.
2016-02-24 14:23:45 +01:00
Lukas Stockner
c359343f8d Fix T43388, fix T40369: Cycles baking not antialiasing textures.
This re-enables the AA jittering, but with proper clamping so that u >= 0,
v >= 0 and u+v <= 1.

Differential Revision: https://developer.blender.org/D1254
2016-02-21 15:10:51 +01:00
Sergey Sharybin
b30ab24fb8 Cycles: Avoid re-definition of math cnstants with MSVC 2016-02-20 14:06:05 +05:00
3c4f971392 Workaround for T47213: branched path sampling issues with CUDA 7.5. 2016-02-19 00:49:24 +01:00
Sergey Sharybin
da81227e54 Cycles: Fix wrong sample all direct/indirect settings on sm_50 and higher
Seems to be some compiler fault which leads to a wrong flag being used,
making it so wrong number of samples is used for the background.

This should in theory fix issue reported in T47213.
2016-02-18 16:29:35 +01:00
Lukas Stockner
a8fe3a1cee Fix T47461: Different results on CPU and GPU when using Branched Path Tracing
The issue here was actually somewhere else - the attached scene from the report used a light falloff node in a sunlamp (aka distant light).
However, since distant lamps set the ray length to FLT_MAX and the light falloff node squares this value, it overflows and produces a NaN
weight, which propagates and leads to a NaN intensity, which is then clamped to zero and produces the black pixels.

To fix that issue, the smoothing part of the light falloff is just ignored if the smoothing term isn't finite (which makes sense since
the term should converge to 1 as the distance increases).
The reason for the different results on CPUs and GPUs is not perfectly clear, but probably can be explained with different handling of
Inf/NaN edge cases.

Also, to notice issues like these faster in the future, kernel_asserts were added that evaluate as false as soon as a non-finite intensity is produced.
2016-02-18 01:23:38 +01:00
Sergey Sharybin
8cab327316 Cycles: Make CUDA 7.5 officially recommended
This was a hard decision, because going newer CUDA toolkit makes
rendering up to 5% slower. But on another hand, it solves major
speed regressions (up to 30%) with branched path tracing on a
top level cards.

Neither of those regressions have a meaningful and sane workaround
from the code itself.

Toolkit 6.5 could still be used, but it's no longer recommended one.
2016-02-17 15:18:56 +01:00
Sergey Sharybin
3857b4600f Cycles: Don't silence unused macro, remove the macro instead
It's not really handy to silence something unused hoping for it'll be
used in the future. We can end up with quite some silencing then.

Also made this flag which i find rather useless to NOT cause -Werror
in Cycles code.
2016-02-17 12:40:56 +01:00
Campbell Barton
d4e5e94ec7 Cleanup: unused define warning 2016-02-17 21:39:23 +11:00
Campbell Barton
88d4d0d070 Cleanup: OSL style 2016-02-17 21:39:23 +11:00
Sergey Sharybin
d6b77450ce Fix T47447: Cycles crash when reaching texture limit with 3D textures 2016-02-17 11:43:03 +01:00
Lukas Stockner
8d95178c0b Fix T47411: Cycles portals luminance artifacts
When using multiple portals, scene areas behind one of the portals were rendered darker than they should.
The reason for that is a pretty stupid mistake: Since portals are only used at positions that aren't behind them,
only portals that are used should be accounted for in the PDF calculation. That was actually the case, but the final
divide incorrectly divided by the total amount of portals, not the amount of visible ones.

Another issue with areas behind portals was the PDF evaluation function.
The new evaluation code is shorter, simpler and fixes this issue.

Also, the threshold for the distance check was increased to avoid artifacts where portals touch a surface.
2016-02-17 03:06:30 +01:00
0ccae52394 Fix OpenCL kernel build errors after recent 3D texture changes. 2016-02-17 01:38:55 +01:00
833eb863eb Fix (harmless) assert in BVH spatial splits with Visual Studio debug builds. 2016-02-17 00:07:35 +01:00
Sergey Sharybin
480b814e02 Cycles: Remove back some tweaks for inline policies
While kernel compiles fine, it seems generated binary is not really correct.
2016-02-16 17:25:58 +01:00
Sergey Sharybin
d0246d5f30 Cycles: Some cleanup, should be no functional changes
Addressing meaningful feedback from coverity.
2016-02-16 15:33:00 +01:00
Sergey Sharybin
63b60be6d7 Fix T47427: Crash caused by OSL 2016-02-16 13:38:07 +01:00
Thomas Dinges
ab5417870d Cleanup: Typo. 2016-02-16 13:00:44 +01:00
Sergey Sharybin
c5e1781944 Cycles: Fix crash when trying to render after re-enabling the addon 2016-02-16 12:47:31 +01:00
Sergey Sharybin
1c4f21f85e Cycles: Initial support of 3D textures for CUDA rendering
Supports both smoke/fire and point density textures now.

Reduces number of textures available for sm_20 and sm_21, but you have
to compromise somewhere on such a limited hardware.

Currently limited to linear interpolation only, and decoupled ray
marching is not supported yet. Think those could be considered just a
further improvement.

Some quick example:

  https://developer.blender.org/F282934

Code is minimal and we can fully consider it a fix for missing
support of 3D textures with CUDA.

Reviewers: lukasstockner97, brecht, juicyfruit, dingto

Reviewed By: brecht, juicyfruit, dingto

Subscribers: mib2berlin

Differential Revision: https://developer.blender.org/D1806
2016-02-15 21:26:29 +01:00
Martijn Berger
b5171e250c Make cycles standalone link again 2016-02-15 21:00:25 +01:00
Sergey Sharybin
c93069083e Cycles: Tweaks for 32bit CUDA binaries
Tweak some inline policies. Not totally crazy yet, and in fact we now
have one less ifdef statement now.
2016-02-15 19:11:02 +01:00
Sergey Sharybin
1336e97b12 Cycles: Use CUDA_64_BIT_DEVICE_CODE to detect which CUDA architecture to use
It is initialized based on size of pointer, which matches our previous
behavior, but using it in Cycles side allows to cross-compile CUDA
binaries.
2016-02-15 19:08:36 +01:00
Sergey Sharybin
06743f4018 Cycles: Make guarded allocator compatible with MSVC2015 2016-02-15 18:33:36 +05:00
Sergey Sharybin
6371fccdbe Cycles: Fix guarded allocator issues on Windows
The issue was caused by static vectors allocating some internal
data using rebound element allocator for them, which was causing
access to a non-initialized statistics objects and was failing a
lot when switching Blender to a fully guarded allocation.

Additionally, we were not able to free that internal memory before
Blender exits, which was causing false-positive memory leak prints.

Now we're not using GuardedAllocator for those proxy containers.

Ideally this should be done as a GuardedAllocator::rebind, but
it didn't work for vector<bool> because it seems some internal
parts are converting bool to char32_t, which either makes it so
we can't use GuardedAllocator for those vectors or the compiler
get's confused when we're trying explicitly allow GuardedAllocator
for rebind<char32_t>.

This with current approach we should be fine for the release.
2016-02-15 11:46:13 +01:00
Sergey Sharybin
7d85da882b Cycles: Fix infinite recursion of md5 calculation on Windows
Was caused by some safety things of making sure we've for NULL
terminator for the buffer when doing mbs<->wcs conversion, but
it turns out this simply confuses str::string and it can no
longer have proper .size(). Let's assume behavior of string
allocation is same all over the std, and we can avoid having
that extra null-terminator allocated.
2016-02-14 21:08:11 +05:00
Thomas Dinges
6a593aba44 Cleanup: Move Cycles sky model data to util. 2016-02-13 13:41:40 +01:00
Sergey Sharybin
d1dd893487 Cycles: Remove meaningless expression 2016-02-13 13:29:50 +01:00
Sergey Sharybin
89b1f042cf Cycles: Fix compilation error on Windows 2016-02-13 13:29:13 +01:00
Sergey Sharybin
69dc0c3192 Cycles: Fixes for Burley BSSRDF
There are several fixes in here, which hopefully will make the shader
working correct without too much magic in there.

First of all, this commit brings BURLEY_TRUNCATE down from 30 to 16
which reduces noise a lot. It's still higher than original truncate
from Brecht, but this reduces PDF value at a cutoff distance by an
order of magnitude (now it's 0.008387, previously it was 0.063521
for the albedo of 0.8 and radius 1.0). This should converge to a
proper result faster and don't have artifacts.

This kind of reverts fix for T47356, but after additional thinking
came to conclusion Burley is not being totally smooth, it is about
giving less waxy results which it's kind of doing in the file.

Second of all, this commit fixes burley_eval() to use normalized
diffusion reflectance. This matches the way we calculate CDF and
solves numeric instability close to 0, making PDF profile looking
closer to other SSS profiles:

  https://developer.blender.org/F282355
  https://developer.blender.org/F282356
  https://developer.blender.org/F282357

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D1792
2016-02-13 13:29:13 +01:00
Thomas Dinges
83dc288689 Cleanup: Remove some OIIO code for versions prior to 1.5. 2016-02-13 13:21:47 +01:00
Sergey Sharybin
ae635771b2 Cycles: Fix crash caused by the guarded allocation commit
C++ requires specific alignment of the allocations which was not an
issue when using GCC but uncovered issue when using Clang on OSX.
Perhaps some versions of Clang might show errors on other platforms
as well.
2016-02-13 12:35:33 +01:00