Alan Wolfe
blog.demofox.org · Personal blog · on HN since 2015
Alan Wolfe, a game and graphics programmer, writes about random numbers, blue noise, Monte Carlo methods, floating point, and automatic differentiation.
What HN saysHN commenters link it to explain low discrepancy sequences and blue noise sampling in graphics, and one lists it among math-focused blogs.
54HN people shared it
17linked it in comments
122stories submitted
2.8Kstory points
3 months agolast shared
2015people per year2026
Most-shared posts
- 1Dual Numbers and Automatic Differentiation (2014)5 people · 78 points · first shared 2017 · 35 comments on HN
- 2When random numbers are too random: Low discrepancy sequences (2017)4 people · 139 points · first shared 2017 · 69 comments on HN
- 3Generating Blue Noise Sample Points with Mitchell’s Best Candidate Algorithm4 people · 8 points · first shared 2017 · 1 comments on HN
- 4Using Wang Tiles to Simulate Turing Machines4 people · 5 points · first shared 2020 · 1 comments on HN
- 5Demystifying Floating Point Precision3 people · 150 points · first shared 2017 · 54 comments on HN
- 6Dissecting "Tiny Clouds" shadertoy (2017)3 people · 126 points · first shared 2017 · 4 comments on HN
- 7Monte Carlo Integration in 1D3 people · 6 points · first shared 2018 · discussion on HN
- 8Interpolating Data over Arbitrary Shapes with Laplace’s Equation3 people · 4 points · first shared 2020 · discussion on HN
- 9Interleaved Gradient Noise: A Different Kind of Low Discrepancy Sequence3 people · 3 points · first shared 2022 · discussion on HN
- 10Granular Audio Synthesis2 people · 154 points · first shared 2018 · 33 comments on HN
- 11Casual Shadertoy Path Tracing 1: Basic Camera, Diffuse, Emissive2 people · 139 points · first shared 2020 · 6 comments on HN
- 12SIMD / GPU Friendly Branchless Binary Search2 people · 84 points · first shared 2017 · 46 comments on HN
- 13Casual Shadertoy Path Tracing 2: Image Improvement and Glossy Reflections2 people · 72 points · first shared 2020 · 15 comments on HN
- 14Basic Methods for Finding Zeroes and Mins / Maxes of Functions2 people · 66 points · first shared 2020 · 9 comments on HN
- 15Minimizing Code Complexity by Programming Declaratively2 people · 7 points · first shared 2016 · 1 comments on HN
What HN people wrote when they linked it
tomsmeding · 2022-05-01
If I understand you correctly, I think you missed my point. You're explaining how with true randomness, you get different stuff most of the time and the same stuff some of the time. That is true. But it's not what people want when they press shuffle. What people want is something _different_, and giving the same song twice is not something different. As another commenter wrote, giving multiple (different) songs after each other from the same album would even be undesirable, even if that could occur perfectly well with random shuffling.
A human pressing "shuffle" usually doesn't want randomness. They want pleasing _variation_. See e.g. the "Comparison" heading here: https://blog.demofox.org/2017/10/20/generating-blue-noise-sample-point…
onos · 2021-12-30
Newbie here trying to follow.
The prior post I link below suggests that what’s going on here is we are trying to find good points to sample an image. A challenge here is that the algorithms to generate the blue noise distributed sample points are slow. This motivates using an FT signal constructed by hand and then inverting this somehow to get sample points more quickly. But… he’s finding that the result doesn’t place sample points uniformly throughout an image. Is that right?
How does one construct discrete sample points from the inverted FT?
https://blog.demofox.org/2017/10/20/generating-blue-noise-sample-point…
petschge · 2019-07-02
Actually you can make use of non-randomness in Monte Carlo simulations to get better results. There is various names for this, but the one I like best is "low discrepancy series". Have a look at [1] or [2] for a quick intro. These are sometimes also called quasi-random (or sub-random), but I find that a bit too close to pseudo-random.
[1] https://en.wikipedia.org/wiki/Low-discrepancy_sequence
[2] https://blog.demofox.org/2017/05/29/when-random-numbers-are-too-random…
dahart · 2021-12-30
One reason to use Blue noise in graphics / games / images is anytime you need a random number per pixel for, say, some Monte Carlo process, that will have a visible effect on the image and result in visible noise in the output. Using blue noise, the output will be visibly less “noisy” looking than when using white noise, due to blue noise having no low frequencies.
Blue noise is best for situations where you only have the budget for 1 or 2 samples per pixel. The very low sample counts is where it performs considerably better than white noise. If you integrate with many samples, tens or hundreds or more, then the advantage of blue noise over other “colors” diminishes.
The author of this post has some examples in other articles on his blog, for example using blue noise vs white noise for ray traced soft shadows. https://blog.demofox.org/2020/05/16/using-blue-noise-for-raytraced-sof…
panic · 2017-07-25
Here are a bunch of blogs from my RSS reader that I think are worth reading. Some of them haven't updated in a while, but the archives may be worth a look anyway.
* Blogs with a math focus:
http://blog.sigfpe.com
http://bit-player.org
http://mathr.co.uk/blog/
https://www.johndcook.com/blog/
* Blogs with a programming languages focus:
https://existentialtype.wordpress.com
https://bluishcoder.co.nz
http://blog.ezyang.com
http://akkartik.name
http://lambda-the-ultimate.org
http://mrale.ph
* Blogs with a UI design focus:
http://www.brandonwalkin.com/blog/
http://ignorethecode.net/blog/
http://interuserface.net
* Blogs with a graphics / 3D rendering focus:
http://c0de517e.blogspot.com
http://diaryofagraphicsprogrammer.blogspot.com
https://directtovideo.wordpress.com
http://graphicrants.blogspot.com
http://www.reedbeta.com
http://www.realtimerendering.com/blog/
https://blog.demofox.org
http://eelpi.gotdns.org/blog.wiki.html
* Other interesting / more general programming blogs (many of these have a "systems" focus):
http://danluu.com
http://ewontfix.com
http://chneukirchen.org/blog/
http://neverworkintheory.org
http://apenwarr.ca/log/
https://www.snellman.net/blog/
https://www.pvk.ca
http://psy-lob-saw.blogspot.com
https://randomascii.wordpress.com
http://fastcompression.blogspot.com
https://fgiesen.wordpress.com
http://blog.plover.com
http://chneukirchen.org/trivium/
http://rachelbythebay.com/w/
cyber_kinetist · 2025-05-12
As a bonus: the vanilla JFA can only calculate unsigned distances, but you can extend this to signed distance computation using a simple trick: by inverting your JFA result and setting it as the seed for running a second DFA. (See https://blog.demofox.org/2016/03/02/actually-making-signed-distance-fi… for a better explanation)
Atrix256 · 2024-01-07
This talks about that more deeply and is by the same author (me) :) https://blog.demofox.org/2020/07/26/irrational-numbers/
jdmichal · 2023-02-08
GP didn't say odd, or at least not numerically odd, but rather "ending in impossible digits".
Floats have varying precision, not uniform. The closer the number is to zero, the more precision it has. There's a point where the precision is so low that it only covers whole numbers, and then a point after that where the precision is less than whole numbers.
Given the context of pointers, it's quite possible that they were large enough to reach that less-than-whole-number-precision range.
EDIT: For 32-bit floats, that's apparently any number above 16,777,216. Which seems surprisingly small to me. For 64-bit doubles that goes to 9,007,199,254,740,992.
https://blog.demofox.org/2017/11/21/floating-point-precision
percentcer · 2020-11-13
I'm not sure where they're getting that "lenses in pathtracers are ignored". They most certainly are not. How would physically based path tracing even work if they were?
e.g. https://blog.demofox.org/2018/07/04/pathtraced-depth-of-field-bokeh/
ctchocula · 2020-11-07
I enjoy reading this author's articles such as the one explaining auto-differentiation [1]. Before that, I tried to understand this survey on auto-differentiation [2], and it just didn't click for me. The analogy to imaginary numbers was perfect.
[1] https://blog.demofox.org/2014/12/30/dual-numbers-automatic-differentia…
[2] https://arxiv.org/abs/1502.05767v4
adamnemecek · 2020-09-09
Are you familiar with automatic differentiation? https://blog.demofox.org/2014/12/30/dual-numbers-automatic-differentia… note that you get f(x) and f'(x) for some x without getting the derived function.
fizixer · 2020-06-07
part 1: https://blog.demofox.org/2020/05/25/casual-shadertoy-path-tracing-1-ba…
You started part 1 with:
> When you see a photorealistic image that someone says is “ray traced” what they likely mean is that it is “path traced” ...
well, you just became my new hero. Thank you for saying what is my pet peeve ever since nVidia started using the term ray tracing for some stupid reason that I will never understand.
notgood · 2017-09-28
This link[0] has an example; so basically almost anything in a game where it has to lookup massive amounts of data (e.g. logs), the example in the article is to quickly check if the user has already seen an item (in a game with thousands of items [e.g because those were pseudo-randomly generated, think RPGs]). But it's easy to think further applications: quickly check if the player already played this chess game before (all pieces where in the same position) to make sure the enemy does something smarter this time (because that time the enemy lost), and such.
[0] https://blog.demofox.org/2015/02/08/estimating-set-membership-with-a-b…
bschwindHN · 2026-02-05
Some notes because I weirdly just went through almost the exact same project for work:
* I also started with an RP2040 because the PIO is such a good Swiss Army knife for working with custom digital protocols. An RP2040 with a faster USB PHY would be killer!
* The STM32U5 series has variants with built-in High Speed USB PHYs, along with 2.5 megabytes of SRAM, along with easily solderable footprints (down to LQFP64) if you want to solder at home instead of having a PCB fab do it.
* JLCPCB and/or PCBWay can assemble boards for quite cheap these days
* ESD protection would be good to add to the board, as others have noted and as you mention in the post
* Ideally all routed traces which have fast rise/fall times (most digital signals) should have a solid reference plane under them along the entire trace, to avoid cross-talk and EMI, along with vias for your reference plane if your signal changes layers.
* If you control the rendering, and color banding is still an issue, look into Interleaved Gradient Noise
* I hadn't heard of GUD before. I just made a simple USB Bulk Out endpoint in the firmware and in my application code, took less than a day. Sometimes a custom solution is quicker and easier but it depends on where it's running and who you're distributing it to. Obviously my custom solution isn't interoperable with other things, but for now it doesn't need to be.
I plan to write up a blog post on the project I worked on, I'll be sure to post it to HN when I…
vanderZwan · 2024-05-21
Curious to see whether more recent dithering approaches would produce better results. They don't even have to be more resource hungry than the classic Bayer or Floyd-Steinberg dithers!
Interleaved Gradient Noise[0][1][2] comes to mind as an alternative to Bayer, and it can even be approximated quite well with just 8-bit operations! Basically, use the following function to determine your threshold based on pixel position: (x, y) => (142 * x + 79 * y) & 255
And for error diffusion, there are the Ostromoukhov and Zhou-Fang dithering algorithms[3][4], which I also have an JavaScript implementation of on Observable, so you can try it live[5].
[0] http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-…
[1] https://bartwronski.com/2016/10/30/dithering-part-three-real-world-2d-…
[2] https://blog.demofox.org/2022/01/01/interleaved-gradient-noise-a-diffe…
[3] https://perso.liris.cnrs.fr/victor.ostromoukhov/publications/publicati…
[4] https://dl.acm.org/doi/abs/10.1145/1201775.882289
[5] https://observablehq.com/@jobleonard/variable-coefficient-dithering
ly3xqhl8g9 · 2023-05-26
Contrary to popular belief, perhaps we are not yet ready for fuzzy logic-based mathematics†. Like asking that does Boolean logic do in the 13th century, before Leibniz had any glimpse of characteristica universalis [1] (software, as opposed to calculus ratiocinator, hardware). If cryptocurrencies are solutions in search of a problem, fuzzy logic, and especially fuzzy dual numbers logic [2] [3] [4], doesn't even know it is a solution.
† one speculative use would be to assign degrees(?) of agency, some kind of a future unit of measurement: a person can be 100% evolved, or maybe 49% evolved and 51% designed (prosthetics, neural implants, and so on).
[1] https://en.wikipedia.org/wiki/Characteristica_universalis
[2] 2017, Fuzzy Dual Numbers: Theory and Applications, https://dl.acm.org/doi/book/10.5555/3172931
[3] "Fuzzy Dual Dynamic Programming", https://hal-enac.archives-ouvertes.fr/hal-01372543/document
[4] "Dual Numbers & Automatic Differentiation", https://blog.demofox.org/2014/12/30/dual-numbers-automatic-differentia…
thatcherc · 2020-03-01
This paper does a weird thing by introducing complex numbers and then presenting a code solution that effectively implements dual numbers [0] while still calling them complex:
"The new version of the complexify module has
been improved by using the new function definitons discussed in the previous section, i.e., definitions that use the original real function for the real
part and the derivative of the function multiplied by
h for the imaginary part, rather than the complex
function definition." (emphasis mine)
Dual numbers ( "a + bE", where E [usually small epsilon] is a symbol defined by E^2=0, but E itself doesn't equal 0) are perfectly suited for automatic differentiation [1,2], so this paper is accurate. I just think it's confusing, probably especially for someone new to the topic, to kind of conflate dual and complex numbers in this way.
[0] - https://en.wikipedia.org/wiki/Dual_number
[1] - https://github.com/JuliaDiff/DualNumbers.jl
[2] - https://blog.demofox.org/2014/12/30/dual-numbers-automatic-differentia…