Skip to content

Feature: More Bake VC colorization methods#35

Open
lfod1997 wants to merge 5 commits into
mrven:masterfrom
lfod1997:feature/bake-vc-colorization-methods
Open

Feature: More Bake VC colorization methods#35
lfod1997 wants to merge 5 commits into
mrven:masterfrom
lfod1997:feature/bake-vc-colorization-methods

Conversation

@lfod1997
Copy link
Copy Markdown

@lfod1997 lfod1997 commented Jul 8, 2025

  1. Implement basic support for changeable VC calculation methods
  2. Adds 3 new colorization: grayscale (linear), grayscale (square root) and fixed-point non-color

Motivation

I'm using the addon to calculate TD and bake into VC, so I can use that data in the game engine. Currently the color is calculated with a fixed method that maps the calculated value to a hue (utils.Value_To_Color), which I believe is perfect for visualization, but not quite suitable for real-time applications as decoding the mapped color involves RGB to HSV transformation.

Contents

I'm making this PR so the VC calculation ("colorization") method can be chosen from a range of methods. This involves adding one property (props.TD_Addon_Props.bake_vc_colorization) and minor logic tweaks. Original work (the value-to-hue method) is not changed in any way and has become the default.

3 more colorization methods are also implemented:

Grayscale (Linear), calculated values are mapped to the colors' brightness:

01

Grayscale (Square Root), calculated values are first taken the square root of, then mapped to the colors' brightness:

02

Normalized 24-Bit Fixed-Point (RGB8), which bakes values directly into VC; offers higher precision than grayscale methods, at the cost of readability and slightly heavier decoding:

Calculated values are normalized and converted to 24-bit fixed-point numbers, then bitwise-split into 3 channels and converted to floating-point RGB colors, resulting in non-color RGB values in the final VC.

Data can be recovered with expression:

((round(R * 255.0) << 16) + (round(G * 255.0) << 8) + round(B * 255.0)) / float(0xffffff)

, which evaluates to the normalized value. To retrieve the original, unnormalized value, users will need to scale back using the Min and Max values, which the addon offers.

03

@mrven
Copy link
Copy Markdown
Owner

mrven commented Jul 24, 2025

@lfod1997, could you clarify the use cases for normalized 24-bit fixed-point format (RGB8)? I'm wondering if it's broadly useful enough to include.

@mrven
Copy link
Copy Markdown
Owner

mrven commented Jul 27, 2025

And one more thing - this modes isn't compatible with current checker material because it uses "Color" blend mode

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.

2 participants