Commit Graph

978 Commits

Author SHA1 Message Date
Mai Lavelle
a5261e06a3 Fix T49167: Normals in wrong coordinate space when adaptive subdivision is used
Meshes with Cycles subdivision were being transformed to world space leading to
normals to sometimes be calculated in that space, while they should be in
object space. Also caused dicing to happen at the wrong rate for scaled meshes.
2016-08-27 18:07:04 -04:00
Mai Lavelle
50a44edca4 Cycles: Remove some redundant checks 2016-08-25 10:52:00 -04:00
Sergey Sharybin
86c719f796 Cycles: Fix crash after recent subd fixes
Was happening when object only had curves (doe example, object with hair
particle system and emitter rendering disabled).
2016-08-25 11:31:36 +02:00
Mai Lavelle
438bcc6d28 Cycles: Fix crash when empty mesh has subdivision
OpenSubdiv doesn't like empty meshes, so we need to be careful not to
subdivide when the mesh is empty.
2016-08-24 10:39:00 -04:00
Mai Lavelle
74bd809962 Cycles Standalone: Fix support for subdivision meshes
Changes from microdisplacement work broke previous support for subdivision
meshes, sometimes leading to crashes; this makes things work again. Files
that contain "patch" nodes will need to be updated to use meshes instead, as
specifying patches was both inefficient and completely unsupported by the new
subdivision code.
2016-08-24 10:39:00 -04:00
Alexander Gavrilov
eb2ee7212e Fix T49136: full constant Curves with zero Fac input crashes in assert.
The if branches were reordered when the original patch was
committed, which broke the implicit non-NULL guarantee on link.

To prevent re-occurrence, add a couple of unit tests.
2016-08-22 11:11:45 +03:00
e8b5e66db1 Code cleanup to use array.data() rather than &array[0]
(Now without the build errors)
2016-08-18 02:24:13 +02:00
Mai Lavelle
7baf93c711 Revert "Code cleanup to use array.data() rather than &array[0]."
This reverts commit 40b367479c6fe23d6f2b6d822f2d5266485619f3.

Didn't build or solve any known issue. Please don't push changes without
testing them first.
2016-08-17 18:49:18 -04:00
40b367479c Code cleanup to use array.data() rather than &array[0].
These latter can cause MSVC debug asserts if the array is empty. With C++11
we'll be able to do this for std::vector later. This hopefully fixes an assert
in the Cycles subdivision code.
2016-08-17 23:54:47 +02:00
Mai Lavelle
76b6c77f2c Cycles microdisplacement: Allow kernels to be built without patch evaluation
Kernels can now be built without patch evaluation when not needed by the
scene (Catmull-Clark subdivision not in use), giving a performance boost
for some devices.
2016-08-15 11:13:18 -04:00
Thomas Dinges
9b0f6fa7f7 Revert "Cycles: Use half storage for 16bit files (e.g. 16bit pngs) as well."
After discussion in IRC, 16bit int should not be converted to half, too much precision loss.
2016-08-15 01:01:43 +02:00
Thomas Dinges
a18b2ba643 Cycles: Use half storage for 16bit files (e.g. 16bit pngs) as well.
Note: This only works for textures loaded from disk via OIIO, not packed textures. That's still a ToDo.
2016-08-14 22:24:29 +02:00
Mai Lavelle
9396e11180 Cycles microdisplacement: Move call to tessellate() from addon to Cycles
By calling `tessellate()` from the mesh manager in Cycles we can do pre/post
processing or even threaded tessellation without concerning client side code
with the details.
2016-08-14 15:04:21 -04:00
Thomas Dinges
5c0a67b325 Cycles: Add single channel texture support for OpenCL.
This way OpenCL devices can also benefit from a smaller memory footprint, when using e.g. bumpmaps (greyscale, 1 channel).

Additional target for my GSoC 2016.
2016-08-14 20:21:08 +02:00
Thomas Dinges
5ac7ef873b Cycles: Change code order for Image Data Types.
Now we have the 4 component ones first (float4, byte4, half4) followed by the 1 component ones (float, byte, half).
Makes code a bit more consistent and also reduces code a bit when enabling half support on GPU in next commit.

This also exposed a typo in half CPU images for 3D textures, which wasn't used yet, but good to have that one fixed anyway.
2016-08-11 22:30:03 +02:00
Julian Eisel
b53eca1711 Cycles: Fix crash in empty scenes
To recreate, just delete default cube and render.

