   smoothstep intrinsic (HLSL)
  I've been writing lots of procedural effect shaders recently, and have been using the smoothstep intrinsic a lot.e.g.const float2 weights1 = float2(0,1   ) * curveScale;const float4 weights2 = float4(0,1,1,2    ) * curveScale;const float4 weights3 = float4(    1,2,2,3) * curveScale;const float2 weights4 = float2(   2,3) * curveScale;float weight1 = 1-smoothstep ( weights1.x, weights1.y, h );float weight2 =   smoothstep2( weights2.x, weights2.y, weights2.z, weights2.w, h );float weight3 =   smoothstep2( weights3.x, weights3.y, weights3.z, weights3.w, h );float weight4 =   smoothstep ( weights4.x, weights4.y, h );...float smoothstep2( float min1, float max1, float min2, float max2, float input ){return smoothstep(min1, max1, input) * (1 - smoothstep(min2, max2, input));}What I'm wondering is what the performance of this function is like. The MSDN says it performs a Hermite interpolation rather than a simple linear one, so I'm guessing that it would be comparatively slow unless there's some hardware that corresponds to this intrinsic.Would I be better off using something like this instead?float linearstep( float lo, float hi, float input ){float diff = hi-lo;float offset = input-lo;return min(1.0, max(0.0, offset/diff));}
  I just profiled the shader that the above code is from (a 4-weight gradient), using smoothstep (312 MPix/s) and linearstep (194 MPix/s). Obviously this intrinsic is there for a reason - but can anyone tell me why this built-in hermite interpolation is so much faster than my hand-coded linear version?   ;  Naturally, any operation done in hardware, with hardware designed specifically to perform that operation would be faster than doing it using hardware designed to perform generic operations. There's probably hardware available in the GPU that can perform the linear-step (or part of it), faster than the generic hardware version can.Strictly speaking, your implementation isn't optimal, since the max-min combo could be swapped for a saturate() instric instead. It probably wouldn't make a difference since the compiler is already optimizing, but maybe it's missing it.   ;  Try using the lerp intrinsic for the linear interpolation.   ;  Thanks guys, lerp is what I was looking for.I just thought it was strange to only have built-in smooth interpolation but not linear.   