Commit Graph

47 Commits

Author SHA1 Message Date
Sergey Sharybin
0579eaae1f Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.

For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.

Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.

This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.

Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.

Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner

Reviewed By: lukasstockner97, maiself, nirved, dingto

Subscribers: brecht

Differential Revision: https://developer.blender.org/D2586
2017-03-29 13:41:11 +02:00
Sergey Sharybin
0ac2be7030 Cycles: Disable AVX2 crash workarounds
I can no longer reproduce crash with neither of the files where
the crash was originally visible. This is something where other
changes (light threshold, sampling) had an effect and made code
to work as it is supposed to. Could have been optimizator issue
or something like that.

Let's see if we hit same issue again.
2016-12-02 10:17:05 +01:00
Sergey Sharybin
f11298692b Cycles: More workarounds for weird crashes on AVX2
Oh man, is it a compiler bug? Is it something we do stupid?

For now more crap to prevent crashes. During the conference will talk to
Maxyn about how can we troubleshoot such weird issues.
2016-10-27 12:51:03 +02:00
Sergey Sharybin
7e380ad4c0 Cycles: Another attempt to fix crashes on AVX2 processors
Basically don't use rcp() in areas which seems to be critical after
second look. Also disabled some multiplication operators, not sure
yet why they might be a problem.

Tomorrow will be setting up a full test with all cases which were
buggy in our farm to see if this fix is complete.
2016-10-26 22:14:41 +02:00
Sergey Sharybin
35f152358b Cycles: Completely disable transform SSE for now
Was causing issues on another frame.

On a tight schedule, disabling for now so artists are happy.

Still looking into root of the issue!
2016-10-26 15:23:58 +02:00
Sergey Sharybin
7c7d23691f Cycles: Fix crashes after recent optimization commits
There is some precision issues for big magnitude coordinates which started
to give weird behavior of release builds. Some weird memory usage in BVH
which is tricky to nail down because only happens in release builds and GDB
reports all variables as optimized out when trying to use RelWithDebInfo.

There are two things in this commit:

- Attempt to make vectorized code closer to original one, hoping that it'll
  eliminate precision issue.
  This seems to work for transform_point().
- Similar trick did not work for transform_direction() even tho absolute
  error here is much smaller. For now disabled that function, need a more
  careful look here.
2016-10-26 14:30:25 +02:00
Sergey Sharybin
064caae7b2 Cycles: BVH-related SSE optimization
Several ideas here:

- Optimize calculation of near_{x,y,z} in a way that does not require
  3 if() statements per update, which avoids negative effect of wrong
  branch prediction.

- Optimization of direction clamping for BVH.

- Optimization of point/direction transform.

Brings ~1.5% speedup again depending on a scene (unfortunately, this
speedup can't be sum across all previous commits because speedup of
each of the changes varies from scene to scene, but it still seems to
be nice solid speedup of few percent on Linux and bigger speedup was
reported on Windows).

Once again ,thanks Maxym for inspiration!

Still TODO: We have multiple places where we need to calculate near
x,y,z indices in BVH, for now it's only done for main BVH traversal.
Will try to move this calculation to an utility function and see if
that can be easily re-used across all the BVH flavors.
2016-10-25 14:47:34 +02:00
Alexander Gavrilov
1f19fba566 Cycles: hide particles with broken motion blur traces.
Currently cycles cannot correctly render motion blur for objects that appear or
disappear during the shutter window. Until that can be fixed properly, it may be
better to hide such particles rather than let them render as if they were
stationary for half of the frame.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2125
2016-08-05 01:00:41 +02:00
Sergey Sharybin
a62967787c Fix T48808: Regression: Cycles OpenCL broken after Hair BVH commit 2016-07-08 09:41:36 +02:00
Sergey Sharybin
b03e66e75f Cycles: Implement unaligned nodes BVH builder
This is a special builder type which is allowed to orient nodes to
strands direction, hence minimizing their surface area in comparison
with axis-aligned nodes. Such nodes are much more efficient for hair
rendering.

Implementation of BVH builder is based on Embree, and generally idea
there is to calculate axis-aligned SAH and oriented SAH and if SAH
of oriented node is smaller than axis-aligned SAH we create unaligned
node.

We store both aligned and unaligned nodes in the same tree (which
seems to be different from what Embree is doing) so we don't have
any any extra calculations needed to set up hair ray for BVH
traversal, hence avoiding any possible negative effect of this new
BVH nodes type.

This new builder is currently not in use, still need to make BVH
traversal code aware of unaligned nodes.
2016-07-07 17:25:48 +02:00
Sergey Sharybin
ad5f6a95dd Cycles: Fix compilation error of CUDA kernel after recent decomposition changes 2015-10-09 17:53:29 +05:00
Sergey Sharybin
4974ed93ef Cycles: Fix issues with quick inverse of degenerate matrix
This fixes part of the issues reported in T46322. Still need to solve
issue with wrong intersection distance scaling.
2015-10-09 15:58:03 +05:00
Sergey Sharybin
dc3563ff48 Cycles: Implement camera zoom motion blur
Works totally similar to camera motion blur and majority of the changes are
related on just passing extra arguments to sync() functions.