Simple fix, but @maiself or @sergey may want to double-check ;)
2016-08-09 04:32:38 +02:00
Mai Lavelle
a58fe05c05 Cycles microdisplacement: Move displacement options from mesh to material settings
Displacement is now a per material setting, which means old files will have to
be updated if they had used displacement. Cool side effect of this change is
material previews now show displacement.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2140
2016-08-07 14:15:20 -04:00
Mai Lavelle
0b68c68006 Cycles microdisplacement: Support for Catmull-Clark subdivision via OpenSubdiv
Enables Catmull-Clark subdivision meshes with support for creases and attribute
subdivision. Still waiting on OpenSubdiv to fully support face varying
interpolation for subdividing uv coordinates tho. Also there may be some
inconsistencies with Blender's subdivision which will be resolved at a
later time.

Code for reading patch tables and creating patch maps is borrowed
from OpenSubdiv.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2111
2016-08-07 11:13:11 -04:00
Mai Lavelle
cd809b95d8 Cycles: Add AttributeDescriptor
Adds a descriptor for attributes that can easily be passed around and extended
to contain more data. Will be used for attributes on subdivision meshes.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2110
2016-08-05 23:49:21 -04:00
734e0aca38 Fix for Cycles particle motion blur hiding fix.
My mistake in modifying the patch.
2016-08-06 01:14:32 +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
Alexander Gavrilov
5f63797c09 Cycles: copy shader node names over in the blender sync code.
This makes constant folding logs with --debug-cycles more meaningful.
A tiny fix is needed in OSL generator to match recent node refactoring.
2016-08-04 15:19:58 +03:00
Sergey Sharybin
285e082a77 Fix T49010: Portals don't work in recent Blender versions 2016-08-03 12:38:25 +02:00
Alexander Gavrilov
f2d5295abf Cycles: log how many nodes were deduplicated for use in tests.
To make the number more meaningful, also skip deduplicating
obviously unused nodes with no outgoing links.
2016-08-02 19:26:57 +03:00
Alexander Gavrilov
e54320c488 Cycles: add folding for redundant A to B to A conversions.
As a result of other folding simplifications it may happen that
two type conversion nodes end up directly connected. In some
cases it may be possible to then remove both. A realistic case
might be an optimized out Mix RGB node used to blend vectors.

It seems it's safe to optimize when B is a float3 type
(color, vector), and A is float3 or float.

Reviewers: #cycles, sergey

Reviewed By: #cycles, sergey

Subscribers: sergey

Differential Revision: https://developer.blender.org/D2134
2016-08-02 18:41:15 +03:00
Alexander Gavrilov
138362a3c9 Cycles: add unit tests for supported constant folding rules.
Code coverage of different combinations of secondary conditions
is obviously not complete because there are so many of them, but
all main rules should be there.

The reason for CORRECT vs INVALID is that both words have the same
number of characters so calls line up, but look quite different.

Reviewers: #cycles, sergey

Reviewed By: #cycles, sergey

Subscribers: dingto, sergey, brecht

Differential Revision: https://developer.blender.org/D2130
2016-08-01 18:53:20 +03:00
feac208557 Fix mistake in Cycles mix node multiply constant folding. 2016-07-31 15:00:40 +02:00
9b6ed3a42b Cycles: refactor kernel closure storage to use structs per closure type.
Reviewed By: dingto, sergey

Differential Revision: https://developer.blender.org/D2127
2016-07-31 02:34:43 +02:00
Alexander Gavrilov
1776f75c3b Cycles: constant fold add/mul type nodes with known 0 and 1 arguments.
These values often either turn the node into a no-op, or even make it
evaluate to 0 no matter what the other input value is, thus allowing
deletion of a branch of the node graph that otherwise is not constant.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2085
2016-07-31 02:34:34 +02:00
Alexander Gavrilov
ea2ebf7a00 Cycles: constant folding for RGB/Vector Curves and Color Ramp.
These are complex nodes, and it's conceivable they may end up constant
in some circumstances within node groups, so folding support is useful.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2084
2016-07-31 02:18:23 +02:00
f4bcc97729 Fix Cycles OpenCL not always allocating enough space for closures. 2016-07-30 23:21:03 +02:00
Sergey Sharybin
37933cb048 Cycles: Add fundamentals to test constant folding
This commit adds some easy to use way to check whether the graph
was properly optimized. The idea is based on using mock glog sync
which keeps track on all messages and expects specific log message
to appear in the logging.

This means each optimization step should report that it optimized
something (specifying what exactly was optimized) and what was used
for optimization.

There's also some ease-ish way to define shader networks which we
might want to make a bit more global and available for all tests
in the future.

