Commit Graph

143 Commits

Author SHA1 Message Date
Sergey Sharybin
91b23992ce Fix T41870: Cycles OSL - Changing rotation value in anisotropic shader crashes Blender
Older OSX has major issues with sincos() function, it's likely a big in OSL
or LLVM. For until we've updated to new versions of this libraries we'll use
a workaround to prevent possible crashes on all the platforms.

Shouldn't be that bad because it's mainly used for anisotropic shader where
angle is usually constant.

This fix is safe for inclusion into final Blender 2.75 release.
2015-06-14 13:14:11 +02: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
Campbell Barton
b82d571c85 Cleanup: style 2015-04-21 15:53:32 +10:00
Thomas Dinges
97422ea64f Cleanup: Simplify brick texture code a bit. 2015-02-23 16:49:50 +01:00
Sergey Sharybin
578cc2143d Cycles: Add note about autodiff in OSL wireframe shader 2015-02-21 17:31:41 +05: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
de4dcda545 Fix T43651: New pointiness attribute doesn't work with displacement
Simple fix: just make pointiness aware of bump offset.
2015-02-20 17:20:24 +05:00
Sergey Sharybin
227a94077f Cycles: implement pointiness geometry attribute
This attribute means how "pointy" the geometry surface is, which allows to do
effects like dirt maps and wear-off effects on render geometry. This means the
attribute is calculated for the final mesh which means no baking (which implies
UV unwrap) is needed. Apart from this the behavior is quite close to how vertex
dirty colors works.

The new attribute is available as an output socket of Geometry node.

There's no penalty for the render time, only some delay on scene preparation
(the delay is linear of the mesh complexity).

Reviewers: brecht, juicyfruit

Subscribers: eyecandy, venomgfx

Differential Revision: https://developer.blender.org/D1086
2015-02-10 20:33:41 +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
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
d68521df7b Cycles: Fix difference between SVM and OSL implementation of Normal node
SVM was normalizing the input normal, OSL did not. This lead to render
result differences across this shading systems.
2014-12-10 19:07:50 +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
Thomas Dinges
d5ed153760 Cycles / OSL: Support microfacet() closure color function from OSL 1.5
This is basically just a wrapper class, which maps the generic call from the OSL spec to our closures.

Example usage:

shader microfacet_osl(
    color Color = color(0.8),
    int Distribution = 0,
    normal Normal = N,
    vector Tangent = normalize(dPdu),
    float RoughnessU = 0.0,
    float RoughnessV = 0.0,
    float IOR = 1.4,
    int Refract = 0,
    output closure color BSDF = 0)
{
    if (Distribution == 0)
        BSDF = Color * microfacet("ggx", Normal, Tangent, RoughnessU, RoughnessV, IOR, Refract);
    else
        BSDF = Color * microfacet("beckmann", Normal, Tangent, RoughnessU, RoughnessV, IOR, Refract);
}
2014-10-30 11:33:27 +01: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
3aa65574f5 Cycles / OSL: Make the signed/unsigned Perlin parameter more self explaining. 2014-10-03 17:51:21 +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
Campbell Barton
927099ceb8 Cleanup: style 2014-09-30 02:04:34 +10:00
Thomas Dinges
aa8d25bf09 Cycles / OSL: Add a conductive fresnel shader template.
This adds a fresnel conductive OSL preset to the Text Editor. Based on a patch by Lukas Stockner.
Differential revision: https://developer.blender.org/D145

See the differential for details.
2014-09-07 18:28:59 +02:00
Thomas Dinges
59f4ba854b Cycles: Update stdosl.h for OSL 1.5. 2014-08-01 15:23:58 +02:00
Thomas Dinges
6cff19a0bf Cycles: Drop old OSL closure compatibility code.
This was added to keep custom OSL scripts with Toon and SSS closure calls working. 1 year after the change, we can drop the compatibility code now.
2014-07-25 11:42:01 +02:00
Thomas Dinges
ead83a48f1 Fix T40692, Checker Texture derivation on very large scales (1k).
It might still have a derivation on larger scales (10k or more), but we need some offset to avoid precision issues on unit coordinates.
2014-06-20 09:03:22 +02:00
b12151eceb Cycles: glossy and anisotropic BSDF changes
* Anisotropic BSDF now supports GGX and Beckmann distributions, Ward has been
  removed because other distributions are superior.
* GGX is now the default distribution for all glossy and anisotropic nodes,
  since it looks good, has low noise and is fast to evaluate.
* Ashikhmin-Shirley is now available in the Glossy BSDF.
2014-06-14 13:49:57 +02:00
Karsten Schwenk
8ce1090d4e Cycles: Ashikhmin-Shirley anisotropic BSDF
* Ashikhmin-Shirley anisotropic BSDF was added as closure
* Anisotropic BSDF node now has two distributions

Reviewers: brecht, dingto

Differential Revision: https://developer.blender.org/D549
2014-06-14 13:49:57 +02:00
Thomas Dinges
3de3987ea1 Cycles: Add dedicated nodes to split/combine vectors.
This was already possible via the RGB nodes, but that seems weird.
2014-06-13 21:59:14 +02:00
Thomas Dinges
2c69f1e574 Cleanup: Remove unused total power Emission code in Cycles, that was never exposed in the UI.
Differential Revision: https://developer.blender.org/D562
2014-05-30 14:32:59 +02:00
4d1ec4d9c7 Fix T40386: cycles anisotropic BSDF difference between SVM and OSL. 2014-05-28 16:41:48 +02:00
Matt Heimlich
3fbc984b06 Nodes: add absolute value operation to all math nodes
Reviewed By: dingto, brecht

Differential Revision: https://developer.blender.org/D507
2014-05-07 16:43:59 +02:00
Kevin Dietrich
1dcf956849 Fix for wrong behavior of 'darken' blend mode with factor.
The formula was not consistent across Blender and behaved strangely, now it is
a simple linear blend between color1 and min(color1, color2).

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D489
2014-04-29 14:03:09 +02:00
Campbell Barton
a2489e29f6 Code cleanup: style, unused import 2014-04-28 00:19:15 +10: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
Kevin Dietrich
83988b6cdd Fix new Cycles UV Map node not working correct for bump mapping.
Reviewed By: brecht

Differential Revision: https://developer.blender.org/D475
2014-04-21 14:44:36 +02:00
72308669ce Fix T39284: clamp cycles volume density to be >= 0, to avoid accidental strange shading. 2014-04-15 15:19:23 +02:00
Kevin Dietrich
cb7cfd3ab6 Cycles: add dedicated UV Map node, easier to find and has convenient auto complete.
Fixes T37954.

Reviewed By: brecht, dingto

Differential Revision: https://developer.blender.org/D230
2014-04-02 11:53:44 +02:00
Martijn Berger
dd2dca2f7e Add support for multiple interpolation modes on cycles image textures
All textures are sampled bi-linear currently with the exception of OSL there texture sampling is fixed and set to smart bi-cubic.

This patch adds user control to this setting.

Added:
- bits to DNA / RNA in the form of an enum for supporting multiple interpolations types
- changes to the image texture node drawing code ( add enum)
- to ImageManager (this needs to know to allocate second texture when interpolation type is different)
- to node compiler (pass on interpolation type)
- to device tex_alloc this also needs to get the concept of multiple interpolation types
- implementation for doing non interpolated lookup for cuda and cpu
- implementation where we pass this along to osl ( this makes OSL also do linear untill I add smartcubic to the interface / DNA/ RNA)

Reviewers: brecht, dingto

Reviewed By: brecht

CC: dingto, venomgfx

Differential Revision: https://developer.blender.org/D317
2014-03-07 23:16:33 +01:00
eff3bd4e98 Fix T38439: allow IOR in range [0, inf] instead of [1, inf] in Cycles.
The same can be achieved by flipping normals on the mesh, but it can be
convenient to do this in the shader.
2014-02-03 17:08:34 +01:00
Thomas Dinges
e9984653a8 Cycles: Fix Wave texture difference between OSL and SVM, OSL wasn't using the "Scale" properly for distortion. 2014-01-13 22:01:39 +01:00
Campbell Barton
64fc94e93f Code Cleanup: osl style 2014-01-06 13:58:33 +11:00
9cd2b19999 Cycles Volume Render: generated texture coordinates for volume render.
This does not support staying fixed while the surface deforms, but for static
meshes it should match up with the surface texture coordinates. Implemented
as a matrix transform from objects space to mesh texture space.

Making this work for deforming surfaces would be quite complicated, you might
need something like harmonic coordinates as used in the mesh deform modifier,
probably will not be possible anytime soon.
2013-12-31 17:38:26 +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
28d5f2ab60 Cycles: Update stdosl.h to OSL 1.4.0. (includes new aastep functions). 2013-12-08 12:20:15 +01:00
Lukas Toenne
89fc09b3be Fix for OSL bug reported on IRC by Pablo Vasquez: Clamp option of the math node in OSL produces bad results. Really stupid bug, OSL math node was assigning the clamped 1st input value instead of the
clamped result of the actual operation.
2013-10-23 11:30:18 +00:00
Campbell Barton
8fd52b3433 style cleanup 2013-10-10 17:28:01 +00:00
Thomas Dinges
3d4bbd278a * Code cleanup for M_PI code. 2013-10-10 17:14:04 +00:00
Brecht Van Lommel
a200256451 Fix windows scons OSL build error, just use quotes now instead of array. 2013-10-09 20:11:18 +00:00
Brecht Van Lommel
bde4148375 Fix OSL shader build failing with spaces in the path to build directory,
patch by Campbell.
2013-10-09 18:48:32 +00:00