diff options
author | Aras Pranckevicius <aras@nesnausk.org> | 2022-06-15 20:59:38 +0300 |
---|---|---|
committer | Aras Pranckevicius <aras@nesnausk.org> | 2022-06-15 21:05:35 +0300 |
commit | 653100cd651d43daa1f814ef49d1f0d7a9a0ee52 (patch) | |
tree | 312ea5f2f41c9d559216231796be527fb1cf2eca /source/blender/io/wavefront_obj | |
parent | 004d858138fced20d45cf3cc0149fcef1922c8a0 (diff) |
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.
Diffstat (limited to 'source/blender/io/wavefront_obj')
3 files changed, 6 insertions, 10 deletions
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh index 157d7760307..5413c9969e3 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh @@ -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...>}; diff --git a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc index fea74c2fd90..6aec848573f 100644 --- a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc @@ -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", diff --git a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc index efdd8839615..b67adbc9753 100644 --- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc @@ -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) { |