For now only RGBToBW node is covered as an example, really hope
to get help from active guys in the community to finish covering
all existing optimization cases. Ready to fix any possible issues
with builder when needed tho :)
2016-07-29 22:19:30 +02:00
Mai Lavelle
992257cfa0 Cycles: remove narrowing conversion from recent commit 2016-07-29 04:00:37 -04:00
Mai Lavelle
66e2e2484c Cycles microdisplacement: move subdivision options to subsurf modifier
Subdivision options can now be found in the subsurf modifier. The modifier must
be the last in the stack or the options will be unavailable. Catmull-Clark
subdivision is still unavailable and will fallback to linear subdivision instead

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2109
2016-07-29 03:37:55 -04:00
Mai Lavelle
c96ae81160 Cycles microdisplacement: ngons and attributes for subdivision meshes
This adds support for ngons and attributes on subdivision meshes. Ngons are
needed for proper attribute interpolation as well as correct Catmull-Clark
subdivision. Several changes are made to achieve this:

- new primitive `SubdFace` added to `Mesh`
- 3 more textures are used to store info on patches from subd meshes
- Blender export uses loop interface instead of tessface for subd meshes
- `Attribute` class is updated with a simplified way to pass primitive counts
  around and to support ngons.
- extra points for ngons are generated for O(1) attribute interpolation
- curves are temporally disabled on subd meshes to avoid various bugs with
  implementation
- old unneeded code is removed from `subd/`
- various fixes and improvements

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2108
2016-07-29 03:36:30 -04:00
e30f9b04fc Fix use of uninitialized variable in Cycles, mostly harmless. 2016-07-29 03:29:02 +02:00
Sergey Sharybin
df00529648 Cycles: Fix missing mesh flags update when tweaking shaders
This is a bit weak, but better than tagging whole mesh manager for update.

Maybe we'll solve such dual-look up in the future.

This commit finally solves T48963: Noise when changing Diffuse node to Emission node
2016-07-28 12:37:44 +02:00
Sergey Sharybin
9f18e3acd6 Cycles: Fix wrong order of light manager update tag
Shader's has_surface_emission will only be known for sure after compilation.
2016-07-28 12:31:01 +02:00
Sergey Sharybin
d3d1313ca4 Cycles: De-duplicate more checks around light emisive meshes
Once again, should be no functional changes.
2016-07-28 12:28:31 +02:00
Sergey Sharybin
87717c6449 Cycles: De-duplicate check for MIS shaders in meshes
Should be no functional changes.
2016-07-28 12:27:05 +02:00
Sergey Sharybin
aaac4e965e Cycles: Add some extra logging for light debugging 2016-07-28 12:13:11 +02:00
b645e7081d Fix T48790: Cycles render bug with zero strength lights. 2016-07-27 23:09:38 +02:00
Sergey Sharybin
2e38c07e48 Cycles: Style, placement of asteric in pointers
Seems we are using `void *` much much more often in Cycles.
2016-07-27 14:10:09 +02:00
Sergey Sharybin
183874841b Cycles: Some minor tweaks to emission sharder
- Nodification of shader nodes changed default strength from 10 to 1.
  If that was intentional, IMO should happen as a separate commit.

- Fixed indentation.
2016-07-27 14:05:22 +02:00
e44fa4e6a9 Fix another Cycles OSL script node issue with shaders using bump. 2016-07-21 04:40:28 +02:00
1c6b8c6675 Fix Cycles OSL script node not working in shader using bump, after node type refactoring. 2016-07-21 02:56:17 +02:00
Alexander Gavrilov
5234e9ddd3 Cycles: add ConstantFolder class for constant folding boilerplate.
Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D2089
2016-07-18 22:54:30 +02:00
Kévin Dietrich
10b0e33de1 Cycles: add support for motion blurring of fluid meshes.
Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2063
2016-07-18 22:40:08 +02:00
Sergey Sharybin
6cd675af30 Cycles: Add option to disable new Hair BVH
While it's an extra option added to the interface which might not be
fully obvious for artists, it allows to save up to 20% of memory in
hairy scenes.

This is high enough memory saver in my opinion which might become
handy for some production files where it's more important to make
scene to fit into memory rather than trying to use more optimal BVH
structure but go into swap or crash.

Reviewers: dingto, brecht

Reviewed By: dingto, brecht

Differential Revision: https://developer.blender.org/D2090
2016-07-15 16:29:28 +02:00
71bbf0e1b5 Code cleanup: show unused arguments names for ShaderNode::constant_fold. 2016-07-14 22:59:44 +02:00