Commit Graph

310 Commits

Author SHA1 Message Date
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
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
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
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
de7b7572c2 Fix T46030: Strange behavior of Cycles Brick Texture
Added some extra seed to the hash, so it's now less likely to give repetitive
patters at values around zero.

This will change distribution of bricks for existing files. but it's something
inevitable.
2015-09-18 17:32:17 +05:00
Sergey Sharybin
f387fe2b65 Cycles: Fix for uninitialized closure data
This might confuse closure merger.

Spotted by Campbell Barton, thanks!
2015-09-03 13:48:43 +05:00
Campbell Barton
2672ee77a0 Cleanup: spelling/style 2015-08-23 21:12:48 +10:00
Lukas Stockner
4737b12462 Cycles: Fix issue in closure merge function.
* Did not check data2, this partially fixes T45583.
* Initialize data2 in some closures to avoid potential problems.

Differential Revision: https://developer.blender.org/D1436
2015-07-29 22:04:36 +02:00
Sergey Sharybin
7ae44e8a30 Cycles: Workaround for sm_50 on 32bit platform
Basically this commit totally disables new SVN Voxel node, which solves some
of the compiler's issues.
2015-07-21 10:18:04 +02:00
Sergey Sharybin
faeac63f68 Cycles: Fix compilation of OpenCL kernel after point density commit 2015-07-18 23:10:46 +02:00
Sergey Sharybin
7d10798af2 Cycles: Add voxel texture sampler shader node
The idea of this node is to sampling of 3D voxels at a given coordinate
supporting different mapping strategies (world space mapping, object
local space etc).

Currently not in use, it's a preparation step for supporting point density
textures.
2015-07-18 22:09:20 +02:00
Sergey Sharybin
d3e16df4f1 Cycles: Solve possible buffer overrun when using too much closures
Glass BSDF was doing some magic with copying weigths from initial closure
onto refraction one and the code was not checking properly for the number
of closures.
2015-06-13 18:51:48 +02:00
Sergey Sharybin
f0a0b1eaac Cycles: Assert in the cases when SVM node was not handled
This will help figuring out cases when node was not properly handled by the SVM
by aborting execution on CPU, where all the nodes are expected to be supported.
2015-06-01 19:49:52 +05:00
Sergey Sharybin
ecd4ee75af Cycles: Implement selective nodes compilation
This commits finishes initial selective nodes compilation into kernel, which
helps a lot performance-wise for AMD OpenCL kernels.

Split by node groups is based on statistics from simple scenes like BMW and
more complex scenes like mango and gooseberry production files. Further
tweaks are always possible, but it should be a good starting point.

TODO: Still need to ignore unused nodes when calculating requested shader
features.
2015-06-01 19:49:52 +05:00
Sergey Sharybin
c0235da53c Cycles: Fix some typos in the selective modes compilation 2015-06-01 19:49:52 +05:00
Sergey Sharybin
4d8cf1329d Cycles: Add bump feature for selective nodes compilation
For now it is unused in the kernel, actual usage will come with
the next commits.
2015-06-01 19:49:52 +05:00
Thomas Dinges
46d8bcb617 Cleanup: Remove unused Noise Basis texture code.
Same as last commit, code is unused and this one actually would have required some fixes,
as these variants output values outside the 0-1 value range, which doesn't fit Cycles shader design.
2015-05-28 01:07:37 +02:00
Thomas Dinges
20f6a0f2d7 Cleanup: Remove unused Voronoi texture code.
Let's finally delete this code, after 4 years of being unused,
there really is no excuse anymore.

If we decide to extend the procedural textures in SVM, we can do this anytime in the future.
2015-05-28 00:36:33 +02:00
George Kyriazis
7f4479da42 Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.

Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.

Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.

This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.

More feature will be enabled once they're ported to the split kernel and
tested.

Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.

Based on the research paper:

  https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf

Here's the documentation:

  https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit

Design discussion of the patch:

  https://developer.blender.org/T44197

Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:52:40 +05:00
Sergey Sharybin
6fc1669679 Cycles: Initial work towards selective nodes support compilation
The goal is to be able to compile kernel with nodes which are actually needed
to render current scene, hence improving performance of the kernel,

The idea is:

- Have few node groups, starting with a group which contains nodes are used
  really often, and then couple of groups which will be extension of this one.

- Have feature-based nodes disabling, so it's possible to disable nodes related
  to features which are not used with the currently used nodes group.

