obj: reduce vertex colors to 4 decimal places, reenable tests

OBJ vertex color related tests were not producing identical results
across various platforms, primarily due to sRGB<->Linear color space
conversions.

While D15193 has just made the color space conversion accuracy match
much closer between platforms, it's still not 100% the same.

This change reduces the amount of decimal places used for exporting
vertex colors, to 4 digits (down from 6). Vertex normals were
already always printed with 4 digits, and colors are conceptually
similar (usually 0..1 range etc.).

This makes the vertex color tests pass again, so re-enable them
after adjusting to 4 decimals expectations.
This commit is contained in:
Aras Pranckevicius 2022-06-15 20:59:38 +03:00
parent 004d858138
commit 653100cd65
3 changed files with 6 additions and 10 deletions

View File

@ -132,7 +132,7 @@ constexpr FormattingSyntax syntax_elem_to_formatting(const eOBJSyntaxElement key
return {"v {:.6f} {:.6f} {:.6f}\n", 3, is_type_float<T...>};
}
case eOBJSyntaxElement::vertex_coords_color: {
return {"v {:.6f} {:.6f} {:.6f} {:.6f} {:.6f} {:.6f}\n", 6, is_type_float<T...>};
return {"v {:.6f} {:.6f} {:.6f} {:.4f} {:.4f} {:.4f}\n", 6, is_type_float<T...>};
}
case eOBJSyntaxElement::uv_vertex_coords: {
return {"vt {:.6f} {:.6f}\n", 2, is_type_float<T...>};

View File

@ -436,8 +436,6 @@ TEST_F(obj_exporter_regression_test, cubes_positioned)
_export.params);
}
/* Disabled until sRGB<->Linear conversion produces close enough results between
* SSE2 and non-SSE2.
TEST_F(obj_exporter_regression_test, cubes_vertex_colors)
{
OBJExportParamsDefault _export;
@ -450,7 +448,6 @@ TEST_F(obj_exporter_regression_test, cubes_vertex_colors)
"",
_export.params);
}
*/
TEST_F(obj_exporter_regression_test, cubes_with_textures_strip)
{
@ -510,7 +507,7 @@ TEST_F(obj_exporter_regression_test, all_objects)
_export.params.forward_axis = IO_AXIS_Y;
_export.params.up_axis = IO_AXIS_Z;
_export.params.export_smooth_groups = true;
//_export.params.export_colors = true;
_export.params.export_colors = true;
compare_obj_export_to_golden("io_tests/blend_scene/all_objects.blend",
"io_tests/obj/all_objects.obj",
"io_tests/obj/all_objects.mtl",

View File

@ -453,7 +453,8 @@ TEST_F(obj_importer_test, import_all_objects)
float3(13, 1, -1),
float3(11, 1, 1),
float3(0, 0, 1),
float2(0, 0)},
float2(0, 0),
float4(0.0f, 0.002125f, 1.0f, 1.0f)},
{"OBUVCube",
OB_MESH,
8,
@ -509,7 +510,6 @@ TEST_F(obj_importer_test, import_all_objects)
import_and_check("all_objects.obj", expect, std::size(expect), 7);
}
/*
TEST_F(obj_importer_test, import_cubes_vertex_colors)
{
Expectation expect[] = {
@ -524,7 +524,7 @@ TEST_F(obj_importer_test, import_cubes_vertex_colors)
float3(-1.0f, -1.0f, 1.0f),
float3(0, 0, 0),
float2(0, 0),
float4(0.846873f, 0.027321f, 0.982251f, 1.0f)},
float4(0.846873f, 0.027321f, 0.982123f, 1.0f)},
{"OBCubeVertexFloat",
OB_MESH,
8,
@ -535,7 +535,7 @@ TEST_F(obj_importer_test, import_cubes_vertex_colors)
float3(1.392028f, -1.0f, 1.0f),
float3(0, 0, 0),
float2(0, 0),
float4(49.99558f, 0.027321f, 0.982251f, 1.0f)},
float4(49.99467f, 0.027321f, 0.982123f, 1.0f)},
{"OBCubeCornerByte",
OB_MESH,
8,
@ -580,7 +580,6 @@ TEST_F(obj_importer_test, import_cubes_vertex_colors)
};
import_and_check("cubes_vertex_colors.obj", expect, std::size(expect), 0);
}
*/
TEST_F(obj_importer_test, import_cubes_vertex_colors_mrgb)
{