Commit Graph

111 Commits

Author SHA1 Message Date
Sergey Sharybin
700722f686 Cycles: Cleanup, indent nested preprocessor directives
Quite straightforward, main trick is happening in path_source_replace_includes().

Reviewers: brecht, dingto, lukasstockner97, juicyfruit

Differential Revision: https://developer.blender.org/D1794
2016-03-25 13:55:42 +01:00
Sergey Sharybin
3aa74828ab Cycles: Cleanup, indentation and braces 2016-02-03 15:00:55 +01:00
Sergey Sharybin
1f273cec00 Cycles: Tweak inline policy for some functions
The goal is to make Experimental kernel closer in performance to the
official kernel, avoiding spills and such.

There should not be big impact on official kernel, own tests showed
few percent performance drop on laptop's GPU. CPU was always the
same speed on AVX, AVX2 and SSE4.1 CPUs i've been testing here.

This seems to be the last essential step before we can get rid of
Experimental kernel and enable SSS officially on GPU without causing
some major performance issues.

Surely some more tweaks are possibly required, but that we can do
for until cows go home anyway.
2016-01-14 14:53:05 +05:00
Thomas Dinges
83e73a2100 Cycles: Refactor how we pass bounce info to light path node.
This commit changes the way how we pass bounce information to the Light
Path node. Instead of manualy copying the bounces into ShaderData, we now
directly pass PathState. This reduces the arguments that we need to pass
around and also makes it easier to extend the feature.

This commit also exposes the Transmission Bounce Depth to the Light Path
node. It works similar to the Transparent Depth Output: Replace a
Transmission lightpath after X bounces with another shader, e.g a Diffuse
one. This can be used to avoid black surfaces, due to low amount of max
bounces.

Reviewed by Sergey and Brecht, thanks for some hlp with this.

I tested compilation and usage on CPU (SVM and OSL), CUDA, OpenCL Split
and Mega kernel. Hopefully this covers all devices. :)
2016-01-06 23:43:29 +01: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
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
Thomas Dinges
e6f7f36e40 Cleanup: Style in for loops header. 2015-06-29 00:56:04 +02:00
Sergey Sharybin
1cbf748e0c Cycles: Add assert check to shader closure merge function 2015-06-13 18:17:16 +02:00
Sergey Sharybin
3d3d805b64 Cycles: Prepare code for OpenCL camera/motion blur
The kernels are now compiling just fine, but there're some issues
during rendering. This is still to be investigated.
2015-05-14 18:48:56 +05: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
e2354e64d2 Cycles: Cleanup, spaces around assignment operator
Did some bad spacing in recent commits, better to get rid of those so
they does not confuse those who're working on sources.
2015-04-07 00:25:54 +05:00
Jens Verwiebe
9fc1a29de3 Fix 2 typos ( shakin' hands ) 2015-03-25 16:56:51 +01: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
0ed914a194 Cleanup: Use differential helper class. 2015-03-12 23:35:01 +01: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
Sergey Sharybin
7366283c01 Fix T42818: Cycles SSS passes are incorrect for SSS size of 0
This was caused by some internal optimization which evaluated SSS with
size of zero as BSDF but used different ID so the evaluation result
didn't appear in regular diffuse pass.

This lead to situation when SSS data was nowhere stored if the
size was zero.

Now SSS with zero size and close-to-zero sizes will be handled in the
same way from the passes point of view.
2014-12-10 17:28:44 +05:00
Martijn Berger
25ec0d97f9 make "tri_shader" an int instead of a float
tri_shader does no longer need to a float.

Reviewers: dingto, sergey

Reviewed By: dingto, sergey

Subscribers: dingto

Projects: #cycles

Differential Revision: https://developer.blender.org/D789
2014-09-24 13:34:28 +02:00
Thomas Dinges
2ed1b67835 Fix T41912, OpenCL compile error when building without __SVM__
Thanks to Vitaliy Filippov for the patch.
2014-09-23 12:54:16 +02:00
Sergey Sharybin
bfaf4f2d0d Fix T41219: Cycles backface detection doesn't work properly
Root of the issue goes back to the on-fly normals commit and the
latest fix for it wasn't actually correct. I've mixed two fixes
in there.

So the idea here goes back to storing negative scaled object flag
and flip runtime-calculated normal if this flag is set, which is
pretty much the same as the original fix for the issue from me.

The issue with motion blur wasn't caused by the rumtime normals
patch and it had issues before, because it already did runtime
normals calculation. Now made it so motion triangles takes the
negative scale flag into account.

This actually makes code more clean imo and avoids rather confusing
flipping code in mesh.cpp.
2014-08-13 16:35:54 +06:00
Sergey Sharybin
9fcaac5009 Fix T41147: Static BVH shading problem
Fix T41079: Solid black render of object with negative scale and smooth shading

In both cases the issue was caused by negative scaled objects with single mesh
users for which scale gets applied when using static BVH.

Since the on-fly normals calculation land normals for such cases weren't flipped
leading them to point to a wrong direction.

Added a special object flag for this, which is a bit of a bummer because now
we've got less bits for real useful things, but this is the only way to get
proper normals without adding more complexity in the on-fly calculations.
2014-07-23 13:00:52 +06:00
a29807cd63 Cycles: volume light sampling
* Volume multiple importace sampling support to combine equiangular and distance
  sampling, for both homogeneous and heterogeneous volumes.

* Branched path "Sample All Direct Lights" and "Sample All Indirect Lights" now
  apply to volumes as well as surfaces.

Implementation note:

For simplicity this is all done with decoupled ray marching, the only case we do
not use decoupled is for distance only sampling with one light sample. The
homogeneous case should still compile on the GPU because it only requires fixed
size storage, but the heterogeneous case will be trickier to get working.
2014-06-14 13:49:56 +02:00
Thomas Dinges
49df707496 Cycles: Calculate face normal on the fly.
Instead of pre-calculation and storage, we now calculate the face normal during render.
This gives a small slowdown (~1%) but decreases memory usage, which is especially important for GPUs,
where you have limited VRAM.

Part of my GSoC 2014.
2014-06-13 21:59:13 +02:00
48b053bd44 Fix T40345: cycles volume render + AO pass not working correct. 2014-05-26 13:51:11 +02:00
Campbell Barton
dc13969e48 Style cleanup: indentation, braces 2014-05-05 02:19:08 +10:00
04a10907dc Code cleanup: remove old closure sampling code Cycles.
This was the original code to get things working on old GPUs, but now it is no
longer in use and various features in fact depend on this to work correctly to
the point that enabling this code is too buggy to be useful.
2014-04-21 16:14:37 +02:00
Carlo Andreacchio
7765b73f6d Cycles: add Transparent Depth output to Light Path node.
This can for example be useful if you want to manually terminate the path at
some point and use a color other than black.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D454
2014-04-21 14:44:36 +02:00
5e5ec4c138 Fix T39577: cycles issue mixing anisotropic BSDFs with branched path tracer. 2014-04-03 15:59:39 +02:00
e8b1cfed0a Cycles code refactor: replace magic ~0 values in the code with defines. 2014-03-29 13:03:47 +01:00
6020d00990 Cycles: add support for mesh deformation motion blur. 2014-03-29 13:03:47 +01:00
0509553b5e Cycles code refactor: changes to make adding new primitive types easier. 2014-03-29 13:03:46 +01:00
41d1675053 Cycles code refactor: move more geometry code into per primitive files. 2014-03-29 13:03:45 +01:00
7b0a46b1ff Fix CUDA/OpenCL compile errors in scattering commit. 2014-01-07 15:48:04 +01:00
01df756bd1 Cycles Volume Render: scattering support.
This is done by adding a Volume Scatter node. In many cases you will want to
add together a Volume Absorption and Volume Scatter node with the same color
and density to get the expected results.

This should work with branched path tracing, mixing closures, overlapping
volumes, etc. However there's still various optimizations needed for sampling.
The main missing thing from the volume branch is the equiangular sampling for
homogeneous volumes.

The heterogeneous scattering code was arranged such that we can use a single
stratified random number for distance sampling, which gives less noise than
pseudo random numbers for each step. For volumes where the color is textured
there still seems to be something off, needs to be investigated.
2014-01-07 15:03:41 +01:00
fe222643b4 Cycles Volume Render: add volume emission support.
This is done using the existing Emission node and closure (we may add a volume
emission node, not clear yet if it will be needed).

Volume emission only supports indirect light sampling which means it's not very
efficient to make small or far away bright light sources. Using direct light
sampling and MIS would be tricky and probably won't be added anytime soon. Other
renderers don't support this either as far as I know, lamps and ray visibility
tricks may be used instead.
2013-12-28 23:20:53 +01:00
2b39214c4d Cycles Volume Render: add support for overlapping volume objects.
This works pretty much as you would expect, overlapping volume objects gives
a more dense volume. What did change is that world volume shaders are now
active everywhere, they are no longer excluded inside objects.

This may not be desirable and we need to think of better control over this.
In some cases you clearly want it to happen, for example if you are rendering
a fire in a foggy environment. In other cases like the inside of a house you
may not want any fog, but it doesn't seem possible in general for the renderer
to automatically determine what is inside or outside of the house.

This is implemented using a simple fixed size array of shader/object ID pairs,
limited to max 15 overlapping objects. The closures from all shaders are put
into a single closure array, exactly the same as if an add shader was used to
combine them.
2013-12-28 20:12:11 +01:00
e369a5c485 Cycles Volume Render: support for rendering of homogeneous volume with absorption.
This is the simplest possible volume rendering case, constant density inside
the volume and no scattering or emission. My plan is to tweak, verify and commit
more volume rendering effects one by one, doing it all at once makes it
difficult to verify correctness and track down bugs.

Documentation is here:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Materials/Volume

Currently this hooks into path tracing in 3 ways, which should get us pretty
far until we add more advanced light sampling. These 3 hooks are repeated in
the path tracing, branched path tracing and transparent shadow code:

* Determine active volume shader at start of the path
* Change active volume shader on transmission through a surface
* Light attenuation over line segments between camera, surfaces and background

This is work by "storm", Stuart Broadfoot, Thomas Dinges and myself.
2013-12-28 16:57:10 +01:00
37c4d6a50a Cycles Volume Render: add flags to quickly detect when objects have a volume shader. 2013-12-28 16:57:10 +01:00
a35db17cee Cycles Volume Render: work on nodes and closures.
* Henyey-Greenstein scattering closure implementation.
* Rename transparent to absorption node and isotropic to scatter node.
* Volume density is folded into the closure weights.
* OSL support for volume closures and nodes.
* This commit has no user visible changes, there is no volume render code yet.

This is work by "storm", Stuart Broadfoot, Thomas Dinges and myself.
2013-12-28 16:57:02 +01:00
Thomas Dinges
b43ce8a140 Code cleanup / Cycles: Remove some unused hair code. 2013-12-14 13:11:44 +01:00
746628e0d0 Cycles OSL: refactoring to remove all dependencies on builtin OSL closures.
These were removed in new OSL versions. We only used these as base classes,
not using them at all simplifies the code a bit.
2013-11-29 04:01:07 +01:00
c18712e868 Cycles: change __device and similar qualifiers to ccl_device in kernel code.
This to avoids build conflicts with libc++ on FreeBSD, these __ prefixed values
are reserved for compilers. I apologize to anyone who has patches or branches
and has to go through the pain of merging this change, it may be easiest to do
these same replacements in your code and then apply/merge the patch.

Ref T37477.
2013-11-18 08:48:15 +01:00
Thomas Dinges
b5a5773fa9 Cycles / CUDA:
* Remove support for  CUDA Toolkit 4.x, only Toolkit 5.0 and above are supported now.
* Remove support for sm_1x cards (< Fermi) for good. We didn't officially support those cards for a few releases already, now remove some special code that was still there.
2013-10-08 15:29:28 +00:00
Brecht Van Lommel
edde749850 Fix #36741: cycles AO pass giving values > 1.0 with transparency. 2013-09-17 13:22:42 +00:00
Stuart Broadfoot
3306afac87 Cycles Hair: Two basic bair shaders added
A new hair bsdf node, with two closure options, is added. These closures allow the generation of the reflective and transmission components of hair. The node allows control of the highlight colour, roughness and angular shift.

Llimitations include:
-No glint or fresnel adjustments.
-The 'offset' is un-used when triangle primitives are used.
2013-09-15 23:58:00 +00:00
Brecht Van Lommel
01e22d1b9f Cycles: more code refactoring to rename things internally as well. Also change
property name back so we keep compatibility.
2013-08-23 14:34:34 +00:00
Brecht Van Lommel
b9ce231060 Cycles: relicense GNU GPL source code to Apache version 2.0.
More information in this post:
http://code.blender.org/

Thanks to all contributes for giving their permission!
2013-08-18 14:16:15 +00:00
Brecht Van Lommel
d43682d51b Cycles: Subsurface Scattering
New features:

* Bump mapping now works with SSS
* Texture Blur factor for SSS, see the documentation for details:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Shaders#Subsurface_Scattering

Work in progress for feedback:

Initial implementation of the "BSSRDF Importance Sampling" paper, which uses
a different importance sampling method. It gives better quality results in
many ways, with the availability of both Cubic and Gaussian falloff functions,
but also tends to be more noisy when using the progressive integrator and does
not give great results with some geometry. It works quite well for the
non-progressive integrator and is often less noisy there.

This code may still change a lot, so unless you're testing it may be best to
stick to the Compatible falloff function.

Skin test render and file that takes advantage of the gaussian falloff:
http://www.pasteall.org/pic/show.php?id=57661
http://www.pasteall.org/pic/show.php?id=57662
http://www.pasteall.org/blend/23501
2013-08-18 14:15:57 +00:00
Thomas Dinges
2c2206a272 Cycles:
* Remove an unneeded return in shader_bsdf_eval(), function is void. 
* if / else if tweak in shader_bsdf_ao().
2013-08-14 19:38:14 +00:00
Thomas Dinges
48ae40ccdf Code cleanup / Cycles:
* Rename "curve_kernel_data" to just "curve", to avoid redundant naming.
2013-08-11 15:27:04 +00:00
Thomas Dinges
a18112249d Cycles / Non-Progressive integrator:
* Non-Progressive integrator is now available on the GPU (CUDA, sm_20 and above). 

Implementation details:
* kernel_path_trace() has been split up into two functions:
kernel_path_trace_non_progressive() and kernel_path_trace_progressive().

* We compile two CUDA kernel entry functions (in kernel.cu) for the two integrators, they are still inside one .cubin file but due to the kernel separation there should be no performance problem. I tested with the BMW file on my Geforce 540M and the render times were the same for 100 samples (1.57 min in my case).

This is part of my GSoC project, SVN merge of r59032 + manual merge of UI changes for this from my branch.
2013-08-09 18:47:25 +00:00