SMOOTHSTEP(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’« SMOOTHSTEP(3clc) β€” the OpenCL Manual, bestie edition πŸ’«

okay so welcome to the smoothstep page from the OpenCL Manual, and honestly? she's a little icon. no cap. let's get into it 🫢


✨ NAME ✨

smoothstep β€” step and interpolate, but make it smooth πŸ’…


🌸 SYNOPSIS 🌸

gentype smoothstep(gentype edge0, gentype edge1, gentype x);

gentypef smoothstep(float edge0, float edge1, gentypef x);

gentyped smoothstep(double edge0, double edge1, gentyped x);

gentype smoothstep (half edge0, half edge1, gentype x)   // if half extension enabled

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: smoothstep gives you back 0.0 if x ≀ edge0, and 1.0 if x β‰₯ edge1. and when edge0 < x < edge1? it does that gorgeous smooth Hermite interpolation thing between 0 and 1. πŸŽ€

it's giving "threshold function but make it seamless." like when you want a hard cutoff but the transition needs to be soft β€” this is her moment. main character energy fr fr.

it's literally equivalent to this:

gentype t;
t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
return t * t * (3 - 2 * t);
πŸ’€ careful bestie!! results are undefined if edge0 β‰₯ edge1, or if x, edge0, or edge1 is a NaN. so like… don't do that. seriously. don't.

πŸ“ NOTES πŸ“

okay, type-name lore time, because the generics here are doing the most:

  • the generic type name gentype means the function can take float, float2, float3, float4, float8, float16, double, double2, double3, double4, double8, or double16 as the type for the arguments.
  • the generic type name gentypef means the function can take float, float2, float3, float4, float8, or float16 as the type for the arguments.
  • the generic type name gentyped means the function can take double, double2, double3, double4, double8, or double16 as the type for the arguments.

also!! the built-in common functions are implemented using the round to nearest even rounding mode. slay. 🧚

if extended with cl_khr_fp16(3clc), the generic type name gentype may indicate half and half{2|3|4|8|16} as arguments and return values. 🌈

and last but not least: this function can be implemented using contractions such as mad(3clc) or fma(3clc). πŸ”₯


πŸ“œ SPECIFICATION πŸ“œ

OpenCL Specification[1]


πŸ‘€ SEE ALSO πŸ‘€


πŸ‘‘ AUTHORS πŸ‘‘

The Khronos Group


Copyright Β© 2007-2011 The Khronos Group Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.


πŸŽ€ NOTES πŸŽ€

  1. OpenCL Specification β€” page 260, section 6.12.4 - Common Functions

and that's the whole page, bestie!! πŸ₯ΉπŸ’– this one came straight from The Khronos Group, dated 01/14/2021 β€” so if you're citing her, that's the tea. go forth and interpolate smoothly. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from