Skip to content

Commit

Permalink
[libim] Fix setting head light to zero when parsing NDY param `lightI…
Browse files Browse the repository at this point in the history
…ntensity` 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.
  • Loading branch information
smlu committed Jan 6, 2023
1 parent b452606 commit 4ae95b5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion libraries/libim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
${PM_LIBIM}
LANGUAGES CXX
VERSION 0.9.0
VERSION 0.9.1
)

# LibIM source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ 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);
}
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());
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion programs/cndtool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
${PM_CNDTOOL}
LANGUAGES CXX
VERSION 0.7.0
VERSION 0.7.1
HOMEPAGE_URL ${CMAKE_PROJECT_HOMEPAGE_URL}
)

Expand Down

0 comments on commit 4ae95b5

Please # to comment.