As far as I understand Pixel Shader operates on per-pixel basis. But there are functions like ddx
and ddy
that calculates derivates. But how can one calculate derivatives from just one pixel coordinates?? Can someone help me on these? These also raises questions as in
tex.Sample(s0, t0);
Does it mean Sample function is calculated per pixel basis?? I thought Sampler Instruction operates on per subspan basis.
Example:
If I have the following 16 pixels:
* * * *
* * * *
* * * *
* * * *
And my pixel shader looks like this:
float4 PS(PS_INPUT input) : SV_Target{
float2 derivX = ddx_fine(input.tex);
float2 derivY = ddx_fine(input.tex);
return tex.SampleGrad(s0, t0, derivX, derivY);
}
How many times the above code will be called in a 4 x 4 grid of pixel coordinates? Thanks.