-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MaterialX 1.36 additions: rotate, transforms, rgb/hsv, extract, separ…
…ate (#905) * Add a variant of rotate() that just takes an axis, rotate about the origin. * MaterialX: add rotate node (new with MaterialX 1.36) * rotate2d note is kept for back-compatibility, but considered deprecated, since it was dropped from 1.36. * MaterialX: implement new transformpoint, transformvector, transformnormal nodes * MaterialX: add new nodes rgbtohsv, hsvtorgb * MaterialX: add new 1.36 node 'hsvadjust', deprecate 'hueshift' * MatrialX: Add new 1.36 nodes: extract, separate
- Loading branch information
Showing
19 changed files
with
423 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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_extract_TYPE_SUFFIX | ||
[[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] | ||
( | ||
TYPE in = TYPE_ZERO, | ||
int index = 0, | ||
output float out = 0 | ||
) | ||
{ | ||
out = extract (in, index); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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_rotate_TYPE_SUFFIX | ||
[[ string help = "Rotates a vector2 value about an axis centered at the origin." ]] | ||
( | ||
TYPE in = TYPE_ZERO, | ||
float amount = 0 | ||
[[ string help = "Amount to rotate, in degrees" ]], | ||
vector axis = vector(0,0,1) | ||
[[ string help = "Axis about which to rotate (only used for 3D case)" ]], | ||
output TYPE out = TYPE_ZERO | ||
) | ||
{ | ||
out = rotate (in, radians(amount), axis); | ||
} |
Oops, something went wrong.