Skip to content

Commit

Permalink
MaterialX: add new 1.36 node 'hsvadjust', deprecate 'hueshift'
Browse files Browse the repository at this point in the history
  • Loading branch information
lgritz committed Jul 27, 2018
1 parent 0e1177e commit f641b91
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/shaders/MaterialX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ 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_hsvadjust.mx TYPES color color4)
make_mx_flavors (mx_hsvtorgb.mx TYPES color color4)
make_mx_flavors (mx_hueshift.mx TYPES color color4)
make_mx_flavors (mx_hueshift.mx TYPES color color4) # DEPRECATED in MX 1.36
make_mx_flavors (mx_in.mx TYPES color2 color4)
make_mx_flavors (mx_luminance.mx TYPES color color4)
make_mx_flavors (mx_magnitude.mx TYPES vector vector2 vector4)
Expand All @@ -166,7 +167,7 @@ make_mx_flavors (mx_position.mx TYPES vector)
make_mx_flavors (mx_premult.mx TYPES color color2 color4)
make_mx_flavors (mx_rgbtohsv.mx TYPES color color4)
make_mx_flavors (mx_rotate.mx TYPES vector vector2)
make_mx_flavors (mx_rotate2d.mx TYPES vector2) # Deprecated in MX 1.36
make_mx_flavors (mx_rotate2d.mx TYPES vector2) # DEPRECATED in MX 1.36
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
3 changes: 2 additions & 1 deletion src/shaders/MaterialX/build_materialX_osl.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@
'mx_geomattrvalue': ALL_TYPES + ['bool', 'string', 'int'],
'mx_geomcolor': ['float', 'color', 'color2', 'color4'],
'mx_heighttonormal': ['vector'],
'mx_hsvadjust' : ['color', 'color4'],
'mx_hsvtorgb' : ['color', 'color4'],
'mx_hueshift': ['color', 'color4'],
'mx_hueshift': ['color', 'color4'], # DEPRECATED in MX 1.36
'mx_image': ALL_TYPES,
'mx_ln' : ALL_TYPES + ['int'],
'mx_max': ALL_TYPES,
Expand Down
41 changes: 41 additions & 0 deletions src/shaders/MaterialX/mx_hsvadjust.mx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 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"


//
// Shift the hue of a color by the given amount.
//
color hsvadjust(color in, vector amount)
{
color hsv3 = transformc("rgb","hsv", in);
hsv3[0] += amount[0]; // add hue adjustment
hsv3[1] *= amount[1]; // multiply saturation adjustment
hsv3[2] *= amount[2]; // multiply value adjustment
hsv3[0] = fmod(hsv3[0], 1.0);
color out = transformc("hsv","rgb", hsv3);
return out;
}

color4 hsvadjust(color4 in, vector amount)
{
return color4 (hsvadjust(in.rgb, amount), in.a);
}



shader mx_hsvadjust_TYPE_SUFFIX
[[ string help = "Adjust the hue, saturation, and value of a color." ]]
(
TYPE in = TYPE_ZERO,
vector amount = vector(0,1,1)
[[ string help = "Adjustment (hue add, sat mul, val mul)" ]],
output TYPE out = TYPE_ZERO
)
{
out = hsvadjust(in, amount);
}
5 changes: 5 additions & 0 deletions src/shaders/MaterialX/mx_hueshift.mx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include "mx_funcs.h"


//
// NOTE: This node is DEPRECATED as of MaterialX 1.36
//


//
// Shift the hue of a color by the given amount.
//
Expand Down

0 comments on commit f641b91

Please sign in to comment.