Commit Graph

2733 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
Thomas Dinges
a3d774e4c9 Cycles: Fold Value and RGB node as well.
This way, connecting Value or RGB node to e.g. a Math node will still allow folding.

Note: The same should be done for the ConvertNode, but I leave that for another day.
2015-12-06 23:47:38 +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
6552d5bebd Cycles: Avoid recursion when doing constant fold
This reduces stress on the the stack memory which could be really handy
on certain operation systems which applies strict limits on the stack.

Reviewers: brecht, juicyfruit, dingto

Reviewed By: brecht, juicyfruit, dingto

Differential Revision: https://developer.blender.org/D1656
2015-12-02 16:19:39 +05: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
Thomas Dinges
e5e1010919 Cleanup: Remove some more code for BVH cache. I missed that somehow. 2015-12-01 18:17:28 +01:00
Lukas Stockner
8512e284a0 Fix T46906: Cycles syntax error while compiling OpenCL kernels
The safe normalization was using a float as a condition, now the intended non-zero test is explicit.
2015-12-01 13:53:29 +01:00
Sergey Sharybin
607150d058 Fix T46898: OpenCL Fails to compile after recent SSS changes 2015-12-01 13:55:40 +05:00
Campbell Barton
5bfc32bab4 Cleanup: warning w/ unknown define 2015-11-30 11:03:49 +11:00
Sergey Sharybin
2ae7593700 Cycles: Avoid having two consequence getenv() calls 2015-11-28 21:05:12 +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
bbd33b3a8e Cycles: Create proper sockets for OSL script nodes
Previously render nodes will be always created with just a VECTOR socket
type and then those sockets will try to be set as all point, vector and
normal to work around lack of such a subtype distinguishing in blender.

This change makes it so subtype is being queried from OSL itself and
proper subtupe is being used for socket.

It's still not in use for the official builds because it requires changes
applied recently on the 1.7 branch of OSL:

  https://github.com/imageworks/OpenShadingLanguage/commit/f70e58f

This solves artists confusion reported in T46117.

Reviewers: #cycles, juicyfruit

Reviewed By: #cycles, juicyfruit

Subscribers: juicyfruit

Differential Revision: https://developer.blender.org/D1627
2015-11-25 20:23:52 +05:00
Sergey Sharybin
2700ab1de1 Cycles: Whitespace cleanup from the recent changes 2015-11-25 20:15:35 +05:00
Sergey Sharybin
1bec2aa54e Cycles: Fix crash in constant folding introduced by recent commit
Graph::disconnect() actually modifies links, needs to create a copy to iterate
if disconnect happens form inside the loop.

Question tho whether we can control this somehow..

Reported by BzztPloink in IRC, thanks!
2015-11-25 20:14:01 +05:00
Thomas Dinges
e796581655 Cycles: Refactor of constant fold.
* Move constant folding from nodes to the shader graph. This way it's part of our (later) 4-step optimization process.
* Instead of only doing a one level constant fold, we can now do a recursive constant fold, allowing us to simplify shaders much further.
Constant folding is implemented for Blackbody, Math and VectorMath nodes.

Example (the highlighted nodes are removed before rendering):
Before: http://archive.dingto.org/2015/blender/code/one_level_constant_fold.jpg
Now: http://archive.dingto.org/2015/blender/code/multi_level_constant_fold.jpg

Thanks to Sergey and Brecht for Review!
Differential Revision: https://developer.blender.org/D1626
2015-11-25 13:57:54 +01:00
Sergey Sharybin
415b5a4369 Fix T46646: Point Cloud Density crashes on real time rendering
The issue was caused by possible use of object->derivedFinal from the render
thread, The patch tries to eliminate (or at least minimize, huh) amount of
access to the derivedFinal of a source object. It's still possible that in
the case of particle source derived mesh will be still unsafely used, but
with the patch applied we can easily change runtime part of the code and
cache derived mesh on the preparation stage.

Some ideas for the future:

- Check whether cache() was called on the point density node when calling
  calc().

- Cache derivedMesh in the runtime part of point density node to avoid
  possible remained thread conflicts.

- NULL the runtime part of the node on .blend load

Reviewers: campbellbarton, plasmasolutions

Reviewed By: plasmasolutions

Differential Revision: https://developer.blender.org/D1614
2015-11-25 17:43:44 +05:00
Sergey Sharybin
328208a6a6 Cycles: Fix shader update bug introduced by recent commits
Seems set_intersection() requires passing explicit comparator if non-default
one is used for the sets. A bit weird, but can't really find another explanation
here about whats' going on here.
2015-11-25 16:05:57 +05:00
Sergey Sharybin
8294452b14 Fix T46782: Updating Shaders very slow with complex nodegraph
The issue was caused by not really optimal graph traversal for gathering nodes
dependencies which could have exponential complexity with a long tree branches
connected with multiple connections between them.

