SMOOTHSTEP(3clc)
π« 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 ifedge0 β₯ edge1, or ifx,edge0, oredge1is 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
gentypemeans the function can takefloat,float2,float3,float4,float8,float16,double,double2,double3,double4,double8, ordouble16as the type for the arguments. - the generic type name
gentypefmeans the function can takefloat,float2,float3,float4,float8, orfloat16as the type for the arguments. - the generic type name
gentypedmeans the function can takedouble,double2,double3,double4,double8, ordouble16as 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 βοΈ
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 π
- 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
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms