Blog Archive About

Psychopath Renderer

a slightly psychotic path tracer

2022 - 08 - 14

A Fast Hash For Base-4 Owen Scrambling

In Building a Better LK Hash I developed a significantly improved variant of the Laine-Karras hash for base-2 Owen scrambling. And in Owen Scrambling Based Blue-Noise Dithered Sampling I used base-4 Owen scrambling to build a simpler implementation of Ahmed and Wonka's screen-space blue-noise sampler. But there's an annoying gap between those two posts: unlike base-2, there's no fast hash for performing base-4 Owen scrambling, so you have to resort to a slower implementation.

In this post I'm going to fill that gap by developing a Laine-Karras style hash for base-4 Owen scrambling as well.1

Here's the hash we're going to end up with:

n ^= x * 0x3d20adea
n ^= (n >> 1) & (n << 1) & 0x55555555
n += seed
n *= (seed >> 16) | 1
n ^= (n >> 1) & (n << 1) & 0x55555555
n ^= n * 0x05526c56
n ^= n * 0x53a22864
2022 - 07 - 24

Owen Scrambling Based Blue-Noise Dithered Sampling

A little while back, the company Solid Angle published the paper "Blue-noise Dithered Sampling". It describes a method of distributing sampling error as blue noise across the image plane, which makes it appear more like error-diffusion dithering than typical render noise.

Or in other words, it turns renders like this:1

standard noise distribution

...into renders like this:

blue noise distribution

2022 - 07 - 12

In Defense of Brain-Dead Interpolation

Interpolating object transforms is a critical task for supporting transform motion blur in a 3d renderer. Psychopath takes a rather brain-dead approach to this and just directly interpolates each component of the transform matrices. This is widely considered to be wrong. The recommended approach is to first decompose the matrices into separate translation/rotation/scale components before interpolating.

In this post I'm going to argue that, for motion blur, the brain-dead approach is not only perfectly reasonable, but actually has some important advantages.

2022 - 04 - 23

Blackmagic Design's Color Spaces

(Note 1: if you just want the LUTs and color space data, jump down to the section titled "The Data".)

(Note 2: this is a slightly odd post for this blog. I normally only write about things directly relevant to 3D rendering here, and this post has very little to do with 3D rendering. Although it is relevant to incorporating rendered VFX into footage if you're a Blackmagic user.)

When you're doing VFX work it's important to first get your footage into a linear color representation, with RGB values proportional to the physical light energy that hit the camera sensor.

Color in image and video files, however, is not typically stored that way1, but rather is stored in a non-linear encoding that allocates disproportionately more values to darker colors. This is a good thing for efficient storage and transmission of color, because it gives more precision to darker values where the human eye is more sensitive to luminance differences. But it's not good for color processing (such as in VFX), where we typically want those values to be proportional to physical light energy.

The functions that transform between non-linear color encodings and linear color are commonly referred to as transfer functions.2 There are several standard transfer functions for color, with sRGB gamma perhaps being the most widely known. But many camera manufacturers develop custom transfer functions for their cameras.3

If you're doing VFX work, you really want to know what transfer function your camera used when recording its colors. Otherwise you can only guess at how to decode the colors back to linear color.

2021 - 01 - 30

Building a Better LK Hash

(This post has been updated as of 2021-05-08 with important changes due to an issue identified by Matt Pharr. The majority of the post is essentially unchanged, but additional text discussing the issue and providing a new hash with the issue addressed have been added near the end of the post. If you just want the hash itself, skip down to the section "The final hash".)

At the end of my last post about Sobol sampling I said that although there was room for improvement, I was "quite satisfied" with the LK hash I had come up with for use with the techniques in Brent Burley's Owen scrambling paper. Well, apparently that satisfaction didn't last long, because I decided to have another go at it. And in the process I've not only come up with a much better hash, but I've also learned a bunch of things that I'd like to share.