From 4ae95b5a4f2f0ad5ac53534f6d533335ef4cb196 Mon Sep 17 00:00:00 2001 From: Crt Vavros - smlu Date: Fri, 6 Jan 2023 22:09:31 +0100 Subject: [PATCH] [libim] Fix setting head light to zero when parsing NDY param `lightIntensity` as RGB The jones3D engine looks like having a bug in light rendering system when light color alpha aka light range is set to 0.0. This commit makes sure that when parsing NDY param`lightIntensity` as RGB to use very small floating point number 1.34550338e-36f for alpha color component instead of 0.0. Commit also fixes issues with head light when converting NDY to CND. --- CMakeLists.txt | 2 +- libraries/libim/CMakeLists.txt | 2 +- .../world/impl/serialization/ndy/thing/ndy_thing_iser.h | 9 ++++++--- programs/cndtool/CMakeLists.txt | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6778b8c..a9075af 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.15 FATAL_ERROR) project( Urgon LANGUAGES CXX - VERSION 0.10.0 + VERSION 0.10.1 HOMEPAGE_URL "https://github.com/smlu/Urgon" ) diff --git a/libraries/libim/CMakeLists.txt b/libraries/libim/CMakeLists.txt index b2aa63a..f78d4b2 100644 --- a/libraries/libim/CMakeLists.txt +++ b/libraries/libim/CMakeLists.txt @@ -1,7 +1,7 @@ project( ${PM_LIBIM} LANGUAGES CXX - VERSION 0.9.0 + VERSION 0.9.1 ) # LibIM source diff --git a/libraries/libim/content/asset/world/impl/serialization/ndy/thing/ndy_thing_iser.h b/libraries/libim/content/asset/world/impl/serialization/ndy/thing/ndy_thing_iser.h index 61cebd6..d0b10e3 100644 --- a/libraries/libim/content/asset/world/impl/serialization/ndy/thing/ndy_thing_iser.h +++ b/libraries/libim/content/asset/world/impl/serialization/ndy/thing/ndy_thing_iser.h @@ -26,7 +26,7 @@ namespace libim::content::asset { return true; } - LinearColor ndyParseLightValue( const Token& val) + LinearColor ndyParseLightValue( const Token& val, float defaultAlpha = 0.0f) { try { return LinearColor(val.value(), /*strict=*/true); @@ -34,7 +34,7 @@ namespace libim::content::asset { catch (...) { try { - return makeLinearColor(LinearColorRgb(val.value(), /*strict=*/true), /*alpha=*/0.0f); + return makeLinearColor(LinearColorRgb(val.value(), /*strict=*/true), defaultAlpha); } catch (...) { LOG_WARNING("NDY: Bad light value: %s", val.value()); @@ -422,9 +422,12 @@ namespace libim::content::asset { return true; case NdyThingParam::LightIntensity: // head light - actorInfo.lightIntensity = ndyParseLightValue(value); // Hack by default NDY allows only RGB but we try to parse it as RGBA, to allow min/max range to be set //makeLinearColor(LinearColorRgb(value.value(), /*strict=*/true), 0.0f); + { + constexpr float dfltAlpha = 1.34550338e-36f; // The jones3d engine looks like having troubles issues when alpha is 0.0f, and uses this value instead for zero. + actorInfo.lightIntensity = ndyParseLightValue(value, dfltAlpha); // Hack by default NDY allows only RGB but we try to parse it as RGBA, to allow min/max range to be set thing.flags |= Thing::Flag::EmitsLight; return true; + } case NdyThingParam::VoiceColor: actorInfo.voiceColor = GradientColor(value.value()); diff --git a/programs/cndtool/CMakeLists.txt b/programs/cndtool/CMakeLists.txt index 853f574..65ab770 100644 --- a/programs/cndtool/CMakeLists.txt +++ b/programs/cndtool/CMakeLists.txt @@ -1,7 +1,7 @@ project( ${PM_CNDTOOL} LANGUAGES CXX - VERSION 0.7.0 + VERSION 0.7.1 HOMEPAGE_URL ${CMAKE_PROJECT_HOMEPAGE_URL} )