Couple of things still to look into:

- Motion pass will not include motion caused by the zoom.
- Only perspective cameras are supported currently.
- Motion is being interpolated on projected coordinates, which might give
  different results from constructing projection matrix from interpolated
  field of view.

  This could be good enough for us, but we need to consider improving this
  at some point.

Reviewers: juicyfruit, dingto

Reviewed By: dingto

Differential Revision: https://developer.blender.org/D1383
2015-07-21 17:40:03 +02:00
Sergey Sharybin
33439626f1 Cycles: Add transformation functions with specified addrspace
This is required for OpenCL prior to 2.0 and those functions will become
handy when working on camera/motion blur support in split kernel.
2015-05-14 18:48:56 +05:00
Sergey Sharybin
e073562f80 Cycles: Make transform from viewplane a generic utility function 2015-04-10 15:53:14 +05:00
Sergey Sharybin
a1ffb49e49 Fix T43120: Cycles mapping node rotation order is different from viewport
Root of the issue goes to the fact that since the very beginning Cycles was
using ZYX euler rotation for mapping shader node but blender was always
using XYZ euler rotation.

This commit switches Cycles to use XYZ euler order and adds versioning code
to preserve backward compatibility.

There was no really nice solution here because either we're ending up with
versioning code or we'll need to deal with all sort of exceptions from blender
side in order to support ZYX order for the mapping node. The latest one is
also creepy from the other render engines points of view -- that might break
compatibility with existing bindings or introduce some extra headache for them
in the future.

This could also become a PITA for us with need of supporting all sort of weird
and wonderful exceptions in the refactored viewport project.

NOTE: This commit breaks forward compatibility, meaning opening new files in
older blender might not give proper result if Mapping node was used.

Also, libraries are to be re-saved separately from the scene file, otherwise
versioning code for them wouldn't run if scene file was re-saved with new
version of blender.

Reviewers: brecht, juicyfruit, campbellbarton

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D973
2015-01-22 14:12:22 +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
Campbell Barton
dc13969e48 Style cleanup: indentation, braces 2014-05-05 02:19:08 +10:00
Campbell Barton
1dc1d92dab Code cleanup: white space and cmake was broken on all platforms 2014-02-03 13:56:34 +11: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
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
Thomas Dinges
9e4914e055 Cycles:
* Revert r57203 (len() renaming)
There seems to be a problem with nVidia OpenCL after this and I haven't figured out the real cause yet. 
Better to selectively enable native length() later, after figuring out what's wrong. 