This commit only lays down needed routines for this approach, actual split will
happen later after gathering statistics from bunch of production scenes.
2015-05-09 19:22:16 +05:00
Sergey Sharybin
5068f7dc01 Cycles: Add utility function to graph to query number of closures used in it
Currently unused but will be needed soon for the split kernel work.
2015-05-09 19:13:32 +05:00
Sergey Sharybin
9ca2b76a9f Cycles: Cleanup, make it more clear what endif closes what ifdef 2015-05-07 15:02:43 +05:00
Sv. Lockal
7201f6d14c Cycles: Use curve approximation for blackbody instead of lookup table
Now we calculate color in range 800..12000 using an approximation a/x+bx+c for R and G and ((at + b)t + c)t + d) for B.
Max absolute error for RGB for non-lut function is less than 0.0001, which is enough to get the same 8 bit/channel color as for OSL with a noticeable performance difference.
However there is a slight visible difference between previous non-OSL implementation because of lookup table interpolation and offset-by-one mistake.
The previous implementation gave black color outside of soft range (t > 12000), now it gives the same color as for 12000.

Also blackbody node without input connected is being converted to value input at shader compile time.

Reviewers: dingto, sergey

Reviewed By: dingto

Subscribers: nutel, brecht, juicyfruit

Differential Revision: https://developer.blender.org/D1280
2015-05-05 06:11:54 +00:00
Sergey Sharybin
ae7d84dbc1 Cycles: Use native saturate function for CUDA
This more a workaround for CUDA optimizer which can't optimize clamp(x, 0, 1)
into a single instruction and uses 4 instructions instead.

Original patch by @lockal with own modification:

  Don't make changes outside of the kernel. They don't make any difference
  anyway and term saturate() has a bit different meaning outside of kernel.

This gives around 2% of speedup in Barcelona file, but in more complex shader
setups with lots of math nodes with clamping speedup could be much nicer.

Subscribers: dingto

Projects: #cycles

Differential Revision: https://developer.blender.org/D1224
2015-04-28 00:38:32 +05:00
Sergey Sharybin
828abaf11c Cycles: Split BVH nodes storage into inner and leaf nodes
This way we can get rid of inefficient memory usage caused by BVH boundbox
part being unused by leaf nodes but still being allocated for them. Doing
such split allows to save 6 of float4 values for QBVH per leaf node and 3
of float4 values for regular BVH per leaf node.

This translates into following memory save using 01.01.01.G rendered
without hair:

                   Device memory size   Device memory peak   Global memory peak
Before the patch:  4957                 5051                 7668
With the patch:    4467                 4562                 7332

The measurements are done against current master. Still need to run speed tests
and it's hard to predict if it's faster or not: on the one hand leaf nodes are
now much more coherent in cache, on the other hand they're not so much coherent
with regular nodes anymore.

Reviewers: brecht, juicyfruit

Subscribers: venomgfx, eyecandy

Differential Revision: https://developer.blender.org/D1236
2015-04-20 17:29:51 +05:00
Thomas Dinges
e5392069cc Cleanup: Typo fix in HSV code. 2015-04-04 07:50:09 +02:00
Sergey Sharybin
79918e0577 Cycles: Avoid float/int conversion in few places 2015-03-31 19:52:14 +05:00
Sergey Sharybin
5ff132182d Cycles: Code cleanup, spaces around keywords
This inconsistency drove me totally crazy, it's really confusing
when it's inconsistent especially when you work on both Cycles and
Blender sides.

Shouldn;t cause merge PITA, it's whitespace changes only, Git should
be able to merge it nicely.
2015-03-28 00:15:15 +05:00
Sergey Sharybin
87cff57207 Fix T44123: Cycles SSS renders black in recent builds
Issue was introduced in 01ee21f where i didn't notice *_setup()
function only doing partial initialization, and some of parameters
are expected to be initialized by callee function.

This was hitting only some setups, so tests with benchmark scenes
didn't unleash issues. Now it should all be fine.

This is to go to the 2.74 branch and we actually might re-AHOY.
2015-03-25 02:33:49 +05:00
Thomas Dinges
97422ea64f Cleanup: Simplify brick texture code a bit. 2015-02-23 16:49:50 +01:00
Sergey Sharybin
a97bc1bedf Fix T43755: Wireframe attribute doesn't work with displace
This attribute missed derivatives calculation.

Not totally sure what's the proper approach for algebraic derivative
calculation, so calculating them by definition. This isn't fastest
way to do it in this case and could be replaced with some smarter magic
in the wireframe calculation loop.

At least currently implemented approach is better than nothing.
2015-02-21 17:30:29 +05:00
Sergey Sharybin
3e534833e3 Cycles: Make sphere and tube image mapping friendly with OpenCL
OpenCL doesn't let you to get address of vector components, which
is kinda annoying. On the other hand, maybe now compiler will have
more chances to optimize something out.
2015-02-19 12:52:48 +05:00
Thomas Dinges
a0d7db503d Cycles: Small tweaks for Henyey Greenstein closure code.
* Avoid duplicative fabs(g) check in sample code.
* Avoid dot product in eval code.

