Commit Graph

1291 Commits

Author SHA1 Message Date
Martijn Berger
de0672436b Add support for compiling the cuda kernel on the Nvidia Jetson TX1 2015-12-07 17:51:24 +01:00
Sergey Sharybin
ed5dbb0a7b Cycles: Implement extrapolation for RGB curves
Previously RGB Curves node will clamp input to 0..1 which is rather useless
when one wants to use HDR image textures and do bit of correction on them.

Now kernel code supports extrapolation of baked LUT based on first/last two
table points and performs linear extrapolation.

The only tricky part is to guess the range to bake the LUT for. Currently
it's using simple approach -- minmax of the input curves. While this behaves
ok for the simple cases it's easy to trick the system up causing incorrect
results.

Not sure we can solve those issues in a general case and since the new code
is giving more expected results it's not that bad actually. In the worst
case artist migh always create explicit point to make sure LUT is created
for the needed HDR range.

Reviewers: brecht, juicyfruit

Subscribers: sebastian_k

Differential Revision: https://developer.blender.org/D1658
2015-12-06 01:21:14 +05:00
Bastien Montagne
76d1201996 Fix OSL shaders building with some versions of that lib.
This must have happened months ago, but as I did not `make clean` any build folder since then,
so only noted that today.

Issue is same as dirty patch we have to apply to ODL sources before building it in install_deps.sh - for
some mysterious reason, it has become impossible to compoile .osl files into .oso ones without
giving explicit output file name (otherwise it just produces `.oso` file - utterly stupid and useless).

We could probably fix that in own OSL source, but think being explicit here does not hurt anyway, so...
Let's go the easy way.
2015-12-05 00:17:04 +01:00
Sergey Sharybin
d0a9ec5efc Cycles: Fix SSS object not properly reflected in glossy object with indirect clamping
This fixes remained issues reported in T46908.
2015-12-02 16:00:01 +05:00
Campbell Barton
fc9505c9c5 Cleanup: warnings & spelling 2015-12-02 13:15:52 +11:00
Sergey Sharybin
a6bbf05ba6 Cycles: Fix wrong SSS intersection refinement when this option is disabled
The code is disabled by default, but we'd better keep it all correct.
2015-12-02 03:14:54 +05:00
Sergey Sharybin
e82876589f Cycles: Fix wrong SSS on scaled instanced objects
Was a mistake on searching refined position form ray and hit distance.

Remember kids: SSS distance is in the object space!
2015-12-02 03:13:19 +05:00
Sergey Sharybin
70502578b1 Cycles: Remove TODO, it is possible there'll be more intersections recorded
It's just only few of them will be stored in the intersection array, nothing
wrong with that what's so ever.
2015-12-02 02:39:57 +05:00
Sergey Sharybin
607150d058 Fix T46898: OpenCL Fails to compile after recent SSS changes 2015-12-01 13:55:40 +05:00
Sergey Sharybin
6147c4037d Cycles: Fix wrong volume stack after SSS bounce
Was introduced by a recent fixes, now it should be all correct and additionally
it solves the TODO mentioned in the code.
2015-11-28 20:07:34 +05:00
Sergey Sharybin
f5d1551b6e Cycles: Fix wrong original ray used for SSS baking
Also de-duplicated some code by moving to an utility function.
2015-11-28 20:07:34 +05:00
Sergey Sharybin
1e43f0d742 Cycles: Set of fixes for delayed SSS ray tracing
There were multiple issues which are solved now:

- It was possible that ray wouldn't be bounced off the BSSRDF, for example
  when PDF or shader eval is zero. In this case PathState might have been
  left in pre-bounced state which would have been gave incorrect shading
  results.

  This is solved by having separate PathState for each of the hits.

- Path radiance summing wasn't happening correct as well, indirect rays
  were using wrong path radiance in the case when there were more than
  one hit recorded.

  This is now using a bit trickier state machine which calculates path
  radiance for just SSS (both direct and indirect) and then sums it back
  to the final radiance.