This fixes [#35612].
2013-06-04 17:20:00 +00:00
Thomas Dinges
c5ed6765b9 Cycles / Math functions:
* Rename some math functions:
len -> length
len_squared -> length_squared
normalize_len -> normalize_length

* This way OpenCL uses its inbuilt length() function, rather than our own. The other two functions have been renamed for consistency. 
* Tested CPU, CUDA and OpenCL compile, should be no functional changes.
2013-06-02 20:39:32 +00:00
Thomas Dinges
75e36650e3 Code cleanup / Cycles:
* Simplify shaperadius() function a bit to avoid castings.
* Style cleanup 1.f -> 1.0f, to follow rest of Cycles code.
2013-05-18 11:04:29 +00:00
Brecht Van Lommel
d0ffbeec73 Cycles OpenCL: a few fixes to get things compiling after kernel changes,
for Apple OpenCL on OS X 10.8 and simple AO render.

Also environment variable CYCLES_OPENCL_TEST can now be set to CPU, GPU,
ACCELERATOR, DEFAULT or ALL values to test particuler devices.
2013-05-09 14:05:40 +00:00
Thomas Dinges
872a8ed1bf Cycles / Hair rendering:
* Enable hair rendering on the GPU.

Patch by Stuart Broadfoot, with small tweaks by me, to only enable it on sm_20 and above.
2013-05-08 17:33:25 +00:00
Brecht Van Lommel
cf3ec257a2 Fix #34880: cycles motion blur render issue with some compilers. Actually is a bigger
problem where accessing float4 members with [] stops working due to optimizer, will
check that later.
2013-04-05 23:03:10 +00:00
Brecht Van Lommel
12117a8187 Fix cycles aliasing warnings caused by motion blur transforms. 2012-12-21 10:26:48 +00:00
Brecht Van Lommel
186bdbd8d8 Fix #33344: cycles motion blur was still crashing on CUDA sm 2.0. Solution now
is also an optimization, use quaternion nlerp instead of slerp, there's no good
reason to use slerp, and nlerp is faster too.
2012-11-29 13:07:45 +00:00
Brecht Van Lommel
0d6976ad0c Fix #32900: object motion blur not working on the GPU. To make this work I disabled motion
blurring of scale animation, probably not a big loss in practice since it's not so common
to animate this, can be added back later.
2012-11-29 00:43:50 +00:00
Brecht Van Lommel
afd42031a9 Fix #32974: cycles curved motion blur is not working well combined with rotation,
problem is that the curved interpolation is not constant speed which leads to
mismatches. Turns out this is really hard to solve and implement efficiently, so
curved motion blur is disabled for now, until I can find a solution.
2012-11-11 15:02:05 +00:00
Brecht Van Lommel
d08b06f773 Cycles: motion blur is now curved and passes exactly through the midpoint.
Previously it would only interpolate between the previous and next frame,
which meant it might not hit the current frame position.
2012-10-17 12:55:23 +00:00
Brecht Van Lommel
c10c6b1cea Fix #32844: cycles camera motion blur producing completely blurred frames sometimes. 2012-10-15 17:56:40 +00:00
Campbell Barton
0fbb6bff27 style cleanup: block comments 2012-06-09 17:22:52 +00:00
Brecht Van Lommel
131de4352b Cycles: fixes to make CUDA 4.2 work, compiling gave errors in shadows and
other places, was mainly due to instancing not working, but also found
issues in procedural textures.

The problem was with --use_fast_math, this seems to now have way lower
precision for some operations. Disabled this flag and selectively use
fast math functions. Did not find performance regression on GTX 460 after
doing this.
2012-05-28 19:21:13 +00:00
Brecht Van Lommel
022d12a721 Fix most of #31307: cycles panorama camera not working correct with speed
vectors and window texture coordinates. Only for Fisheye Equisolid it's
still not working correct yet. Patch from Dalai with modifications.
2012-05-07 10:53:09 +00:00
Brecht Van Lommel
1e2afcddd3 Fix #31168: cycles mask layer should only affect objects for camera rays.
Fix: texture coordinate normal output was not correct, still changed under
object transform.
2012-05-02 09:33:45 +00:00
Brecht Van Lommel
1d8c798188 Cycles: support for motion vector and UV passes.
Most of the changes are related to adding support for motion data throughout
the code. There's some code for actual camera/object motion blur raytracing
but it's unfinished (it badly slows down the raytracing kernel even when the
option is turned off), so that code it disabled still.

Motion vector export from Blender tries to avoid computing derived meshes
when the mesh does not have a deforming modifier, and it also won't store
motion vectors for every vertex if only the object or camera is moving.
2012-04-30 12:49:26 +00:00
Brecht Van Lommel
93df58160e Fix #30966: cycles nan mesh vertices got set to (0, 0, 0), now remove them instead. 2012-04-16 08:35:21 +00:00
Brecht Van Lommel
27df40f87f Fix #29653: fix wrong cycles depth of field distance when rendering with a
scaled camera.
2011-12-19 14:23:24 +00:00
Brecht Van Lommel
57a39c3a0c Fix #29594: cycles NaN values with window coordinates mapping. 2011-12-13 00:00:26 +00:00
Brecht Van Lommel
fc42a6185d Cycles:
* Fix object scaling update issue with interactive rendering + static BVH.
* Fix negative scaling issue with static BVH.
* Fix #29217: excessive fireflies in first sample.
2011-11-12 14:29:52 +00:00
Brecht Van Lommel
e9b967d05b Cycles: remove deprecated strict aliasing flag for opencl, fix missing update
modifying object layer in properties editor, and add memarena utility.
2011-09-19 11:57:31 +00:00
Brecht Van Lommel
67030aaf84 Cycles: optimizations for instances in scene updates before render starts,
should load a non-trivial mesh instanced many times quite a bit faster now.
2011-09-02 16:15:18 +00:00
Brecht Van Lommel
64c2d5e90e Cycles: more opencl fixes. 2011-05-31 11:31:00 +00:00
Brecht Van Lommel
88b25b871d Cycles: fix mapping node rotation not working correct for Y/Z axes, patch by Sanne. 2011-05-12 11:34:16 +00:00
Ton Roosendaal
da376e0237 Cycles render engine, initial commit. This is the engine itself, blender modifications and build instructions will follow later.
Cycles uses code from some great open source projects, many thanks them:

* BVH building and traversal code from NVidia's "Understanding the Efficiency of Ray Traversal on GPUs":
http://code.google.com/p/understanding-the-efficiency-of-ray-traversal-on-gpus/
* Open Shading Language for a large part of the shading system:
http://code.google.com/p/openshadinglanguage/
* Blender for procedural textures and a few other nodes.
* Approximate Catmull Clark subdivision from NVidia Mesh tools:
http://code.google.com/p/nvidia-mesh-tools/
* Sobol direction vectors from:
http://web.maths.unsw.edu.au/~fkuo/sobol/
* Film response functions from:
http://www.cs.columbia.edu/CAVE/software/softlib/dorf.php
2011-04-27 11:58:34 +00:00