Now we optimize the depth traversal and perform early output if the node was
already traversed.

Please note that this adds some limitations to the use of SVM compiler's
find_dependencies() in the cases when skip_node is not NULL and one wants to
perform dependencies find sequentially with the same set. This doesn't happen
in the code, but one should be aware of this.
2015-11-25 13:46:51 +05:00
Sergey Sharybin
443b159f02 Cycles: Ensure order of shader nodes in the dependnecies set
The issue was than nodes dependencies were stored as set<ShaderNode*> which
is actually a so called "strict weak ordered", meaning order of nodes in
the set is strictly defined, but based on the ShaderNode pointer. This means
that between different render invokations order of original nodes could be
different due to different pointers allocated for ShaderNode.

This commit makes it so dependencies and maps used for ShaderNodes are based
on the node->id which has much more predictable order. It's still possible
to trick the system by doing some crazy edits during viewport rendfer and
cause difference between viewport and final render stacks.

Reviewers: brecht

Reviewed By: brecht

Subscribers: LazyDodo

Differential Revision: https://developer.blender.org/D1630
2015-11-25 13:07:32 +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
fa6bdfd622 Cycles: Support per-render layer world AO settings
This is sort of extension of existing Use Environment option which now allows to
disable AO on the render layer basis.

Useful in cases like disabling AO for the background because it might make it
too flat and so.

Reviewers: juicyfruit, dingto, brecht

Reviewed By: brecht

Subscribers: eyecandy, venomgfx

Differential Revision: https://developer.blender.org/D1633
2015-11-24 13:21:40 +05:00
Mike Erwin
291afea8cc OpenGL: clean up use of old extensions 2015-11-24 02:21:07 -05:00
Sergey Sharybin
f021d97e8f Fix T46842: Removing World is missing AO update in viewport render 2015-11-23 17:44:52 +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
Lukas Stockner
5c5df9dc18 Cycles: Save one transform inversion in the camera sync
Summary: By calculating the Camera-to-Screen-Matrix first, one inversion can be saved in the Camera sync.
It won't really improve speed and/or precision, it's mainly a small cleanup.

Reviewers: sergey, dingto

Subscribers:
2015-11-22 00:58:40 +01: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
Sergey Sharybin
c08727ebab Cycles: Quick experiment with using feature-adaptive kernels for CUDA
Gives few percent of memory improvement for regular feature set kernel
and could give significant memory improvement for Experimental kernel.
It could also give some degree of performance improvement, but this I
didn't really measure reliably yet.

Code is ifdef-ed for now, since it's only working on Linux and requires
CUDA toolkit to be installed (other platform only use precompiled
kernels).

This is just an experiment for now and a base for the proper feature
support in the future (with runtime compilation using CUDA 7?).
2015-11-21 22:16:01 +05:00
Sergey Sharybin
f8ab3fd30f Cycles: add utility function to calculate MD5 hash of a given string 2015-11-21 22:07:59 +05:00
Sergey Sharybin
52d7bc624a Cycles: Make CUDA device internally operate with requested features
This just replaces internal argument `experimental` with `requested_features`
making it possible to access particular requested settings when building
kernels.
2015-11-21 21:49:00 +05:00
Sergey Sharybin
a106da7f1d Cycles: Move build options constructions to DeviceRequestedFeatures
This way it's easier to re-use requested features logic across multiple
device implementations.
2015-11-21 21:42:31 +05:00
Sergey Sharybin
9aafec1ce1 Cycles: Avoid multiple spaces in OpenCL build options
This should solve some compilation errors with compilation on OSX.
2015-11-21 21:33:08 +05:00
Sergey Sharybin
7e71be261b Cycles: Fix filter glossy being broken after recent changes
Basically we can not use sharp closure as a substitude when filter glossy is
used. This is because we can not blur sharp reflection/refraction.

This is quite quick and not really clean implementation. Not really happy
with manual handling of original settings, but this is as good as we can do
in the quick patch. It's a good acknowledgment and we now can re-consider
some aspects of graph simplification to make such cases more natively
supported.

P.S. This failure would have been shown by our regression tests, so please,
bother a bit to run Cycles's test sweep before doing such optimizations.
2015-11-20 18:18:27 +05:00
Thomas Dinges
eeed28fefc Fix T46818, crash with Glossy node on Windows. 2015-11-19 08:43:43 +01: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