Several Edits Later: Finally got my quote tags in the right places
From the MS DX9 SDK:
Quote: "faceforward (DirectX HLSL)
Flips the surface-normal (if needed) to face in a direction opposite to i; returns the result in n.
ret faceforward(n, i, ng)
This function uses the following formula: −n × sign(dot(i, ng)).
Parameters
n
[in] The resulting floating-point surface-normal vector.
i
[in] A floating-point, incident vector that points from the view position to the shading position.
ng
[in] A floating-point surface-normal vector.
Return Value
A floating-point, surface normal vector that is facing the view direction.
"
I guess that could be useful for making sure that polys are lit from both sides - otherwise polys lit from behind wouldn't get lit.
The smoothstep function uses simple linear interpolation between 0 and 1 when the x value lies between min and max. For example, if min = 100, max = 500, then
smoothstep(100, 500, 50) = 0 (because 50 is less than 100)
smoothstep(100, 500, 200) = 0.25 (because 200 is one quarter of the way between 100 and 500)
smoothstep(100, 500, 450) = 0.875 (because 450 is 87.5% of the way between 100 and 500)
smoothstep(100, 500, 800) = 1 (because 800 is greater than 500)
This command is useful for things like fog or where you want a smooth transition betwen two colours.
I think you've miscopied or misquoted the ddx description. Here's what the MS DX9 SDK says:
Quote: "ddx (DirectX HLSL)
Returns the partial derivative of the specified value with respect to the screen-space x-coordinate.
ret ddx(x)
This function computes the partial derivative with respect to the screen-space x-coordinate. To compute the partial derivative with respect to the screen-space y-coordinate, use the ddy function.
This function is only supported in pixel shaders.
Parameters
x
[in] The specified value.
Return Value
The partial derivative of the x parameter."
I can see why you find that confusing - they've used "x" in two different senses, i.e. the screen-space coordinate x and the argument of the ddx function.
My understanding of this command is that it works as follows. Suppose, for example, you want to know how much an object's world-space position changes from one screen pixel to the next. Then your pixel shader would need to be passed a suitable variable such as "float4 wpos : texcoord3;" from the vertex shader. In the pixel shader you could use "float3 xChange = ddx(wpos.xyz);". How you might use that information is another matter entirely - and I haven't used it so I can't guarantee that I've got it right
. I'm sure it's useful for creating all sorts of unspeakably cool effects - but I haven't seen it used yet.
Hope this helps.