- Previous commit wasn't totally correct either and was an induced bug
  due to wrong path state left from the "un-happened" ray bounce.

  There should be no special case happening here, BSSRDFs will be replaced
  with diffuse ones due to PATH_RAY_DIFFUSE_ANCESTOR flag.

- Merged back codebases for "delayed" and "immediate" indirect SSS ray
  tracing, hopefully making it easier to maintain the codebase.

Sure this changes brings memory usage back by about 4-5%, but overall
it's still about 2x memory reduction for the experimental kernel here.

Thanks Brecht for the review!
2015-11-28 20:07:34 +05:00
Sergey Sharybin
8919ed3a62 Cycles: Fallback to diffuse BSDF for the indirect SSS rays when BSSRDF is hit
This is actually how it was intended to work, just didn't notice it wasn't
really happening in the main ray loop.

Solves some memory issues reported in T46880.
2015-11-28 20:07:34 +05:00
Sergey Sharybin
299fae1838 Cycles: Fix missing indirect subsurface initialization in the bake code 2015-11-28 20:07:34 +05:00
Sergey Sharybin
20fc9c00fd Cycles: Fully roll-back to non-delayed SSS indirect rays for CPU
There are some issues to be solved with the recent optimization we did for
the indirect rays for the SSS. Those issues will take a bit of a time to
be fully solved still and we need to unlock Caminandes team now, so let's
revert some changes back.

CUDA will still use delayed indirect rays since it's an experimental
feature.

For the details about what's to be done still please refer to T46880.
2015-11-27 17:15:02 +05:00
Sergey Sharybin
175f00c89a Revert "Cycles: Fix wrong SSS with regular path tracing and clamping enabled"
This wasn't really a complete fix and only worked if there was a single scatter
event recorded only. Proper fix requires some more thoughts to make it correct
without memory use increase.

This reverts commit bf9e88bfbebaf5c6228363560970fa526e779c8b.
2015-11-27 17:15:02 +05:00
Sergey Sharybin
bf9e88bfbe Cycles: Fix wrong SSS with regular path tracing and clamping enabled
Radiance sum and reset was happening in different order after 26f1c51.

This is a quick fix to unlock Caminandes team, perhaps we can avoid having
separate variable to detect when radiance is to be sum.
2015-11-26 16:11:41 +05:00
Stefan Werner
c8a041f489 Fix T46760: Branched Path Tracing converges to different result than plain Path Tracing
Multiple importance sampling for branched path tracing light samples needs to be
calculated separately per BSDF, not with Veach's one sample model.
2015-11-26 14:59:58 +05:00
Sergey Sharybin
de35827612 Cycles: Fix wrong volume stack update with SSS object intersecting the volume
There's no need in moving ray at all, stack should always be updated from the
original hit point to the scattered one.
2015-11-25 13:01:22 +05:00
Sergey Sharybin
26f1c51ca6 Cycles: Trace indirect subsurface rays by restarting the integrator loop
This gives much lower stack usage on GPU and reduces kernel memory size to
around 448MB on GTX560Ti (comparing to 652MB with previous commit and 946MB
with official release). There's also a barely measurable speedup of around
5%, but this is to be confirmed still.

At this stage we're using only ~3% for the experimental kernel and SSS
rendering seems to be faster by 40% and after some further testing we might
consider making SSS and CMJ official features and remove experimental
precompiled kernels.
2015-11-25 13:01:22 +05:00
Sergey Sharybin
2a5c1fc9cc Cycles: Delay shooting SSS indirect rays
The idea is to delay shooting indirect rays for the SSS sampling and
trace them after the main integration loop was finished.

This reduces GPU stack usage even further and brings it down to around
652MB (comparing to 722MB before the change and 946MB with previous
stable release).

