Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Dinges <blender@dingto.org>2013-06-11 01:55:41 +0400
committerThomas Dinges <blender@dingto.org>2013-06-11 01:55:41 +0400
commit9020df976ca37104a36a90d43c6e5b33c24cdbd2 (patch)
tree8ce649d25f4de2f84b340a9d8328ef39ed8b2851 /intern/cycles/kernel/shaders/node_color.h
parentc03e638cf310cde57ede10d3d9c90aecce007b15 (diff)
parentcf359f6c7f259bf669a144c9a455fe79780fc6ff (diff)
Cycles / Wavelength to RGB node:
* Added a node to convert wavelength (in nanometers, from 380nm to 780nm) to RGB values. This can be useful to match real world colors easier. * Code cleanup: ** Moved color functions (xyz and hsv) into dedicated utility files. ** Remove svm_lerp(), use interp() instead. Documentation: http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More#Wavelength Example render: http://www.pasteall.org/pic/show.php?id=53202 This is part of my GSoC 2013. (revisions 57322, 57326, 57335 and 57367 from soc-2013-dingto).
Diffstat (limited to 'intern/cycles/kernel/shaders/node_color.h')
-rw-r--r--intern/cycles/kernel/shaders/node_color.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/intern/cycles/kernel/shaders/node_color.h b/intern/cycles/kernel/shaders/node_color.h
index c6b5d740f6a..92bd39b5828 100644
--- a/intern/cycles/kernel/shaders/node_color.h
+++ b/intern/cycles/kernel/shaders/node_color.h
@@ -58,6 +58,26 @@ color color_unpremultiply(color c, float alpha)
/* Color Operations */
+color xyY_to_xyz(float x, float y, float Y)
+{
+ float X, Z;
+
+ if (y != 0.0) X = (x / y) * Y;
+ else X = 0.0;
+
+ if (y != 0.0 && Y != 0.0) Z = ((1.0 - x - y) / y) * Y;
+ else Z = 0.0;
+
+ return color(X, Y, Z);
+}
+
+color xyz_to_rgb(float x, float y, float z)
+{
+ return color( 3.240479 * x + -1.537150 * y + -0.498535 * z,
+ -0.969256 * x + 1.875991 * y + 0.041556 * z,
+ 0.055648 * x + -0.204043 * y + 1.057311 * z);
+}
+
color rgb_to_hsv(color rgb)
{
float cmax, cmin, h, s, v, cdelta;