Commit Graph

37 Commits

Author SHA1 Message Date
Brecht Van Lommel
ceed3ef640 Fix #32907: failure rendering a complex node setup, hitting fixed max number
of closures limit. Optimized the code now so it can handle more.

Change SVM mix/add closure handling, now we transform the node graph so that
the mix weights are fed into the closure nodes directly.
2012-11-26 21:59:41 +00:00
Brecht Van Lommel
90cdf34f56 Fix #32796: cycles did not support image auto refresh option. 2012-11-21 13:00:51 +00:00
Brecht Van Lommel
ab1b5af08d Fix cycles OSL missing support for texture mapping paramaters found in texture
properties tab.
2012-11-20 17:40:10 +00:00
Brecht Van Lommel
27d647dcf8 Cycles: 4 new nodes.
* Tangent: generate a tangent direction for anisotropic shading. Can be either
  radial around X/Y/Z axis, or from a UV map. The default tangent for the
  anisotropic BSDF and geometry node is now always radial Z, for UV tangent use
  this node now.

http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More#Tangent

* Normal Map: generate a perturbed normal from an RGB normal map image. This
  is usually chained with an Image Texture node in the color input, to specify
  the normal map image. For tangent space normal maps, the UV coordinates for
  the image must match, and the image texture should be set to Non-Color mode
  to give correct results.

http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More#Normal_Map

* Refraction BSDF: for best results this node should be considered as a building
  block and not be used on its own, but rather mixed with a glossy node using a
  fresnel type factor. Otherwise it will give quite dark results at the edges for
  glossy refraction.

http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Shaders#Refraction

* Ambient Occlusion: controls the amount of AO a surface receives, rather than
  having just a global factor in the world. Note that this outputs a shader and
  not a color, that's for another time.

http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Shaders#Ambient_Occlusion
2012-11-06 19:59:02 +00:00
Brecht Van Lommel
2ba840652d Cycles: improve Anisotropic BSDF node, changing the Roughness U/V inputs to
Roughness, Anisotropy and Rotation. Also a fix for automatic tangents and
OSL attribute handling.

Meaning of new sockets explained in the documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Shaders#Anisotropic
2012-11-04 22:31:32 +00:00
Brecht Van Lommel
eb87529e23 Cycles OSL: shader script node
Documentation here:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/OSL
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.65/Cycles

These changes require an OSL build from this repository:
https://github.com/DingTo/OpenShadingLanguage

The lib/ OSL has not been updated yet, so you might want to keep OSL disabled
until that is done.

Still todo:
* Auto update for external .osl files not working currently, press update manually
* Node could indicate better when a refresh is needed
* Attributes like UV or generated coordinates may be missing when requested from
  an OSL shader, need a way to request them to be loaded by cycles
* Expose string, enum and other non-socket parameters
* Scons build support

Thanks to Thomas, Lukas and Dalai for the implementation.
2012-11-03 14:32:35 +00:00
Brecht Van Lommel
fe09b24e86 Cycles: per-BSDF normal input and new Bump node.
Each BSDF node now has a Normal input, which can be used to set a custom normal
for the BSDF, for example if you want to have only bump on one of the layers in
a multilayer material.

The Bump node can be used to generate a normal from a scalar value, the same as
what happens when you connect a scalar value to the displacement output.

Documentation has been updated with the latest changes:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes

Patch by Agustin Benavidez, some implementation tweaks by me.
2012-10-10 15:56:43 +00:00
Brecht Van Lommel
f0a9b66469 Cycles: Anisotropic BSDF enabled, with tangents now computed from the active UV map.
It's using the Ward BSDF currently, which has some energy loss so might be a bit
dark. More/better BSDF options can be implemented later.

Patch by Mike Farnsworth, some modifications by me. Currently it's not possible yet
to set a custom tangent, that will follow as part of per-bsdf normals patch.
2012-10-10 13:02:20 +00:00
Brecht Van Lommel
fedc8e1722 Cycles: add "From Dupli" option for texture coordinate node. This gets the
Generated and UV coordinates from the duplicator of instance instead of the
object itself.

This was used in e.g. Big Buck Bunny for texturing instanced feathers with
a UV map on the bird. Many files changed, mainly to do some refactoring to
get rid of G.rendering global in duplilist code.
2012-10-04 21:40:39 +00:00
Brecht Van Lommel
adea12cb01 Cycles: merge of changes from tomato branch.
Regular rendering now works tiled, and supports save buffers to save memory
during render and cache render results.

Brick texture node by Thomas.
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Textures#Brick_Texture

Image texture Blended Box Mapping.
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Textures#Image_Texture
http://mango.blender.org/production/blended_box/

