forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f20acdd
commit 46f8455
Showing
4 changed files
with
141 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Adds some syntactic sugar allowing mixing vector4 and color4 as | ||
// arguments of some binary operators used by OCIO transform code. | ||
|
||
vector4 __operator__mul__(matrix m, vector4 v) | ||
{ | ||
return vector4(v.x * m[0][0] + v.y * m[0][1] + v.z * m[0][2] + v.w * m[0][3], | ||
v.x * m[1][0] + v.y * m[1][1] + v.z * m[1][2] + v.w * m[1][3], | ||
v.x * m[2][0] + v.y * m[2][1] + v.z * m[2][2] + v.w * m[2][3], | ||
v.x * m[3][0] + v.y * m[3][1] + v.z * m[3][2] + v.w * m[3][3]); | ||
} | ||
|
||
vector4 __operator__mul__(color4 c, vector4 v) | ||
{ | ||
return vector4(c.rgb.r, c.rgb.g, c.rgb.b, c.a) * v; | ||
} | ||
|
||
vector4 __operator__mul__(vector4 v, color4 c) | ||
{ | ||
return v * vector4(c.rgb.r, c.rgb.g, c.rgb.b, c.a); | ||
} | ||
|
||
vector4 __operator__sub__(color4 c, vector4 v) | ||
{ | ||
return vector4(c.rgb.r, c.rgb.g, c.rgb.b, c.a) - v; | ||
} | ||
|
||
vector4 __operator__add__(vector4 v, color4 c) | ||
{ | ||
return v + vector4(c.rgb.r, c.rgb.g, c.rgb.b, c.a); | ||
} | ||
|
||
vector4 __operator__add__(color4 c, vector4 v) | ||
{ | ||
return vector4(c.rgb.r, c.rgb.g, c.rgb.b, c.a) + v; | ||
} | ||
|
||
vector4 pow(color4 c, vector4 v) | ||
{ | ||
return pow(vector4(c.rgb.r, c.rgb.g, c.rgb.b, c.a), v); | ||
} | ||
|
||
vector4 max(vector4 v, color4 c) | ||
{ | ||
return max(v, vector4(c.rgb.r, c.rgb.g, c.rgb.b, c.a)); | ||
} |
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