From fd5937fd1f581d521846f2849f6b5b463d917cf6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 14 May 2011 09:42:02 +0000 Subject: Cycles: OSL build fixes, based on patch from erwin94. --- intern/cycles/kernel/osl/nodes/node_color.h | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 intern/cycles/kernel/osl/nodes/node_color.h (limited to 'intern/cycles/kernel/osl/nodes/node_color.h') diff --git a/intern/cycles/kernel/osl/nodes/node_color.h b/intern/cycles/kernel/osl/nodes/node_color.h new file mode 100644 index 00000000000..b92973d1dfe --- /dev/null +++ b/intern/cycles/kernel/osl/nodes/node_color.h @@ -0,0 +1,50 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* Color Management */ + +float color_srgb_to_scene_linear(float c) +{ + if(c < 0.04045) + return (c < 0.0)? 0.0: c * (1.0/12.92); + else + return pow((c + 0.055)*(1.0/1.055), 2.4); +} + +float color_scene_linear_to_srgb(float c) +{ + if(c < 0.0031308) + return (c < 0.0)? 0.0: c * 12.92; + else + return 1.055 * pow(c, 1.0/2.4) - 0.055; +} + +color color_srgb_to_scene_linear(color c) +{ + return color( + color_srgb_to_scene_linear(c[0]), + color_srgb_to_scene_linear(c[1]), + color_srgb_to_scene_linear(c[2])); +} + +color color_scene_linear_to_srgb(color c) +{ + return color( + color_scene_linear_to_srgb(c[0]), + color_scene_linear_to_srgb(c[1]), + color_scene_linear_to_srgb(c[2])); +} + -- cgit v1.2.3