This also solves the speed regression happened in the previous commit
and now simple SSS scene (SSS suzanne on the floor) renders in 0:50
(comparing to 1:16 with previous commit and 1:03 with official release).
2015-11-25 13:01:22 +05:00
Sergey Sharybin
8bca34fe32 Cysles: Avoid having ShaderData on the stack
This commit introduces a SSS-oriented intersection structure which is replacing
old logic of having separate arrays for just intersections and shader data and
encapsulates all the data needed for SSS evaluation.

This giver a huge stack memory saving on GPU. In own experiments it gave 25%
memory usage reduction on GTX560Ti (722MB vs. 946MB).

Unfortunately, this gave some performance loss of 20% which only happens on GPU.
This is perhaps due to different memory access pattern. Will be solved in the
future, hopefully.

Famous saying: won in memory - lost in time (which is also valid in other way
around).
2015-11-25 13:01:22 +05:00
Sergey Sharybin
56ead9d34b Cycles: Make branched path tracer covered with requested features
This gives few percent extra memory saving for the CUDA kernel when
using regular path tracing.

Still more like an experiment, but will be handy in the future.
2015-11-22 13:54:51 +05:00
Sergey Sharybin
f547bf2f10 Cycles: Make requested features struct aware of subsurface BSDF
This way we'll be able to disable SSS for the scene-adaptive kernel.
2015-11-21 23:00:29 +05:00
Lukas Stockner
8dea06565f Cycles: Add Blackman-Harris filter, fix Gaussian filter
This commit adds the Blackman-Harris windows function as a pixel filter to Cycles. On some cases, such as wireframes or high-frequency textures,
Blackman-Harris can give subtle but noticable improvements over the Gaussian window.
Also, the gaussian window was truncated too early, which degraded quality a bit, therefore the evaluation region is now three times as wide.
To avoid artifacts caused by the wider curve, the filter table size is increased to 1024.

Reviewers: #cycles

Differential Revision: https://developer.blender.org/D1453
2015-11-18 20:50:06 +01:00
Sergey Sharybin
537bd0eb51 Fix T46671: Cycles assert with CMJ sample function
With current formulation of cmj_fast_div_pow2() it should always return 0
in the case of first argument is zero and no assert really needed anymore.
2015-11-03 18:49:27 +05:00
Sergey Sharybin
9bce104c8c Cycles: Partially revert previous commit
Apparently removing kernel arguments broke NVidia OpenCL.

Needs more investigation, for the time being revering changes which caused problem.
2015-11-01 21:01:12 +05:00
Sergey Sharybin
dc9e0b819b Cycles: Remove unused argument from the split kernel functions
Should be no functional changes, just simplifies operation with kernels.
2015-11-01 17:22:42 +05:00
Sergey Sharybin
84e8b05e97 Cycles: Minor code style cleanup 2015-11-01 15:40:17 +05:00
Sergey Sharybin
a43e087fb8 Cycles: Add split kernel headers to project generation 2015-10-31 04:08:19 +05:00
Sergey Sharybin
cb1cb63d40 Cycles: Fixes for few typos in OpenCL kernel 2015-10-30 23:31:24 +05:00
Sergey Sharybin
537f41250f Cycles: Fix typo in split kernel
Shadow blocked kernel was using wrong array for storing intersection.
2015-10-29 21:52:56 +05:00
Sergey Sharybin
4ca688a963 Cycles: OpenCL split kernel cleanup, move casts from .h files to .cl files
Ideally we shouldn't use char* at all, but for now we have to, so at least
let's assume common .h files are free from pointer magic.
2015-10-29 21:52:56 +05:00
Sergey Sharybin
6a529e14f4 Cycles: Support user-defined shutter curve
Previously shutter was instantly opening, staying opened for the shutter time
period of time and then instantly closing. This isn't quite how real cameras
are working, where shutter is opening with some curve. Now it is possible to
define user curve for how much shutter is opened across the sampling period
of time.

