Inigo Quilez :: computer graphics, mathematics, shaders, fractals, demoscene and more
Inigo Quilez :: articles :: gpu conditionals - 2025 Intro In this article I want to correct a popular misconception that's been making the rounds in computer graphics aficionado circles for a long time now. It has to do with conditionals when selecting between two results in the GPUs. Unfortunately there are a couple of educational websites out there that are spreading some misinformation, and it would be nice correcting that. I tried contacting the authors without success, so without further ado, here goes my attempt to fix things up a little: The issue So, say I have this code, which I actually published the other day: vec2 snap45( in vec2 v ) { vec2 s = sign(v); float x = abs(v.x); return x>0.923880?vec2(s.x,0.0): x>0.382683?s*sqrt(0.5): vec2(0.0,s.y); } The exact details of what it does don't matter for this discussion. All we care about is the two ternary operations deciding what's the final value this function should retu
--> Inigo Quilez :: computer graphics, maths, shaders, fractals, demoscene Inigo Quilez :: :: Intro In this article I want to correct a popular misconception that's been making the rounds in computer graphics aficionado circles for a long time now. It has to do with conditionals when selecting between two results in the GPUs. Unfortunately there are a couple of educational websites out there that are spreading some misinformation, and it would be nice correcting that. I tried contacting the authors without success, so without further ado, here goes my attempt to fix things up a little: The iss
related reading
- Hello World! | Fragment Foundryhughsk.io
- GitHub - adam-maj/tiny-gpu: A minimal GPU design in Verilog to learn how GPUs work from the ground up · GitHubgithub.com
- Paper Shaders – Ultra-fast zero-dependency shadersshaders.paper.design
- The Book of Shadersthebookofshaders.com
- General-purpose computing on graphics processing units - Wikipediaen.wikipedia.org
- Shadersshaders.com
- Branchless Equivalents of Simple Functions | Harder, Better, Faster, Strongerhbfs.wordpress.com
- README | GPU Glossarymodal.com
- The Case for Use.GPU — Acko.netacko.net
- A case for learning GPU programming with a compute-first mindset – Maister's Graphics Adventuresthemaister.net
- What happens when you run a CUDA kernelfergusfinn.com
- CUDA C++ Programming Guide (Legacy) — CUDA C++ Programming Guidedocs.nvidia.com