forked from autodesk-forks/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmx_image_vector4.osl
21 lines (18 loc) · 942 Bytes
/
mx_image_vector4.osl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "$fileTransformUv"
void mx_image_vector4(string file, string layer, vector4 default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output vector4 out)
{
if (file == "" ||
(uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) ||
(vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0)))
{
out = default_value;
return;
}
color missingColor = color(default_value.x, default_value.y, default_value.z);
float missingAlpha = default_value.w;
vector2 st = mx_transform_uv(texcoord);
float alpha;
color rgb = texture(file, st.x, st.y, "alpha", alpha, "subimage", layer,
"missingcolor", missingColor, "missingalpha", missingAlpha, "swrap", uaddressmode, "twrap", vaddressmode);
out = vector4(rgb[0], rgb[1], rgb[2], alpha);
}