Mike Turitzin
@miketuritzin
Building a game/engine based on signed distance fields ~ Past: rendering lead @figma.com, indie VR dev, founder @ Workflowy, search backend @ Google, Quake modder miketuritzin.com
I'm close to finishing a major rework of how materials are baked in my engine. Rather than baking material properties directly, I now store a material palette per brick and bake blend weights. This means that material property blending is "deferred" to render-time, ... 1/
Something that just clicked for me - In the same way that dividing by distance-to-origin (L2 norm) projects a point onto the unit circle/sphere: Dividing by L1 norm projects onto the unit diamond/octahedron Dividing by L-infinity norm projects onto the unit square/cube cont.
Because ray-marching SDF bricks is so comparatively expensive, with two-pass occlusion culling I'm generally rendering frames faster the more other stuff I add. (Disoccluded bricks are drawn in magenta.)
Kind of obvious when you think about it, but it was cool to realize that I don't need to record position history to draw artillery trails, as the same closed-form trajectory equation can be used to "rewind time" for each shot to generate its trail positions.
If you graph the representable floating point values on the 2D plane, you get something that looks like clipmaps/cascades. Therefore floating point representations are LODs for real numbers🤔 (also shows why floating point for absolute positions is bad)
This is a clever use of 32-bit atomics for depth+color rasterization output that I hadn't thought of. (I hadn't read the FreePipe paper; this summary is from @m-schuetz.bsky.social's recent CuRast paper: github.com/m-schuetz/Cu... )
Experimenting with having enemies turn to full rigid bodies when damaged and then recover after bouncing around. It's pretty entertaining how they pop back up.
Now that I am rendering meshes that need to cast shadows (sorry SDF purists!!), I had to update the world-space caching scheme I use for sun shadows. The SDF shadows are cached in tiles and incrementally redrawn as geometry changes. This is very cheap, which is ... 1/
Attack of the capsules! They are considerably more menacing than I was expecting, especially from inside the dome.
Spraying sticky cubes at the dome (as one does). (The dome is non-stick :) )
I'm also using "double-sided" blending here - first draw the mesh back-faces, followed by the front-faces, which works for convex meshes. More here: bsky.app/profile/mike... This clip toggles double-sided blending on and off.
The base is now operational. I used "dual-source blending" for the first time for this: add the specular contribution and multiply by transmissive color in a single draw (not possible with normal blending). Planning to try a frosted glass effect a la Doom 2016 as well. [cont]
Convex shapes (specifically polyhedra) come up constantly in games and graphics. A few useful properties: - A convex polyhedron is the convex hull of its vertices. - One can also be defined as the intersection of half-spaces defined by a set of planes (one per face). 1/
Another interesting small optimization to SDF brick rendering: I'm already tightly fitting bricks to the surface and doing occlusion culling, but this is another small win on top. If the camera ray intersects the brick at an "inside" point, discard the fragment to avoid ... 1/
Now that I've added support for "strong" materials, I'm experimenting with interesting underground structures to dig around. These metal "pipes" (or alien tendrils?😱) snake around, forcing you to navigate around them and leading you to resources. Future tools will destroy them.
Got my copy of the newest GPU Zen book (4). Recommend this series, they are high-quality! It's also nice to see the grand tradition of sequentially-numbered books containing collections of graphics articles continue :)
It's still kinda wild to me how much tweaking the easing function changes the feel of what kind of materials and tools you're working with. This video demonstrates "quintic" vs. "elastic" vs. none. The easing function controls the scale of the SDF subtraction.
Playing around with a different style for embedding resources underground. This is giving me more ideas - easy to forget there is so much possibility in different ways of combining SDF edits.
The tunnel gun returns! Added a "probe" tool to assist in finding resources when mining. The idea is to reveal what's beyond walls - and also aid in extraction if you use gravity! Feels satisfying, and I think it will also be cooler when I add more underground stuff like caves.
In the hacks-for-WebGL mines, I just saw this in the clustered-lighting article for Babylon.js (using additive blending to set per-light bits in a bitfield, in lieu of atomic-OR on a storage buffer). Cool hack, don't think I had seen it before. doc.babylonjs.com/features/fea...
First version of underground "biomes". They're currently defined by distance to the terrain surface. The idea is that different biomes have different resources, obstacles, caves, etc. The bottom one is very dark🤠 [cont]
Experimenting with strong materials that can't be dug through using normal tools. Gameplay ideas: - block player movement, making underground navigation more complex - enclose special resources that need to be extracted using explosives or other means
Experimenting with "wrapped diffuse" for my point lights while I don't have global-illumination. Seems to work decently in caves to "warm up" the vicinity of the light. 1/
You can now place lights while digging deep into the ground in my game. The plan is to have lights be a resource that must be conserved. Given there are no shadows for these lights right now (much less GI), this is already looking better than I was expecting. [cont]
Metallic materials are now officially supported in my engine. Previously, I hacked this for some videos by interpreting inverse "roughness" as "metallic", but obviously that isn't a great long-term solution :)
The beginnings of prototyping digging/mining gameplay. Resources are embedded in the ground and are dislodged when the surface is cut away. They're placed in colored regions that reveal their proximity. Lots of different directions to go with this, continuing to experiment!
Fixed the way I apply materials for SDF subtractions. My previous approach is common in shaders, but causes problems for future edits that use a material alpha<1.0 (the 1st subtraction material will extend infinitely into the surface). Looks like a nice crunchy candy coating :)