Various bug fixes by Sergey and Campbell.
* Fix for reading freed memory in some node setups.
* Fix incorrect memory read when synchronizing mesh motion.
* Fix crash appearing when direct light usage is different on different layers.
* Fix for vector pass gives wrong result in some circumstances.
* Fix for wrong resolution used for rendering Render Layer node.
* Option to cancel rendering when doing initial synchronization.
* No more texture limit when using CPU render.
* Many fixes for new tiled rendering.
2012-09-04 13:29:07 +00:00
Dalai Felinto
ded5e9cd23 clamp for Mix node
the implementation was following my early commit for Math node
I haven't had a chance to run those through Brecht, but would like to do eventually. (they work fine though)
2012-08-30 06:31:02 +00:00
Dalai Felinto
c052ebda8e Cycles bugfix: [32431] Cycles Math Node : Clamp does not work
the OSL solution is slightly different than the svm, but I think it's fine.

thanks Lukas Toenne for helping with a fix on the original patch
2012-08-29 17:30:14 +00:00
Campbell Barton
2c1abe1f58 style cleanup: assignment & indentation. 2012-06-09 18:56:12 +00:00
Campbell Barton
c6cffe98fa code cleanup: removed/renamed shadow & duplicate variable definitions. 2012-06-09 18:20:40 +00:00
Lukas Toenne
5e1bbde01d Particle Info node for Cycles. This can be used to access particle information in material shaders for dupli objects. For now only the particle Age and individual Lifetime (in frames) are supported, more attributes can be added when needed.
The particle data is stored in a separate texture if any of the dupli objects uses particle info nodes in shaders. To map dupli objects onto particles the store an additional particle_index value, which is different from the simple dupli object index (only visible particles, also works for particle dupli groups mode).

Some simple use cases on the code.blender.org blog:
http://code.blender.org/index.php/2012/05/particle-info-node/
2012-06-08 16:17:57 +00:00
Brecht Van Lommel
c3e1fce775 Cycles: add Object Info node, with outputs object location, object/material
pass index, and a random number unique to the instance of the object.

This can be useful to give some variation to a single material assigned to
multiple instances, either manually controlled through the object index, based
on the object location, or randomized for each instance. 

http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More#Object_Info
2012-05-21 12:52:28 +00:00
Brecht Van Lommel
e6a84eb1b5 Cycles: add light falloff node, with quadratic/linear/constant falloff and a
smoothing factor to reduce high values near the light.
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More#Light_Falloff

Note that this was already possible to do manually with the Ray Length, but
this adds a convenient node for it. This commit also makes the mapping node
min/max option work, fixing #31348.
2012-05-07 20:24:38 +00:00
Brecht Van Lommel
bbc3d820f4 Cycles: add ColorRamp node. 2012-03-26 12:45:14 +00:00
Brecht Van Lommel
9b8dae71a5 Cycles: support for environment texture "Mirror Ball" projection mode, next to
existing "Equirectangular". This projection is useful to create light probes
from a chrome ball placed in a real scene. It expects as input a photograph of
the chrome ball, cropped so the ball just fits inside the image boundaries.

Example setup with panorama camera and mixing two (poor quality) photographs
from different viewpoints to avoid stretching and hide the photographer:
http://www.pasteall.org/pic/28036
2012-03-08 19:52:58 +00:00
Brecht Van Lommel
9fba458a7f Cycles: float texture support. Due to GPU limitations there are now 95 byte,
and 5 float image textures. For CPU render this limit will be lifted later
on with image cache support. Patch by Mike Farnsworth.

Also changed color space option in image/environment texture node, to show
options Color and Non-Color Data, instead of sRGB and Linear, this is more
descriptive, and it was not really correct to equate Non-Color Data with
Linear.
2012-03-07 12:27:18 +00:00
Dalai Felinto
335ffb0ff3 Brightness/Contrast Node for Cycles
Contrast helps to adjust IBL (HDR images used for background lighting).
Note: In the UI we are caling it Bright instead of Brightness. This copy what Blender composite is doing.
Note2: the algorithm we are using produces pure black when contrast is 100. I'm not a fan of that, but it's a division by zero. I would like to look at other algorithms (what gimp does for example). But that would be only after 2.62.
2012-01-24 16:32:31 +00:00
Brecht Van Lommel
8bfa48384d Cycles: checker texture node, patch by Thomas. 2012-01-08 14:55:43 +00:00
Lukas Toenne
5f6bd44c82 Generalized node groups for Cycles.
This allows group nodes inside other group nodes in cycles and makes the
code more generic for all possible cases, like direct group
input-to-output links and unused group sockets.

Previous code tried to connect external nodes and internal group sockets
by following links until a "real" node input/output. This quickly
becomes complicated in corner cases as described above and can lead to
unexpected behavior when the group socket is of a different type than
the internal/external sockets, but that conversion is skipped.

The new code uses the concept of "proxy nodes" similar to what the new
compositor does. Each group socket is replaced with a proxy node with a
single input and output, to which other nodes in the same tree and
internal nodes can link to. After all groups have been expanded in the
graph, these proxy nodes are removed again, adding converter nodes if
necessary.
2011-12-18 15:34:06 +00:00
Dalai Felinto
2a6fdbcccd Cycles Gamma Node
Node specially useful for Texture correction.

This is also a nice example of a simple node made from scratch in case someone wants to create their custom nodes.
Review by Brecht.
2011-12-16 20:35:06 +00:00
Dalai Felinto
3c8ab559a5 Normal Node - Cycles
reviewed by Brecht, with help from Lukas.

Note: dot is reversed compared to Blender.
In Blender Normals point outside, while in Cycles they point inside.
If you use your own custom vector with the Normal Node you will see a difference.
If you feed it with object normals it should work just as good.
2011-12-16 18:15:07 +00:00
Dalai Felinto
d15c5e51a1 Invert Color Cycles Node
as with the HSV node the OSL code is relying on the (yet to be implemented) autorename.

Also the svm code could use mix (svm_lerp) instead:
 32 . float3 color_inv = make_float3(1.0f, 1.0f, 1.0f) - color;
 35 . . stack_store_float3(stack, out_color, svm_lerp(color_inv, color, factor));

I have a feeling that each node 'program' should have the least program as possible. I'll see with Brecht later.
But overall I don't know if that's any fast. And apart from that I think we will need this kind of function to move to a library if multiple functions linked in are not a problem.
2011-12-03 23:05:35 +00:00
Dalai Felinto
78495ddf32 CameraData Input Cycles Node
----------------------------
reviewed and approved by Brecht 

Important note:
the camera Z is reverted compared to Blender render.
Now it goes from zero (camera) to positive (in front of the camera)
2011-12-02 20:36:13 +00:00
Dalai Felinto
4fd2736487 HSV Color Node for Cycles
.........................
note, the OSL code has a problem.
In the original node the input and output nodes have the same name (Color).
So this will be fixed here once Brecht come up with a nice autorenaming (or we do a doversion patch) for that.
2011-12-02 16:57:37 +00:00
Dalai Felinto
4db4a0933f SeparateRGB and CombineRGB nodes for Cycles materials
reviewed and approved by Brecht

my first OpenCL code \o/
2011-12-01 21:46:10 +00:00
Brecht Van Lommel
fb56dbc2af Cycles: procedural texture nodes reorganization. This will break existing files
using them, but rather do it now that I have the chance still. Highlights:

* Wood and Marble merged into a single Wave texture
* Clouds + Distorted Noise merged into new Noise node
* Blend renamed to Gradient
* Stucci removed, was mostly useful for old bump
* Noise removed, will come back later, didn't actually work yet
* Depth setting is now Detail socket, which accepts float values
* Scale socket instead of Size socket

http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Textures
2011-11-06 21:05:58 +00:00
Brecht Van Lommel
72929172dd Cycles: add location/rotate/scale and XYZ mapping options for all texture nodes,
to reduce the amount of nodes needed to set up a simple texture.

These are currently editable in the texture properties tab, still need to make
them available in the node editor. Projection and color modification options will
be added later, they're not implemented yet but allocated already to avoid
version patches later.

Also an issue with the XYZ mapping is that when you set one to None, texture and
material draw mode doesn't draw the image texture well, OpenGL doesn't seem to
like the degenerate texture matrix?
2011-11-04 20:58:00 +00:00
Brecht Van Lommel
310b25c388 Cycles: code refactoring to split out code from mapping node. 2011-10-12 22:42:13 +00:00
Brecht Van Lommel
136d27b350 Cycles: add some volume nodes, they don't actually do anything, this is just
to give other developers who may want to work on this to get a starting point.
2011-09-27 20:03:16 +00:00
Brecht Van Lommel
66b1dfae89 Cycles: tweaks to properties and nodes
* Passes renamed to samples
* Camera lens radius renamed to aperature size/blades/rotation
* Glass and fresnel nodes input is now index of refraction
* Glossy and velvet fresnel socket removed
* Mix/add closure node renamed to mix/add shader node
* Blend weight node added for shader mixing weights

There is some version patching code for reading existing files, but it's not
perfect, so shaders may work a bit different.
2011-09-16 13:14:02 +00:00
Brecht Van Lommel
bae896691a Cycles:
* Add alpha pass output, to use set Transparent option in Film panel.
* Add Holdout closure (OSL terminology), this is like the Sky option in the
  internal renderer, objects with this closure show the background / zero
  alpha.
* Add option to use Gaussian instead of Box pixel filter in the UI.
* Remove camera response curves for now, they don't really belong here in
  the pipeline, should be moved to compositor.

* Output full float values for rendering now, previously was only byte precision.
* Add a patch from Thomas to get a preview passes option, but still disabled
  because it isn't quite working right yet.
* CUDA: don't compile shader graph evaluation inline.
* Convert tabs to spaces in python files.
2011-08-28 13:55:59 +00:00
Brecht Van Lommel
922bb24865 Cycles: color space control for image/environment texture nodes. Ideally would
be automated but need to think about how to do this, not so simply in a node
system. But guideline for now is, for color textures set to sRGB, for things like
bump or roughness map, set to Linear.
2011-05-13 14:32:08 +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