Weird Shader Issue - HLSL Intrinsic ddy - cannot Map to Pixel Instruction Set

Hi all,

Apologies if this is something daft on my part, or a known issue (I’ve searched to no avail).

I’ve got a really simple shader for flat shading geometry. It uses the following line to find the normal for each pixel, in the pixel shader, and shade accordingly:

float3 normal = cross(ddy(, ddx(;

All is well and good. Results are as expected…when compiling with SM 5. When I switch to 4_0_level_9_1, I get an error that the compiler cannot map to the pixel instruction set. Through a process of elimination, I’ve identified the problem as the intrinsic ‘ddy’ method. It just doesn’t like it at all. I can replace ddy with ddx, and the shader compiles fine (and obviously then just looks wrong).

I’m using the stable 3.2 installer, and targeting DirectX11. Like I said, compiling the shader for SM 5 is fine, but 4_0_9_1 isn’t.

Any ideas?

You’ll have to find a different way to do this or use ps_4_0_level_9_3 which excludes your game from working on some hardware.

The docs for ddy say “unsupported in ps_2_0” and ps_4_0_level_9_1 is basically SM 2.0.

This is just graphics hardware issue and nothing wrong in MonoGame.

Thanks Tom, I had glanced over that page and yet totally failed to read it.

Out of curiosity, any idea why ddx compiles but ddy doesn’t? i.e:

float3 normal = cross(ddx(, ddx(;

compiles and runs fine, though obviously looks wrong?

Not really… I expect the work needed to do ddx is just simpler and available on older GPUs.