Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

feat(color): working black & white mixer (shader+tables+UI) and fix stale-shader builds (hlsli deps)

Veyra Goal Agent72693ba8174a
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cpp
index 1882311f..ac45a9a8 100644
--- a/apps/veyra/SettingsWindow.cpp
+++ b/apps/veyra/SettingsWindow.cpp
@@ -211,6 +211,10 @@ void layoutColorPage(){
place(818,y,32,collapsed);y+=36;
place(819,y,200,collapsed);y+=32;
}
+ // The black & white mixer is a mode, not a slider: one switch in the
+ // mixer section turns the eight 黑白 rows on (HSL rows go inert, exactly
+ // like Lightroom's B&W panel).
+ if(section==3){place(820,y,220,collapsed);y+=32;}
y+=8;
}
colorPageContentHeight=y+12;
@@ -229,6 +233,7 @@ void syncColorControls(){
}
}
if(auto space=item(819))if(int(SendMessageW(space,CB_GETCURSEL,0,0))!=colour.lutInputSpace)SendMessageW(space,CB_SETCURSEL,WPARAM(colour.lutInputSpace),0);
+ check(820,colour.blackWhite?BST_CHECKED:BST_UNCHECKED);
syncingColour=false;
}
bool applyColour(const engine::ColorSettings& colour,bool autoEnable){
@@ -459,6 +464,19 @@ LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM wp,LPARAM lp){
}else message(L"没有可撤销的还原。");
syncColorControls();arrange();return 0;
}
+ if(msg==WM_COMMAND&&LOWORD(wp)==820&&HIWORD(wp)==BN_CLICKED){
+ auto colour=colourTarget();
+ colour.blackWhite=SendMessageW(item(820),BM_GETCHECK,0,0)==BST_CHECKED;
+ if(!applyColour(colour,true)){
+ veyra::log::warn("color-ui","black and white mixer switch rejected");
+ syncColorControls();
+ return 0;
+ }
+ veyra::log::info("color-ui",std::format("black and white mixer={}",colour.blackWhite?1:0));
+ message(colour.blackWhite?L"黑白混色器已打开:下面八个“黑白”滑块控制各色系的灰阶明暗。":L"黑白混色器已关闭,回到 HSL 混色。");
+ syncColorControls();
+ return 0;
+ }
if(msg==WM_COMMAND&&LOWORD(wp)>=810&&LOWORD(wp)<810+kColorSections&&HIWORD(wp)==BN_CLICKED){
const int section=LOWORD(wp)-810;
colorFoldMask^=1u<<section;
@@ -665,6 +683,8 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.
// strength row is a normal parameter; the two combos are placed by
// layoutColorPage().
colorParams.push_back({6,L"LUT 强度",0,100,ColorTarget::Scalar,&engine::ColorSettings::lutStrength,0});
+ check(820,BST_UNCHECKED);add(L"BUTTON",L"黑白混色器(把画面转成黑白)",820,BS_AUTOCHECKBOX|WS_TABSTOP,3,12,0,-1,28);
+ SetPropW(item(820),L"veyra.tip",HANDLE(L"打开后画面变成黑白,下面八个“黑白”滑块控制各色系对应的灰阶明暗(和 Lightroom 的黑白混色器同一套语义)。"));
for(int section=0;section<kColorSections;++section)add(L"BUTTON",L"",810+section,BS_PUSHBUTTON|WS_TABSTOP,2,12,12,-1,32);
// Preset toolbar.
combo(803,2,0,{});add(L"EDIT",L"",804,ES_AUTOHSCROLL|WS_TABSTOP,2,12,0,-1,26);send(804,EM_SETLIMITTEXT,48,0);
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cpp
index 6811e599..90c030ab 100644
--- a/apps/veyra/ui/AppShell.cpp
+++ b/apps/veyra/ui/AppShell.cpp
@@ -772,38 +772,55 @@ else if(colorStep==40){colorStep=(colourSnapshot.desired.color.exposure==1.0f)?5
else if(colorStep==5){const int editId=veyra::ui::colourParamEditId(L"混合");if(auto edit=colourControl(editId))SetWindowTextW(edit,L"77.00");colorStep=editId>0?50:-1;}
else if(colorStep==50){colorStep=(colourSnapshot.desired.color.gradingBlending==77.0f)?51:(elapsed>9500?-1:50);
if(colorStep==51)veyra::log::info("color-ui-test","T4 the colour grading row reached the engine");}
+// Black & white mixer (T4): the switch must reach the engine and the per-band
+// row must then change the monochrome result instead of being an inert slider.
+else if(colorStep==51){
+ if(auto box=colourControl(820))SendMessageW(box,BM_CLICK,0,0);
+ colorStep=45;
+}
+else if(colorStep==45&&colourSnapshot.desired.color.blackWhite){colorStep=46;
+ veyra::log::info("color-ui-test","T4 the black and white mixer switch reached the engine");}
+else if(colorStep==45&&elapsed>11500){colorStep=-1;}
+else if(colorStep==46){
+ const int editId=veyra::ui::colourParamEditId(L"绿色 · 黑白");
+ if(auto edit=colourControl(editId))SetWindowTextW(edit,L"60.00");
+ colorStep=editId>0?47:-1;
+}
+else if(colorStep==47){
+ colorStep=(colourSnapshot.desired.color.blackWhiteMix[3]==60.0f)?52:(elapsed>12500?-1:47);
+ if(colorStep==52)veyra::log::info("color-ui-test","T4 the black and white band row reached the engine");}
// Named colour presets: save the current look, clear a value, apply the preset,
// then delete it - the same three actions the panel exposes.
-else if(colorStep==51){
+else if(colorStep==52){
if(auto edit=colourControl(804))SetWindowTextW(edit,L"烟测预设");
SendMessageW(colourControl(805),BM_CLICK,0,0);
- colorStep=52;
+ colorStep=53;
}
-else if(colorStep==52){
+else if(colorStep==53){
veyra::engine::ColorLookStore store(veyra::runtime::localDataDirectory());
store.load();
const bool saved=!store.entries().empty()&&store.entries().back().name==L"烟测预设";
if(auto edit=colourControl(1300))SetWindowTextW(edit,L"0.00");
- colorStep=saved?53:-1;
+ colorStep=saved?54:-1;
veyra::log::info("color-ui-test",std::format("preset saved={} count={} step={}",saved,store.entries().size(),colorStep));
}
-else if(colorStep==53&&colourSnapshot.desired.color.exposure==0.0f){SendMessageW(colourControl(806),BM_CLICK,0,0);colorStep=54;}
-else if(colorStep==53&&elapsed>9000){
+else if(colorStep==54&&colourSnapshot.desired.color.exposure==0.0f){SendMessageW(colourControl(806),BM_CLICK,0,0);colorStep=55;}
+else if(colorStep==54&&elapsed>9000){
veyra::log::info("color-ui-test",std::format("preset apply waiting: desiredExposure={:.3f} configuredExposure={:.3f} elapsed={}",
colourSnapshot.desired.color.exposure,uiState.configured.color.exposure,elapsed));
colorStep=-1;
}
-else if(colorStep==54){colorStep=(colourSnapshot.desired.color.exposure==1.0f)?55:(elapsed>14000?-1:54);
- if(colorStep==55)veyra::log::info("color-ui-test","preset applied: exposure came back through the engine");}
-else if(colorStep==55){SendMessageW(colourControl(807),BM_CLICK,0,0);colorStep=56;}
-else if(colorStep==56){
+else if(colorStep==55){colorStep=(colourSnapshot.desired.color.exposure==1.0f)?56:(elapsed>14000?-1:55);
+ if(colorStep==56)veyra::log::info("color-ui-test","preset applied: exposure came back through the engine");}
+else if(colorStep==56){SendMessageW(colourControl(807),BM_CLICK,0,0);colorStep=57;}
+else if(colorStep==57){
veyra::engine::ColorLookStore store(veyra::runtime::localDataDirectory());
store.load();
const bool deleted=store.entries().empty();
- colorStep=deleted?57:(elapsed>16000?-1:56);
- if(colorStep==57)veyra::log::info("color-ui-test","preset deleted; colour page back to no stored looks");
+ colorStep=deleted?58:(elapsed>16000?-1:57);
+ if(colorStep==58)veyra::log::info("color-ui-test","preset deleted; colour page back to no stored looks");
}
-else if(colorStep==57){
+else if(colorStep==58){
auto edit=colourControl(1300);
const bool beforeVisible=edit&&IsWindowVisible(edit);
const bool beforeMask=(preferences.load().colourFoldMask&1u)!=0u;
diff --git a/cmake/VeyraShaders.cmake b/cmake/VeyraShaders.cmake
index 1d1708e5..1b772484 100644
--- a/cmake/VeyraShaders.cmake
+++ b/cmake/VeyraShaders.cmake
@@ -19,11 +19,22 @@ function(veyra_find_dxc out_var)
set(${out_var} "${chosen}" PARENT_SCOPE)
endfunction()
+# Shared includes (.hlsli) that every shader may pull in. They MUST be declared
+# as dependencies: a colour-grade change that only edits ColorGrade.hlsli used
+# to leave the .dxil untouched, so the build silently kept running the old
+# shader - the kind of no-op that makes "I changed the shader" unverifiable.
+function(veyra_shader_includes out_var)
+ file(GLOB includes "${CMAKE_CURRENT_SOURCE_DIR}/shaders/*.hlsli")
+ list(SORT includes)
+ set(${out_var} "${includes}" PARENT_SCOPE)
+endfunction()
+
# Compiles one compute shader into <binary-dir>/shaders/<name>.dxil.
# Single-config Ninja: branch on CMAKE_BUILD_TYPE instead of generator
# expressions, whose empty expansion would quote-separate dxc arguments.
function(veyra_add_compute_shader target_name shader_name)
veyra_find_dxc(DXC_EXE)
+ veyra_shader_includes(SHADER_INCLUDES)
set(source "${CMAKE_CURRENT_SOURCE_DIR}/shaders/${shader_name}.hlsl")
set(output "${CMAKE_CURRENT_BINARY_DIR}/shaders/${shader_name}.dxil")
set(config_flags -O3 -Qstrip_debug -Qstrip_reflect)
@@ -34,17 +45,18 @@ function(veyra_add_compute_shader target_name shader_name)
OUTPUT "${output}"
COMMAND "${DXC_EXE}" -T cs_6_0 -E main ${config_flags}
-Fo "${output}" "${source}"
- DEPENDS "${source}" "${CMAKE_CURRENT_SOURCE_DIR}/shaders/HdrColor.hlsli" "${CMAKE_CURRENT_SOURCE_DIR}/shaders/HdrToSdr.hlsli"
+ DEPENDS "${source}" ${SHADER_INCLUDES}
COMMENT "dxc ${shader_name}.hlsl (${CMAKE_BUILD_TYPE})"
VERBATIM)
add_custom_target(${target_name} DEPENDS "${output}")
- set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${source}" "${CMAKE_CURRENT_SOURCE_DIR}/shaders/HdrColor.hlsli" "${CMAKE_CURRENT_SOURCE_DIR}/shaders/HdrToSdr.hlsli")
+ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${source}" ${SHADER_INCLUDES})
endfunction()
# Compiles a vertex+pixel shader pair (entry vsMain/psMain) into two DXIL
# files under <binary-dir>/shaders/. Used by the graphics present path.
function(veyra_add_graphics_shader_pair target_name shader_name)
veyra_find_dxc(DXC_EXE)
+ veyra_shader_includes(SHADER_INCLUDES)
set(source "${CMAKE_CURRENT_SOURCE_DIR}/shaders/${shader_name}.hlsl")
set(vs_out "${CMAKE_CURRENT_BINARY_DIR}/shaders/${shader_name}_vs.dxil")
set(ps_out "${CMAKE_CURRENT_BINARY_DIR}/shaders/${shader_name}_ps.dxil")
@@ -56,14 +68,14 @@ function(veyra_add_graphics_shader_pair target_name shader_name)
OUTPUT "${vs_out}"
COMMAND "${DXC_EXE}" -T vs_6_0 -E vsMain ${config_flags}
-Fo "${vs_out}" "${source}"
- DEPENDS "${source}" "${CMAKE_CURRENT_SOURCE_DIR}/shaders/HdrColor.hlsli"
+ DEPENDS "${source}" ${SHADER_INCLUDES}
COMMENT "dxc ${shader_name}.hlsl VS (${CMAKE_BUILD_TYPE})"
VERBATIM)
add_custom_command(
OUTPUT "${ps_out}"
COMMAND "${DXC_EXE}" -T ps_6_0 -E psMain ${config_flags}
-Fo "${ps_out}" "${source}"
- DEPENDS "${source}" "${CMAKE_CURRENT_SOURCE_DIR}/shaders/HdrColor.hlsli"
+ DEPENDS "${source}" ${SHADER_INCLUDES}
COMMENT "dxc ${shader_name}.hlsl PS (${CMAKE_BUILD_TYPE})"
VERBATIM)
add_custom_target(${target_name} DEPENDS "${vs_out}" "${ps_out}")
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index e7eb1596..12dba579 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1,5 +1,28 @@
# 2026-09-11 继续修复目标模式执行中
+## 2026-09-17 色彩页 P1:黑白混色器(T4 补完)+ 修“改了 shader 却不重编译”的构建漏洞
+
+**黑白混色器现在真的能用**。之前色彩页里那 8 条“黑白”滑块是**死控件**:模型、预设、UI 都在,
+但 `ColorGrade.hlsli` / `ColorGradeTables` 里根本没有 `blackWhite`,拖动毫无效果。现在:
+
+- 烘焙(`ColorGradeTables::bake`):每条色相带的黑白权重按同一套带权重合成,写进**色相表未使用的
+ alpha 通道**(`t9` 的 a),不新增纹理/常量槽位;`flags.z` 标记黑白模式;
+- 着色器:黑白模式下画面转单色,每个色系按其权重把灰阶提亮/压暗(±100%,Lightroom 黑白混色器语义),
+ 此时 HSL 混色行自然失效,和 LR 一致;
+- UI:混色器组新增“黑白混色器(把画面转成黑白)”开关(id 820),并把状态纳入 `syncColorControls()`;
+- 验收:CPU 断言 7 条(identity 清位、绿带权重、远带不受影响、打包 flags、关模式时权重仍保留、
+ identity 表 B&W 列为 0)+ GPU 4 条(真图渲染出单色、绿带把灰阶从 141 提到 174、
+ 关掉后恢复 64/160/64 的彩色)+ 烟测新增两步(开关到引擎、绿带黑白行到引擎)。
+
+**构建漏洞(会影响以后所有人)**:`cmake/VeyraShaders.cmake` 的 dxc 依赖只列了 `.hlsl` 与两个固定
+`.hlsli`,**没有列 `ColorGrade.hlsli`**。后果:只改颜色核心头文件时 `.dxil` 不重编译,程序继续跑旧
+shader——第一次改黑白时就撞上了(改完没效果,差点误判为逻辑错误)。现在改为 `file(GLOB shaders/*.hlsli)`
+全量依赖 + `CMAKE_CONFIGURE_DEPENDS`,任何 `.hlsli` 改动都会触发重编译(已验证:本次 `RgbToLinear.dxil`
+从 8596 → 8720 字节并更新了时间戳)。
+
+**回归**:`veyra_color_grade_tests`(30 项)exit 0;`veyra_color_grade_gpu_tests`(14 项)exit 0;
+`veyra_color_lut_tests` / `veyra_color_look_tests` exit 0;`--smoke-color` **exit 0**(含新步骤)。
+
## 2026-09-17 色彩页 P1:HDR 导出的 MaxCLL/MaxFALL 兜底(原样带上 + 标注未更新)
方案 §5.3 要求“能测就测;不能测时保留原值并标注未更新,不允许静默写入与实际不符的静态元数据”。
diff --git a/include/veyra/pipeline/ColorGradeTables.h b/include/veyra/pipeline/ColorGradeTables.h
index 86272695..9026ced9 100644
--- a/include/veyra/pipeline/ColorGradeTables.h
+++ b/include/veyra/pipeline/ColorGradeTables.h
@@ -27,6 +27,7 @@ struct ColorGradeTables {
float saturation=0,vibrance=0; // -100..100, applied in the shader
float lutStrength=0; // 0..1 (0 disables the 3D LUT lookup)
int lutInputSpace=0;
+ bool blackWhite=false; // monochrome mixer instead of the HSL mixer
bool identity=true; // master switch off or every parameter neutral
static ColorGradeTables bake(const engine::ColorSettings& settings);
// Exposed for the tests and for callers that need the same log mapping.
@@ -44,6 +45,8 @@ inline void packColorGradeConstants(const ColorGradeTables& t,float* out){
out[12]=t.exposure;out[13]=t.saturation;out[14]=t.vibrance;out[15]=t.identity?0.0f:t.lutStrength;
// "identity" covers both "master switch off" and "every parameter neutral":
// in either case the shader must return the input untouched.
- out[16]=t.identity?0.0f:1.0f;out[17]=float(t.identity?0:t.lutInputSpace);out[18]=0;out[19]=0;
+ // flags.w(z) = black & white mixer active. Its per-band weights live in the
+ // hue table's alpha channel, so no extra texture or constant slot is needed.
+ out[16]=t.identity?0.0f:1.0f;out[17]=float(t.identity?0:t.lutInputSpace);out[18]=t.blackWhite?1.0f:0.0f;out[19]=0;
}
} // namespace veyra::pipeline
diff --git a/shaders/ColorGrade.hlsli b/shaders/ColorGrade.hlsli
index 62a31b74..4bb8c66f 100644
--- a/shaders/ColorGrade.hlsli
+++ b/shaders/ColorGrade.hlsli
@@ -180,7 +180,19 @@ float3 ColorGradeApply(float3 lin, ColorGradeParams p)
// Hue mixer.
const float3 hsv = RgbToHsv(rgb);
const float4 hueResponse = ColorGradeHue(hsv.x / 360.0);
- rgb = HsvToRgb(float3(hsv.x + hueResponse.r, saturate(hsv.y * hueResponse.g), max(hsv.z * hueResponse.b, 0.0)));
+ if (p.flags.z > 0.5)
+ {
+ // Black & white mixer: the frame becomes monochrome and each colour band
+ // lightens or darkens its own grey by up to +/-100% (Lightroom's B&W
+ // mixer semantics). The per-band weight rides in hueResponse.a.
+ const float luma = dot(rgb, float3(0.2126, 0.7152, 0.0722));
+ const float grey = max(0.0, luma * max(0.0, 1.0 + hueResponse.a * 0.01));
+ rgb = float3(grey, grey, grey);
+ }
+ else
+ {
+ rgb = HsvToRgb(float3(hsv.x + hueResponse.r, saturate(hsv.y * hueResponse.g), max(hsv.z * hueResponse.b, 0.0)));
+ }
// Luminance-zone grading + calibration shadow tint.
const float tone = saturate(ColorGradeEncodeLog(rgb).y);
diff --git a/src/pipeline/ColorGradeTables.cpp b/src/pipeline/ColorGradeTables.cpp
index 2827a17f..41280aef 100644
--- a/src/pipeline/ColorGradeTables.cpp
+++ b/src/pipeline/ColorGradeTables.cpp
@@ -91,6 +91,7 @@ ColorGradeTables ColorGradeTables::bake(const engine::ColorSettings& s){
out.vibrance=s.vibrance;
out.lutStrength=s.hasLut()?std::clamp(s.lutStrength/100.0f,0.0f,1.0f):0.0f;
out.lutInputSpace=s.lutInputSpace;
+ out.blackWhite=s.blackWhite;
if(!s.enabled||s.neutral()){
for(int i=0;i<kCurveEntries;++i){
const float t=float(i)/float(kCurveEntries-1);
@@ -147,7 +148,7 @@ ColorGradeTables ColorGradeTables::bake(const engine::ColorSettings& s){
// --- hue response (mixer) --------------------------------------------
for(int i=0;i<kHueEntries;++i){
const float hue=360.0f*float(i)/float(kHueEntries-1);
- float shift=0,sat=1,lum=1;
+ float shift=0,sat=1,lum=1,bw=0;
constexpr float centres[engine::kColorMixerBands]={0,30,60,120,180,240,280,320};
for(int b=0;b<engine::kColorMixerBands;++b){
float d=std::abs(hue-centres[b]);
@@ -156,9 +157,14 @@ ColorGradeTables ColorGradeTables::bake(const engine::ColorSettings& s){
shift+=w*s.mixerHue[std::size_t(b)]*0.3f;
sat*=1.0f+w*s.mixerSaturation[std::size_t(b)]/100.0f;
lum*=1.0f+w*s.mixerLuminance[std::size_t(b)]/100.0f;
+ // Black & white mixer: per-band lighten/darken of the monochrome
+ // result. The weight rides in the hue table's unused alpha channel
+ // so the shader keeps its existing table set (no extra SRV).
+ bw+=w*s.blackWhiteMix[std::size_t(b)];
}
const auto base=std::size_t(i)*4;
out.hue[base]=shift;out.hue[base+1]=std::max(0.0f,sat);out.hue[base+2]=std::max(0.0f,lum);
+ out.hue[base+3]=std::clamp(bw,-100.0f,100.0f);
}
// --- luminance response (colour grading + shadow tint) ----------------
diff --git a/tests/integration/ColorGradeGpuTests.cpp b/tests/integration/ColorGradeGpuTests.cpp
index b62bb653..d8856e70 100644
--- a/tests/integration/ColorGradeGpuTests.cpp
+++ b/tests/integration/ColorGradeGpuTests.cpp
@@ -153,6 +153,34 @@ int wmain(){
const auto pixel=center(graded);
check(ok&&pixel.r>pixel.b+10,"mid-tone grading wheel tints mid grey towards red");
}
+ {
+ // T4 black & white mixer: the switch must actually produce a
+ // monochrome frame, and the per-band row must move that band's grey
+ // instead of being an inert slider.
+ engine::EnhancementSettings s;s.color.enabled=true;s.color.blackWhite=true;
+ sink::RgbaImage monoGreen,monoGreenLifted;
+ const bool monochrome=graph.apply(s)&&graph.render(grass,monoGreen)&&!monoGreen.pixels.empty();
+ check(monochrome,"the black and white mixer renders through the real graph");
+ if(monochrome){
+ const auto grey=center(monoGreen);
+ check(grey.r==grey.g&&grey.g==grey.b,"the black and white mixer collapses the frame to grey");
+ s.color.blackWhiteMix[3]=60.0f;
+ const bool lifted=graph.apply(s)&&graph.render(grass,monoGreenLifted)&&!monoGreenLifted.pixels.empty();
+ const auto liftedGrey=lifted?center(monoGreenLifted):Pixel{};
+ check(lifted&&liftedGrey.r==liftedGrey.g&&liftedGrey.g==liftedGrey.b&&liftedGrey.r>grey.r+8,
+ std::format("the green band row lightens the green area's grey (neutral {} vs lifted {})",grey.r,liftedGrey.r));
+ // Same non-colour payload as the accepted call above, so only the
+ // colour block changes (a fresh default settings object carries a
+ // different multiplier/backend combination the graph rejects).
+ auto off=s;off.color=engine::ColorSettings{};off.color.enabled=true;
+ sink::RgbaImage colour;
+ const bool applied=graph.apply(off);
+ const bool rendered=applied&&graph.render(grass,colour)&&!colour.pixels.empty();
+ const auto back=rendered?center(colour):Pixel{};
+ check(rendered&&back.g>back.r+8,
+ std::format("turning the black and white mixer off restores the colour image (applied={} r={} g={} b={})",applied,back.r,back.g,back.b));
+ }
+ }
}
// 3. A real .cube file, imported into runtime_local/luts and resolved by name
// when the graph is built - the same path the UI importer uses.
diff --git a/tests/unit/ColorGradeTableTests.cpp b/tests/unit/ColorGradeTableTests.cpp
index 45195793..2315c948 100644
--- a/tests/unit/ColorGradeTableTests.cpp
+++ b/tests/unit/ColorGradeTableTests.cpp
@@ -130,6 +130,30 @@ int main(){
const auto withLut=ColorGradeTables::bake(s);
check(std::abs(withLut.lutStrength-0.75f)<1e-6f,"lut strength normalises to 0..1 when a lut is selected");
}
+ // 10. Black & white mixer: the eight 黑白 rows must not be inert sliders.
+ // The per-band weight is baked into the hue table's alpha channel and the
+ // mode itself into the packed flags, so the shader needs no extra table.
+ {
+ ColorSettings s;s.enabled=true;s.blackWhite=true;s.blackWhiteMix[3]=60.0f;
+ const auto t=ColorGradeTables::bake(s);
+ const int greenIndex=int(120.0f/360.0f*float(kH-1)+0.5f);
+ const int redIndex=int(0.0f/360.0f*float(kH-1)+0.5f);
+ check(!t.identity,"enabling the black and white mixer clears the identity flag");
+ check(t.blackWhite,"the bake reports the black and white mode");
+ check(hueAt(t,greenIndex,3)>30.0f,"the green band lightens its grey in the B&W mix table");
+ check(std::abs(hueAt(t,redIndex,3))<20.0f,"a band far from the edited colour stays near its neutral grey");
+ float packed[20]{};
+ packColorGradeConstants(t,packed);
+ check(packed[18]>0.5f,"the packed flags tell the shader to run the monochrome path");
+ ColorSettings off=s;off.blackWhite=false;
+ const auto offTables=ColorGradeTables::bake(off);
+ float offPacked[20]{};
+ packColorGradeConstants(offTables,offPacked);
+ check(offPacked[18]<0.5f,"with the mixer off the monochrome path stays disabled even though weights are baked");
+ check(hueAt(offTables,greenIndex,3)>30.0f,"baked weights are kept so toggling the mode back on is instant");
+ ColorSettings plain;s.enabled=true;
+ check(ColorGradeTables::bake(plain).hue[std::size_t(greenIndex)*4+3]==0.0f,"identity bake leaves the B&W column at zero");
+ }
if(failures){std::printf("FAIL: colour grade bake (%d checks)\n",failures);return 1;}
std::printf("PASS: colour grade bake tables (identity, white balance, tone, curves, mixer, grading, lut)\n");
return 0;