Helps like ~1% when Scatter Anisotropy is 0.
2015-02-17 17:48:18 +01:00
Sergey Sharybin
bd10b72ad3 Fix T43458: Crashes with hair transmission BSDF
Hair BSDF did not have proper behavior because of non-normalized
tangent direction (which it expected to be normalized).This lead
to wrong labels being returned by the hair BSDF samplers.
2015-01-30 13:03:01 +05:00
Sergey Sharybin
d2e526a82d Cycles: Fix for bump node not working with object texture mapping
This was intended to be in the original patch of texco copy from object.
2015-01-29 21:48:22 +05:00
Sergey Sharybin
df07a25d28 Cycles: Support texture coordinate from another object
This is the same as blender internal's texture mapping from another object,
so this way it's possible to control texture space of one object by another.

Quite straightforward change apart from the workaround for the stupidness of
the dependency graph. Now shader has flag telling that it depends on object
transform. This is the simplest way to know which shaders needs to be tagged
for update when object changes. This might give some false-positive tags now
but reducing them should not be priority for Cycles and rather be a priority
to bring new dependency graph.

Also GLSL preview does not support using other object for mapping.

This is actually correct for BI shading as well and to be addressed as
a part of general GLSL viewport improvements since it's not really clear
how to support this in GLSL.

Reviewers: brecht, juicyfruit

Subscribers: eyecandy, venomgfx

Differential Revision: https://developer.blender.org/D1021
2015-01-27 13:36:30 +05:00
Sergey Sharybin
dda355442d Cycles: Support tube projection for images
This way Cycles finally becomes feature-full on image projections
compared to Blender Internal and Gooseberry Project Team could
finally finish the movie.
2015-01-22 00:41:42 +05:00
Sergey Sharybin
12ccac657f Cycles: Support sphere mapping for the image texture 2015-01-22 00:41:42 +05:00
Sergey Sharybin
c5927cd977 Revert "Fix T42888: Separate and Combine HSV distorts the hue value"
This reverts commit 1549fea9995c348bc14a9105df5e460644e2b33a.

After some further discussion with other developers in the team it becomes
clear there's no correct solution here. It is just more matter of what's
more convenient in particular case.

We're just going back to old code to avoid possible frustration with the
older files in newer blenders. This also means all HSV/HSL is considered
to be "linear" in the shading nodes.

Would be ported to 2.73 final.
2014-12-29 18:14:08 +05:00
Thomas Dinges
ee36e75b85 Cleanup: Fix Cycles Apache header.
This was already mixed a bit, but the dot belongs there.
2014-12-25 02:50:24 +01:00
Thomas Dinges
43421e9c53 Cycles: Optimize vector math node without links to single values. 2014-12-24 22:45:08 +01:00
Sergey Sharybin
1549fea999 Fix T42888: Separate and Combine HSV distorts the hue value
These nodes were assuming sRGB input/output which is for sure wrong for the
shader pipeline which works in the linear space.

So now conversion to/from linear space happens in these nodes which makes them
making sence in the shader context but which might change look and feel of
existing scenes.
2014-12-16 20:06:25 +05:00
Sergey Sharybin
f9688d88ff Fix T42391: HSV correction shader node gives negative values
This mainly happens when over-saturating already saturated color.
After some discussion with Campbell and loads of tests we decided
to clamp the result RGB color. As an alternative we might want to
clamp corrected HSV values instead, but that would lead to some
larger changes in the render results.

TODO: The same is to be done for compositor nodes.
2014-10-31 14:58:00 +01:00
Sergey Sharybin
6a4a911fc3 Cycles: Optimize math node without links to a single value node
Pretty straightforward implementation. Just needed to move some functions
around to make them available at shader compile time.
2014-10-29 16:31:13 +05:00
Thomas Dinges
744aaa955f Cleanup: Typo fix for Blackbody variable, had different naming in the comments and also in OSL. 2014-10-12 14:18:30 +02:00
Sergey Sharybin
409b3c9c9c Fix T42106: Box image mapping shows black triangles if they point to a corner and blend is 0
After discussion with cambo here we decided it's better to choose arbitrary side of the box
(in this case it's X-axis) and use image from it. That's better than doing a blackness.

P.S. This is literally a corner case anyway.
2014-10-07 15:48:39 +02:00
Thomas Dinges
02ffed4052 Cleanup: Remove some unused / unreferenced functions for perdiodic perlin noise. 2014-10-03 18:00:45 +02:00
Thomas Dinges
4b2fadeaba Cycles: Remove Westin closure.
Was hooked up last year for testing purposes, as we already had some code for it, but the closure itself is not really good nor really useful, so let's remove it.
2014-10-03 16:03:49 +02:00
Thomas Dinges
8243c55f14 Cycles: Split caustics option, to allow separate control for Reflection and Refraction caustics.
This way artists can only disable/enable refraction or reflection caustics.
See Cycles logs for an example: http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.72/Cycles

Differential revision: https://developer.blender.org/D766
2014-09-05 20:39:35 +02:00
Thomas Dinges
00acf4b816 Cleanup: Use function call and delete obsolete comment. 2014-09-02 23:26:49 +02:00