feat(gltf): make linear_output optional to enable tonemapping and gamma adjustment (#9260)
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build docs / build-and-deploy (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
Matt
2025-12-09 10:27:30 -05:00
committed by GitHub
parent 2b5876037f
commit ff7743b0f5
3 changed files with 36 additions and 2 deletions
@@ -1,4 +1,5 @@
#include "lv_gltf_view_shader.h"
#include "../lv_gltf_view_internal.h"
#if LV_USE_GLTF
@@ -12,8 +13,9 @@ static const lv_opengl_shader_t src_includes[] = {
uniform float u_Exposure;
const float STANDARD_GAMMA = 2.2;
const float GAMMA = STANDARD_GAMMA;
// const float STANDARD_GAMMA = 2.2; // Retained for reference - unused
const float GAMMA = )" LV_GLTF_TONEMAP_GAMMA R"(;
const float INV_GAMMA = 1.0 / GAMMA;
@@ -25,8 +25,38 @@
* DEFINES
*********************/
/* ::Gamma Presets::
* Standard Gamma value is 2.2
* Values range from 0.5 to 3.5, roughly speaking, with
* reasonable results between the 1.5 and 2.8 levels.
* The value must be enclosed with quotes, as a string literal.
*/
#define LV_GLTF_GAMMA_BRIGHTEST "3.5"
#define LV_GLTF_GAMMA_BRIGHTER "3.0"
#define LV_GLTF_GAMMA_BRIGHT "2.6"
#define LV_GLTF_GAMMA_STANDARD "2.2"
#define LV_GLTF_GAMMA_DARK "1.8"
#define LV_GLTF_GAMMA_DARKER "1.3"
#define LV_GLTF_GAMMA_DARKEST "0.8"
#define LV_GLTF_DISTANCE_SCALE_FACTOR 2.5f
/* Apply defaults below if not set explicitly */
/* Tone-mapping is not applied if linear output is enabled.
* Linear output is the default.
*/
#ifndef LV_GLTF_LINEAR_OUTPUT
#define LV_GLTF_LINEAR_OUTPUT 1
#endif
/* If tone-mapping is applied, this adjusts the brightness
* and color range of the output. Use stringified values.
*/
#ifndef LV_GLTF_TONEMAP_GAMMA
#define LV_GLTF_TONEMAP_GAMMA LV_GLTF_GAMMA_STANDARD
#endif
/**********************
* TYPEDEFS
**********************/
@@ -141,9 +141,11 @@ lv_result_t lv_gltf_view_shader_injest_discover_defines(lv_array_t * result, lv_
}
}
}
#if LV_GLTF_LINEAR_OUTPUT
if(add_define(result, "LINEAR_OUTPUT", NULL, false) == LV_RESULT_INVALID) {
return LV_RESULT_INVALID;
}
#endif
// only set cutoff value for mask material
if(material.alphaMode == fastgltf::AlphaMode::Mask) {