Skip to content
NRexhaPublic

About

A tool for baking LUT textures using HLSL.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

25 Commits

Folders and files

Repository files navigation

MathLUT

MathLUT is a lightweight desktop application designed to make the creation of lookup tables (LUTs) more intuitive. You can write GLSL-like functions directly in the built-in code editor, inspect their behavior through curve graphs, preview the resulting texture, and export it as a PNG.

Note: The tool was developed as a three-day challenge. It was my first time building a tool from scratch without relying on an application framework. The project was a great opportunity to explore C++ and OpenGL compute shaders.

MathLUT

Download

  1. Download the latest Windows build from the Releases page.
  2. Extract the ZIP archive and launch MathLUT.exe.

Note: Keep the src folder alongside the executable. MathLUT loads its shaders and function files at runtime.

Writing functions

Write your function directly in the built-in code editor. MathLUT uses a compact, GLSL-like syntax to define the output channels of a LUT.

For example:

r = x;
g = x * x;
b = 1.0 - x;
a = 1.0;

You can also assign multiple channels at once using vector types:

rgb = vec3(x, x * x, 1.0 - x);
a = 1.0;

Each assignment defines an output channel. In this example, red follows the input, green follows its square, blue is inverted, and alpha remains fully opaque.

You can combine built-in variables, mathematical constants, and supported GLSL functions to create more complex transformations. There's also autocomplete! Compilation feedback is displayed in the console, helping you identify errors while editing.

MathLUT_Func

Built-in variables

Name Description
x X-coordinate input
PI 3.14159265358979323846
TAU 6.28318530717958647692
E 2.71828182845904523536
_Time Elapsed time
r, g, b, a Red, green, blue, and alpha output channels
rgb RGB output vector (vec3)
rgba RGBA output vector (vec4)

Example use case

In this Unreal Engine material, numerous trigonometric operations (sin, cos, atan2, etc.) were used throughout the graph, although only a sin and cos are shown in this screenshot for practice purpose. Their cumulative cost risked creating a GPU bottleneck. By baking some of these calculations into a small 32 × 4 px LUT texture, we could replace runtime math with texture samples, shifting part of the workload to texture lookups and potentially reducing pressure on shader execution resources.

Usage

Dependencies

License

Released under MIT by @NRexha.

About

A tool for baking LUT textures using HLSL.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages