Skip to content

Commit

Permalink
MaterialX: add new nodes rgbtohsv, hsvtorgb
Browse files Browse the repository at this point in the history
  • Loading branch information
lgritz committed Jul 26, 2018
1 parent 6da478f commit 21533e9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/shaders/MaterialX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ make_mx_flavors (mx_dotproduct.mx TYPES vector vector2 vector4)
make_mx_flavors (mx_frame.mx TYPES float)
make_mx_flavors (mx_geomattrvalue.mx TYPES int bool string)
make_mx_flavors (mx_heighttonormal.mx TYPES vector)
make_mx_flavors (mx_hsvtorgb.mx TYPES color color4)
make_mx_flavors (mx_hueshift.mx TYPES color color4)
make_mx_flavors (mx_in.mx TYPES color2 color4)
make_mx_flavors (mx_luminance.mx TYPES color color4)
Expand All @@ -164,6 +165,7 @@ make_mx_flavors (mx_combine_vv.mx TYPES vector4)
make_mx_flavors (mx_position.mx TYPES vector)
make_mx_flavors (mx_premult.mx TYPES color color2 color4)
make_mx_flavors (mx_rotate2d.mx TYPES vector2)
make_mx_flavors (mx_rgbtohsv.mx TYPES color color4)
make_mx_flavors (mx_saturate.mx TYPES color color4)
make_mx_flavors (mx_scale.mx TYPES vector vector2)
make_mx_flavors (mx_tangent.mx TYPES vector)
Expand Down
2 changes: 2 additions & 0 deletions src/shaders/MaterialX/build_materialX_osl.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
'mx_geomattrvalue': ALL_TYPES + ['bool', 'string', 'int'],
'mx_geomcolor': ['float', 'color', 'color2', 'color4'],
'mx_heighttonormal': ['vector'],
'mx_hsvtorgb' : ['color', 'color4'],
'mx_hueshift': ['color', 'color4'],
'mx_image': ALL_TYPES,
'mx_ln' : ALL_TYPES + ['int'],
Expand Down Expand Up @@ -281,6 +282,7 @@
'mx_remap': ALL_TYPES,
'mx_remap_float': ['color', 'color2', 'color4', 'vector', 'vector2', 'vector4'],
'mx_rotate2d': ['vector2'],
'mx_rgbtohsv' : ['color', 'color4'],
'mx_saturate': ['color', 'color4'],
'mx_scale': ['vector', 'vector2'],
'mx_sign': ALL_TYPES,
Expand Down
18 changes: 18 additions & 0 deletions src/shaders/MaterialX/mx_hsvtorgb.mx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al.
// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE
//
// MaterialX specification (c) 2017 Lucasfilm Ltd.
// http://www.materialx.org/

#include "mx_funcs.h"

shader mx_hsvtorgb
[[ string help = "Transform a color from HSV to RGB" ]]
(
TYPE in = TYPE_ZERO
[[ string help = "Input color" ]],
output TYPE out = TYPE_ZERO
)
{
out = transformc ("hsv", "rgb", in);
}
18 changes: 18 additions & 0 deletions src/shaders/MaterialX/mx_rgbtohsv.mx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al.
// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE
//
// MaterialX specification (c) 2017 Lucasfilm Ltd.
// http://www.materialx.org/

#include "mx_funcs.h"

shader mx_rgbtohsv
[[ string help = "Transform a color from RGB to HSV" ]]
(
TYPE in = TYPE_ZERO
[[ string help = "Input color" ]],
output TYPE out = TYPE_ZERO
)
{
out = transformc ("rgb", "hsv", in);
}
4 changes: 4 additions & 0 deletions src/shaders/color4.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,7 @@ color4 atan2(color4 a, color4 b)
}


color4 transformc (string fromspace, string tospace, color4 C)
{
return color4 (transformc (fromspace, tospace, C.rgb), C.a);
}

0 comments on commit 21533e9

Please sign in to comment.