Skip to content

Add tetrahedral interpolation for 3D table lookups and tests. - #202

Open
aforsythe wants to merge 2 commits into
aces-aswf:masterfrom
aforsythe:feature/tetrahedral-lookup
Open

Add tetrahedral interpolation for 3D table lookups and tests.#202
aforsythe wants to merge 2 commits into
aces-aswf:masterfrom
aforsythe:feature/tetrahedral-lookup

Conversation

@aforsythe

@aforsythe aforsythe commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

lookup3DTetra splits each cell into six tetrahedra and blends the four corners of the one holding the sample point. The existing lookup3D blends all eight corners of the cell. Most LUT formats assume tetrahedral interpolation.

Available from CTL as lookup3DTetra_f3, lookup3DTetra_f and lookup3DTetra_h, matching the existing lookup3D set.

Includes a test that probes all six tetrahedra.

Closes #203

Category: new features

Test generation, code style compliance, and documentation Assisted-by: Calude-4.8-Opus

lookup3DTetra splits each cell into six tetrahedra around its main
diagonal and blends the four corners of the one holding the sample
point. lookup3D's trilinear blend uses all eight corners instead.

Exposed through the SIMD stdlib as lookup3DTetra_f3, _f and _h, matching
the lookup3D set. Both share a single dispatch parameterised on the
interpolation function.

Signed-off-by: Alex Forsythe <aforsythe@oscars.org>
testLookup3D cannot see tetrahedron selection: its probes land on grid
corners, and its table is linear along each axis, which all six
tetrahedra reproduce identically.

testLookup3DTetraBranches probes each tetrahedron with distinct non-zero
fractional coordinates against a table whose corners sit off the
trilinear plane, and its expected values are ones no other tetrahedron
produces. Failures name the tetrahedron and component.

Checks with an explicit test rather than assert, which Release builds
compile out via NDEBUG.

Signed-off-by: Alex Forsythe <aforsythe@oscars.org>
@scottdyer

Copy link
Copy Markdown
Contributor

I have not yet had a chance to compare your nested if structure myself, but any idea if the edge case decisions (i.e. when a point falls on the face between two tetrahedra) align with the math provisioned in CLF standard (ST 2163-1, Formula A.7)?

@aforsythe

Copy link
Copy Markdown
Contributor Author

The SMPTE CLF stnard was my reference for the implementation actually.

Went with the nested ifs to match lookup3D right above it, which does trilinear by just blending the corner values instead of the matrix form in teh standard. A7's T matrices are mostly zeros anyway, so writing them out literally is 32 multiplies and adds per sample when all you really need is to blend four corners.

Tetrahedra and weights come out the same either way. Results match to rounding error and for points sitting on a face both end up in a tetrahedron that contains the point and give the same answer becuase the corner seperating the two has weight zero.

Can add a comment pointing at 2136-1 Formula A.7 if that's useful.

@aforsythe aforsythe changed the title Add tetrahedral interpolation for 3D table lookups and tests. Requested by ILM. Add tetrahedral interpolation for 3D table lookups and tests. Jul 27, 2026
@michaeldsmith

Copy link
Copy Markdown
Collaborator

can you also add documentation for these new functions to the CTL manual - /doc/CtlManual.doc and corresponding PDF?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tetrahedral interpolation for 3D table lookups

3 participants