sample_compare returning neither 1 nor 0?

Hi,

Maybe I'm doing something wrong, but form MSL 2.4 spec, sample_compare should return either 0 or 1.

I'm on a MBP 16 M1 Pro, Monterey 12.3.1 and Xcode 13.3.1.

Now, I'm receiving a value in between. Coordinates, sampler etc.. seems correct:

shadow = 0.125:

Sorry, in the image is not seen, but "i == 0" and shadow_map is a texture with four slices.

Thanks

Accepted Reply

From MSL Spec 2.4 page 185...

These comparison result values per-pixel are then blended together as in normal texture filtering and the resulting value between 0.0 and 1.0 is returned.

The sampler in the screenshot has linear filtering, so you should get linearly-interpolated values.

  • Cool. The confusion comes from the previous sentence:

    sample_compare performs a comparison of the compare_value value against the pixel value (1.0 if the comparison passes and 0.0 if it fails)

    Thank you very much

Add a Comment

Replies

From MSL Spec 2.4 page 185...

These comparison result values per-pixel are then blended together as in normal texture filtering and the resulting value between 0.0 and 1.0 is returned.

The sampler in the screenshot has linear filtering, so you should get linearly-interpolated values.

  • Cool. The confusion comes from the previous sentence:

    sample_compare performs a comparison of the compare_value value against the pixel value (1.0 if the comparison passes and 0.0 if it fails)

    Thank you very much

Add a Comment