[Bf-blender-cvs] [da7ddb6] master: Cycles / OSL: Updare stdosl.h to 1.7.1.
Thomas Dinges
noreply at git.blender.org
Fri Feb 5 00:05:59 CET 2016
Commit: da7ddb69e9f30d8bb480fb991a17b01113ad36ec
Author: Thomas Dinges
Date: Fri Feb 5 00:02:35 2016 +0100
Branches: master
https://developer.blender.org/rBda7ddb69e9f30d8bb480fb991a17b01113ad36ec
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()
===================================================================
M intern/cycles/kernel/shaders/stdosl.h
===================================================================
diff --git a/intern/cycles/kernel/shaders/stdosl.h b/intern/cycles/kernel/shaders/stdosl.h
index acf3ae8..8d5d374 100644
--- a/intern/cycles/kernel/shaders/stdosl.h
+++ b/intern/cycles/kernel/shaders/stdosl.h
@@ -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;
More information about the Bf-blender-cvs
mailing list