This could be used for example to make motion blur trails softer.
2015-10-28 02:43:06 +05:00
Thomas Dinges
aa49c16bd9 Cleanup: Avoid some warnings on OS X with clang and update comment. 2015-10-26 11:52:24 +01:00
Sergey Sharybin
47b1279762 Cycles: Watertight fix for SSS intersection
Same as previous commit, just was missing in there.
2015-10-22 22:10:40 +05:00
Sergey Sharybin
f84cbae43e Cycles: Fix for watertight intersection
It was possible to miss some intersection caused by wrong barycentric
coordinates sign.

Cases when one of the coordinate is zero and other are negative was not
handled correct.
2015-10-22 22:07:28 +05:00
Sergey Sharybin
3f4c0612fe Fix T45058: Cycles hair shader reflects incorrectly for meshes
The issue was caused by non-continuous tangent space calculated for triangles.

This commit adds a Tangent input to Hair BSDF node which can be used to hook up
Tangent calculated form UV as an input to the node in order to make sure the
tangent space is continuous.

Doing this as an input instead of using default tangent layer from UV because of
several reasons:

- This way it's really easy to preserve compatibility with existing setups.

- Default UV map is not necessarily giving continuous space, one might want to
  use other tangent space sources or distort the space for some artistic
  decision.

Reviewers: juicyfruit, dingto

Reviewed By: dingto

Differential Revision: https://developer.blender.org/D1428
2015-10-11 19:43:30 +05:00
b098609186 Fix various compiler warnings. 2015-10-10 17:35:30 +02:00
Sergey Sharybin
b54447c0eb Cycles: Make sure ray direction is always normalized
Ray direction is assumed to be normalized in such areas as scaling intersection
distance on instance push/pop when doing ray-scene intersection, but it was
possible that some closures wouldn't give normalized direction which could cause
wrong intersection checks.

Now normalization will happen on surface bounce, which could be a bit of a waste
if closure actually gives normalized direction, but currently only transparent
BSDF seems to give guaranteed normalized direction.
2015-10-09 15:58:03 +05:00
Sergey Sharybin
29247a7a05 Cycles: Fix wrong intersection with motion blur and degenerate object transform 2015-10-09 15:58:03 +05:00
Sergey Sharybin
8fa4fccec4 Cycles: Fix intersection issues caused by degenerate instance matrix
Issue was caused by wrong intersection distance scaling on instance pop,
which could cause intersection distance to become zero, confusing following
intersection checks.
2015-10-09 15:58:03 +05:00
Sergey Sharybin
350cf8ea7f Cycles: Cleanup, whitespace around keywords 2015-10-08 19:08:28 +05:00
Lukas Stockner
e3abcd6723 Cycles: Add an interpolation option to environment textures
This commit exposes the interpolation parameter for environment textures (requested by DolpheenDream on IRC), just as it already is for image textures.

Reviewers: sergey

Differential Revision: https://developer.blender.org/D1544
2015-10-08 15:45:45 +02:00
Sergey Sharybin
91f1886b8e Fix T46352: Cycles fails to render when material contains UV mapped texture as volume input 2015-10-05 14:45:03 +05:00
Sergey Sharybin
518d68fae0 Cycles: Add some TODO comments about derivatives 2015-10-05 12:54:05 +05:00
Sergey Sharybin
a771e27b84 Cycles: Fix for builtin textures when linking against OSL 1.6.8
Issue was caused by changed function signature. This is still not really full
support of new OSL API since we don't store anything in the derivatives which
could confuse mipmapping.
2015-10-05 12:52:07 +05:00
Sergey Sharybin
2a2e12772c Cycles: Remove redundant coordinate clipping in voxel SVM node
It is now handled via texture extension type.
2015-10-05 12:41:16 +05:00
Sergey Sharybin
d784568805 Cycles: Fix missing z-coordinate check in volume sampling 2015-10-05 12:40:50 +05:00
Sergey Sharybin
0ec814c91d Cycles: Support building with latest OSL-1.7dev
So now the following OSL versions are supported (at least for compilation):

- 1.5 with closure alignment patch applied
- 1.6.8 release
- 1.7 development version from latest git
2015-09-23 12:27:02 +05:00