Blogs on Max Slaterhttp://thenumb.at/blog/Recent content in Blogs on Max SlaterHugoen-usSat, 06 Jan 2024 00:00:00 +0000Oxidizing C++http://thenumb.at/rpp/Sat, 06 Jan 2024 00:00:00 +0000http://thenumb.at/rpp/I recently rewrote the C++20 infrastructure I use for personal projects, so I decided to snapshot its design in the style of another recent article. The library (rpp) is primarily inspired by Rust, and may be found on GitHub.
I use rpp as an STL replacement, and I’m currently developing a real-time path tracer with it. rpp attempts to provide the following features, roughly in priority order:
Fast Compilation
Including rpp should not increase compilation time by more than 250ms.14 Years of Programminghttp://thenumb.at/14-Years/Thu, 16 Nov 2023 00:00:00 +0000http://thenumb.at/14-Years/Many people have chronicled their programming journey in the 80s, 90s, and 00s—here’s one for the 2010s.
2010 I first encountered programming sometime around 2010, when I was 9 years old.
I can’t recall precisely how or why I got started, but I wrote my first programs in TI-BASIC, meticulously entering each symbol into my TI-83 calculator. They computed simple algebraic expressions that I used to do math problems.
I was fascinated by video games, so after learning how to poll for input, I created Catch the θ.Functions are Vectorshttp://thenumb.at/Functions-are-Vectors/Sat, 29 Jul 2023 00:00:00 +0000http://thenumb.at/Functions-are-Vectors/Conceptualizing functions as infinite-dimensional vectors lets us apply the tools of linear algebra to a vast landscape of new problems, from image and geometry processing to curve fitting, light transport, and machine learning.
Prerequisites: introductory linear algebra, introductory calculus, introductory differential equations.
This article received an honorable mention in 3Blue1Brown’s Summer of Math Exposition 3!
Functions as Vectors Vector Spaces Linear Operators Diagonalization Inner Product Spaces The Spectral Theorem Applications Fourier Series Image Compression Geometry Processing Further Reading Functions as Vectors Vectors are often first introduced as lists of real numbers—i.Optimizing Open Addressinghttp://thenumb.at/Hashtables/Sun, 08 Jan 2023 00:00:00 +0000http://thenumb.at/Hashtables/Your default hash table should be open-addressed, using Robin Hood linear probing with backward-shift deletion. When prioritizing deterministic performance over memory efficiency, two-way chaining is also a good choice.
Code for this article may be found on GitHub.
Open Addressing vs. Separate Chaining Benchmark Setup Discussion Separate Chaining Linear Probing Quadratic Probing Double Hashing Robin Hood Linear Probing Two Way Chaining Unrolling, Prefetching, and SIMD Benchmark Data Open Addressing vs. Separate Chaining Most people first encounter hash tables implemented using separate chaining, a model simple to understand and analyze mathematically.Spherical Integrationhttp://thenumb.at/Spherical-Integration/Sun, 08 Jan 2023 00:00:00 +0000http://thenumb.at/Spherical-Integration/Or, where does that $$\sin\theta$$ come from?
Integrating functions over spheres is a ubiquitous task in graphics—and a common source of confusion for beginners. In particular, understanding why integration in spherical coordinates requires multiplying by $$\sin\theta$$ takes some thought.
The Confusion So, we want to integrate a function $$f$$ over the unit sphere. For simplicity, let’s assume $$f = 1$$. Integrating $$1$$ over any surface computes the area of that surface: for a unit sphere, we should end up with $$4\pi$$.Exploring Neural Graphics Primitiveshttp://thenumb.at/Neural-Graphics/Sun, 27 Nov 2022 00:00:00 +0000http://thenumb.at/Neural-Graphics/Neural fields have quickly become an interesting and useful application of machine learning to computer graphics. The fundamental idea is quite straightforward: we can use neural models to represent all sorts of digital signals, including images, light fields, signed distance functions, and volumes.
Neural Networks Compression A Basic Network Activations Input Encodings Positional Encoding Instant Neural Graphics Primitives More Applications SDFs NeRFs References Neural Networks This post assumes a basic knowledge of neural networks, but let’s briefly recap how they work.Differentiable Programming from Scratchhttp://thenumb.at/Autodiff/Sun, 31 Jul 2022 00:00:00 +0000http://thenumb.at/Autodiff/Differentiable programming has become a hot research topic, and not only due to the popularity of machine learning frameworks like TensorFlow, PyTorch, and JAX. Many fields apart from machine learning are finding differentiable programming to be a useful tool for solving optimization problems. In computer graphics, differentiable rendering, differentiable physics, and neural representations are all gaining popularity.
This article received an honorable mention in 3Blue1Brown’s Summer of Math Exposition 2!Exponentially Better Rotationshttp://thenumb.at/Exponential-Rotations/Fri, 15 Apr 2022 00:00:00 +0000http://thenumb.at/Exponential-Rotations/If you’ve done any 3D programming, you’ve likely encountered the zoo of techniques and representations used when working with 3D rotations. Some of them are better than others, depending on the situation.
Based on CMU 15-462 course materials by Keenan Crane.
Representations Rotation Matrices Euler Angles Quaternions Axis/Angle The Exponential and Logarithmic Maps Axis/Angle in 2D Axis/Angle in 3D Averaging Rotations Quaternions (Again) Further Reading Representations Rotation Matrices Linear-algebra-wise, the most straightforward representation is an orthonormal 3x3 matrix (with positive determinant).Graphics Blogrollhttp://thenumb.at/Graphics-Blogroll/Mon, 04 Apr 2022 00:00:00 +0000http://thenumb.at/Graphics-Blogroll/In no particular order, my list of cool computer graphics (or adjacent) blogs:
Amit Patel Interactive algorithm visualizations Highlight: Introduction to A* Inigo Quilez 3D SDF rendering and shadertoy Highlight: 3D SDF Index Fabian Giesen Graphics programming, compression, comp arch, optimization Highlight: A trip through the Graphics Pipeline 2011 Bart Wronski Image/signal processing, real-time rendering, linear algebra Highlight: Why are video game graphics still a challenge? Nicky Case ‘Explorable’ real-world models, mental health Highlight: Parable of the Polygons Bartosz Ciechanowski Highly detailed interactive explainers Highlight: Cameras and Lenses Alan Zucconi Misc.Hamming Hatshttp://thenumb.at/Hamming-Hats/Tue, 29 Mar 2022 00:00:00 +0000http://thenumb.at/Hamming-Hats/I first encountered the Hat Problem in CMU 15-251.
The Game Consider a 31-person game in which each player is assigned a red or blue hat, determined by an independent coin flip. The players can see everyone else’s hat color, but not their own.
Once the game begins, no communication is allowed between the players. After looking at the other hats, all players must simultaneously either announce the color of their hat or abstain from guessing.A Compiler Bughttp://thenumb.at/Compiler-Bug/Sun, 26 Dec 2021 00:00:00 +0000http://thenumb.at/Compiler-Bug/While I was working on Dawn, I ran into a curious bug in the Visual Studio 2019 C++ compiler. I reported it to the bug tracker, where it was confirmed to be an interference analysis issue. It was eventually fixed nearly a year later in 2020. Today, let’s investigate what the issue really was.
The problem arose upon implementing a Perlin noise type for procedural solid texturing. My type just so happened to include a 4-kilobyte array of pre-initialized random data, and this precise size caused writes to the data to interfere with a preceding struct member.Exile: Voxel Rendering Pipelinehttp://thenumb.at/Voxel-Meshing-in-Exile/Sun, 26 Aug 2018 00:00:00 +0000http://thenumb.at/Voxel-Meshing-in-Exile/No, Exile is not technically a “voxel” engine. A real voxel engine unifies objects, textures, and more into colored voxel data, rendering them via raymarching/marching cubes/dual contouring/etc., and can target realism. Instead, Exile is a “voxel” engine in that it’s a traditional 3D engine that happens to focus on representing and drawing textured cubes (like Minecraft and related games). Some have worked around this linguistic confusion by christening the technique “Swedish cubes,” but for the purposes of this post, please assume that voxels imply textured cubes.Exile: Reflectionhttp://thenumb.at/Reflection-in-Exile/Tue, 14 Aug 2018 00:00:00 +0000http://thenumb.at/Reflection-in-Exile/Reflection, specifically type introspection, is an immensely useful feature provided by many modern languages. By enabling a way to inspect the properties of types—for example, the types of the members of a data structure—introspection allows one to write much more general and effective generic code, enforce interfaces/contracts, and more.
Though most obviously found in dynamic languages, introspection is just as powerful in compiled, statically typed languages such as Go and Jai.Exile: Hot Reloadinghttp://thenumb.at/Hot-Reloading-in-Exile/Wed, 25 Jul 2018 00:00:00 +0000http://thenumb.at/Hot-Reloading-in-Exile/In game development, one of the main appeals of implementing game logic in a managed language (e.g. Lua) is the convenient ability to make changes to the source, reload the logic on the fly, and test the changes without restarting the game. A similar technique is also often used to refresh shader programs, asset files, and the like.
However, supporting a secondary scripting language—or using one from the start—is not the only way to implement such a system.