@@ -319,73 +319,73 @@ point step (point edge, point x) BUILTIN;
319
319
vector step (vector edge , vector x ) BUILTIN ;
320
320
normal step (normal edge , normal x ) BUILTIN ;
321
321
float step (float edge , float x ) BUILTIN ;
322
- float smoothstep (float edge0 , float edge1 , float x ) BUILTIN ;
322
+ float smoothstep (float low , float high , float x ) BUILTIN ;
323
323
324
- color smoothstep (color edge0 , color edge1 , color x )
324
+ color smoothstep (color low , color high , color x )
325
325
{
326
- return color (smoothstep (edge0 [0 ], edge1 [0 ], x [0 ]),
327
- smoothstep (edge0 [1 ], edge1 [1 ], x [1 ]),
328
- smoothstep (edge0 [2 ], edge1 [2 ], x [2 ]));
326
+ return color (smoothstep (low [0 ], high [0 ], x [0 ]),
327
+ smoothstep (low [1 ], high [1 ], x [1 ]),
328
+ smoothstep (low [2 ], high [2 ], x [2 ]));
329
329
}
330
- vector smoothstep (vector edge0 , vector edge1 , vector x )
330
+ vector smoothstep (vector low , vector high , vector x )
331
331
{
332
- return vector (smoothstep (edge0 [0 ], edge1 [0 ], x [0 ]),
333
- smoothstep (edge0 [1 ], edge1 [1 ], x [1 ]),
334
- smoothstep (edge0 [2 ], edge1 [2 ], x [2 ]));
332
+ return vector (smoothstep (low [0 ], high [0 ], x [0 ]),
333
+ smoothstep (low [1 ], high [1 ], x [1 ]),
334
+ smoothstep (low [2 ], high [2 ], x [2 ]));
335
335
}
336
336
337
- float linearstep (float edge0 , float edge1 , float x ) {
337
+ float linearstep (float low , float high , float x ) {
338
338
float result ;
339
- if (edge0 != edge1 ) {
340
- float xclamped = clamp (x , edge0 , edge1 );
341
- result = (xclamped - edge0 ) / (edge1 - edge0 );
339
+ if (low != high ) {
340
+ float xclamped = clamp (x , low , high );
341
+ result = (xclamped - low ) / (high - low );
342
342
} else { // special case: edges coincide
343
- result = step (edge0 , x );
343
+ result = step (low , x );
344
344
}
345
345
return result ;
346
346
}
347
- color linearstep (color edge0 , color edge1 , color x )
347
+ color linearstep (color low , color high , color x )
348
348
{
349
- return color (linearstep (edge0 [0 ], edge1 [0 ], x [0 ]),
350
- linearstep (edge0 [1 ], edge1 [1 ], x [1 ]),
351
- linearstep (edge0 [2 ], edge1 [2 ], x [2 ]));
349
+ return color (linearstep (low [0 ], high [0 ], x [0 ]),
350
+ linearstep (low [1 ], high [1 ], x [1 ]),
351
+ linearstep (low [2 ], high [2 ], x [2 ]));
352
352
}
353
- vector linearstep (vector edge0 , vector edge1 , vector x )
353
+ vector linearstep (vector low , vector high , vector x )
354
354
{
355
- return vector (linearstep (edge0 [0 ], edge1 [0 ], x [0 ]),
356
- linearstep (edge0 [1 ], edge1 [1 ], x [1 ]),
357
- linearstep (edge0 [2 ], edge1 [2 ], x [2 ]));
355
+ return vector (linearstep (low [0 ], high [0 ], x [0 ]),
356
+ linearstep (low [1 ], high [1 ], x [1 ]),
357
+ linearstep (low [2 ], high [2 ], x [2 ]));
358
358
}
359
359
360
- float smooth_linearstep (float edge0 , float edge1 , float x_ , float eps_ ) {
360
+ float smooth_linearstep (float low , float high , float x_ , float eps_ ) {
361
361
float result ;
362
- if (edge0 != edge1 ) {
362
+ if (low != high ) {
363
363
float rampup (float x , float r ) { return 0.5 /r * x * x ; }
364
- float width_inv = 1.0 / (edge1 - edge0 );
364
+ float width_inv = 1.0 / (high - low );
365
365
float eps = eps_ * width_inv ;
366
- float x = (x_ - edge0 ) * width_inv ;
366
+ float x = (x_ - low ) * width_inv ;
367
367
if (x <= - eps ) result = 0 ;
368
368
else if (x >= eps && x <= 1.0 - eps ) result = x ;
369
369
else if (x >= 1.0 + eps ) result = 1 ;
370
370
else if (x < eps ) result = rampup (x + eps , 2.0 * eps );
371
371
else /* if (x < 1.0+eps) */ result = 1.0 - rampup (1.0 + eps - x , 2.0 * eps );
372
372
} else {
373
- result = step (edge0 , x_ );
373
+ result = step (low , x_ );
374
374
}
375
375
return result ;
376
376
}
377
377
378
- color smooth_linearstep (color edge0 , color edge1 , color x , color eps )
378
+ color smooth_linearstep (color low , color high , color x , color eps )
379
379
{
380
- return color (smooth_linearstep (edge0 [0 ], edge1 [0 ], x [0 ], eps [0 ]),
381
- smooth_linearstep (edge0 [1 ], edge1 [1 ], x [1 ], eps [1 ]),
382
- smooth_linearstep (edge0 [2 ], edge1 [2 ], x [2 ], eps [2 ]));
380
+ return color (smooth_linearstep (low [0 ], high [0 ], x [0 ], eps [0 ]),
381
+ smooth_linearstep (low [1 ], high [1 ], x [1 ], eps [1 ]),
382
+ smooth_linearstep (low [2 ], high [2 ], x [2 ], eps [2 ]));
383
383
}
384
- vector smooth_linearstep (vector edge0 , vector edge1 , vector x , vector eps )
384
+ vector smooth_linearstep (vector low , vector high , vector x , vector eps )
385
385
{
386
- return vector (smooth_linearstep (edge0 [0 ], edge1 [0 ], x [0 ], eps [0 ]),
387
- smooth_linearstep (edge0 [1 ], edge1 [1 ], x [1 ], eps [1 ]),
388
- smooth_linearstep (edge0 [2 ], edge1 [2 ], x [2 ], eps [2 ]));
386
+ return vector (smooth_linearstep (low [0 ], high [0 ], x [0 ], eps [0 ]),
387
+ smooth_linearstep (low [1 ], high [1 ], x [1 ], eps [1 ]),
388
+ smooth_linearstep (low [2 ], high [2 ], x [2 ], eps [2 ]));
389
389
}
390
390
391
391
float aastep (float edge , float s , float dedge , float ds ) {
0 commit comments