Source

Thread

1/ @iquilezles

Hey, don’t “optimize” conditional moves with mix()+step(). Please stop advising that. Why: https://iquilezles.org/articles/gpuconditionals/

Branches: 2025-02-09-ko_yuki_lo-thanks-for-that-ive-been-told-that-the-if-node, 2025-02-09-jervineyard-what-about-the-classic-a-x-b-1-0-x-assuming-x-is, 2025-02-09-and_coder-id-say-always-look-at-the-generated-assembly-when, 2025-02-09-int_16h-the-fear-of-branching-is-still-so-strong-i-think, 2025-02-09-ENDESGA-i-feel-half-of-the-problem-is-that-people-dont, 2025-02-09-desugar_64-is-this-true-for-arm-gpus-as-well-i-dont-have-arm, 2025-02-09-tom_forsyth-this-is-so-infuriating-its-advice-that-is-20, 2025-02-09-leowbattle-maybe-the-article-should-further-mention-that-the, 2025-02-09-arafleaf-why-would-someone-do-the-bad-one, 2025-02-09-TheWiseWolf_M-is-this-also-good-advice-when-programming-shaders, 2025-02-09-apfiiez-thanks-but-if-i-understand-you-correctly-there, 2025-02-09-redorav-good-advice-in-hlsl-you-can-also-use-the-select, 2025-02-09-AndroidBlogger-conditional-moves-are-also-a-cpu-thing-and, 2025-02-09-AndroidBlogger-do-you-know-if-there-is-any-online-shader, 2025-02-09-valhahaha-thanks-for-this-i-learned-using-step-was-the, 2025-02-09-GhostHandDev-tl-dr-compilers-will-generally-fix-this-kind-of, 2025-02-09-charles_grassi-what-about-conditions-from-sampled-textures-if, 2025-02-09-UnderwaterBepis-but-if-i-use-that-doesnt-that-result-in-a-time, 2025-02-09-leonard_coder-also-valid-for-any-decent-modern-cpu-always, 2025-02-09-OtanoStudio-you-didnt-show-the-compiler-assembly-for-the-mix, 2025-02-09-Tynach-this-greatly-depends-try-doing-this-per-channel, 2025-02-09-___nssy___-at-what-point-does-conditional-branching-occur, 2025-02-09-stormyy_ow-its-still-faster-even-if-the-condition-is-not, 2025-02-09-Niels_Dewitte-i-think-we-need-deeper-write-ups-on-this-subject, 2025-02-10-mlsprwr-okay-you-got-me-there-i-had-to-close-that, 2025-02-10-ekakiya-in-addition-mix-can-cause-nan-because-gpu-can, 2025-02-10-BugoTheCat-i-dont-know-much-about-shader-optimization-but-i, 2025-02-10-FabriceNEYRET-this-comes-from-common-misunderstanding-of, 2025-02-10-evildisease-compilers-are-smart-enough-to-take-care-of, 2025-02-10-djonesuk-x86-has-had-conditional-move-instructions-since, 2025-02-12-luis_reyes_x-is-there-a-use-case-for-step-i-always-forget-if, 2025-05-08-meatloaf1024-as-a-shader-newb-this-is-helpful-i-was-definitely, 2025-06-01-codaaaaaaaaa-read-about-this-from-gpu-gems-2-chapter-34-gpu, 2025-07-30-SquaredApe-i-suspect-the-reason-for-the-poor-advice-stems

2/ @iquilezles

Also GOOD:

float c;
if( x<0.5 ) c=a;
else c = b;

34 items under this folder.