From 5e24db54f81740891460bd8fabb1cae22cf9f848 Mon Sep 17 00:00:00 2001 From: Harvey Fong Date: Sat, 22 Mar 2025 14:54:06 -0600 Subject: [PATCH] convert png from srgb to linear --- vmax2bella.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vmax2bella.cpp b/vmax2bella.cpp index 4c324b7..a3963fa 100644 --- a/vmax2bella.cpp +++ b/vmax2bella.cpp @@ -210,6 +210,12 @@ struct RGBA { unsigned char r, g, b, a; }; +static DL_FI dl::Float srgbToLinear( dl::Float value ) +{ + return ( value <= 0.04045f ) ? + ( value * ( 1.0f/12.92f ) ) : + ( powf( ( value + 0.055f ) * ( 1.0f/1.055f ), 2.4f ) ); +} int writeBszScene( const std::string& bszPath, const plist_t root_node, const std::vector palette); bool debugSnapshots(plist_t element, int snapshotIndex, int zIndex); @@ -1570,7 +1576,12 @@ void writeBellaVoxels(const plist_t& root_node, //dielectric["depth"] = 33.0f; // Set the material color (convert 0-255 values to 0.0-1.0 range) - voxMat["reflectance"] = dl::Rgba{ dR, dG, dB, dA }; + voxMat["reflectance"] = dl::Rgba{ + srgbToLinear(dR), + srgbToLinear(dG), + srgbToLinear(dB), + dA + }; } }