Cycles / OSL: Updare stdosl.h to 1.7.1.

This updates our file to OSL 1.7.1, which comes with some new inbuilt
features:

- linearstep()
- smooth_linearstep()

- hash()
- getchar()
This commit is contained in:
Thomas Dinges 2016-02-05 00:02:35 +01:00
parent 208a49b1c3
commit da7ddb69e9

@ -433,6 +433,35 @@ normal step (normal edge, normal x) BUILTIN;
float step (float edge, float x) BUILTIN;
float smoothstep (float edge0, float edge1, float x) BUILTIN;
float linearstep (float edge0, float edge1, float x) {
float result;
if (edge0 != edge1) {
float xclamped = clamp (x, edge0, edge1);
result = (xclamped - edge0) / (edge1 - edge0);
} else { // special case: edges coincide
result = step (edge0, x);
}
return result;
}
float smooth_linearstep (float edge0, float edge1, float x_, float eps_) {
float result;
if (edge0 != edge1) {
float rampup (float x, float r) { return 0.5/r * x*x; }
float width_inv = 1.0 / (edge1 - edge0);
float eps = eps_ * width_inv;
float x = (x_ - edge0) * width_inv;
if (x <= -eps) result = 0;
else if (x >= eps && x <= 1.0-eps) result = x;
else if (x >= 1.0+eps) result = 1;
else if (x < eps) result = rampup (x+eps, 2.0*eps);
else /* if (x < 1.0+eps) */ result = 1.0 - rampup (1.0+eps - x, 2.0*eps);
} else {
result = step (edge0, x_);
}
return result;
}
float aastep (float edge, float s, float dedge, float ds) {
// Box filtered AA step
float width = fabs(dedge) + fabs(ds);
@ -455,8 +484,9 @@ float aastep (float edge, float s) {
// String functions
int strlen (string s) BUILTIN;
int hash (string s) BUILTIN;
int getchar (string s, int index) BUILTIN;
int startswith (string s, string prefix) BUILTIN;
int endswith (string s, string suffix) BUILTIN;
string substr (string s, int start, int len) BUILTIN;