f3d-app / f3d

Fast and minimalist 3D viewer.
https://f3d.app
BSD 3-Clause "New" or "Revised" License
2.89k stars 208 forks source link

OBJ Incorrect coloring with vertex colors #613

Open mwestphal opened 1 year ago

mwestphal commented 1 year ago

Describe the bug A obj dataset with vertex colors is incorrectly textured

To Reproduce Steps to reproduce the behavior:

  1. female02.zip
  2. Open the file using f3d --dry-run female02_vertex_colors.obj

a

Expected behavior

a

System Information:

F3D Information Paste the content of f3d --version:1.3.1 and master

snoyer commented 1 year ago

This one may not be about the vertex colors.

If we change some vertex colors to known values, for example make all vertices with positive coords red (sed -r 's/(v [.0-9]+ [.0-9]+ [.0-9]+) [.0-9]+ [.0-9]+ [.0-9]+/\1 1 0 0/g' female02/female02_vertex_colors.obj > female02/female02_vertex_colors_red.obj f3d will render this: f3d-female02_vertex_colors_red obj which makes sense, except for the lack of textures, which would be the actual bug

meshlab render for comparison: meshlab-female02_vertex_colors_red obj

mwestphal commented 1 year ago

Ha ! then VTK does not suport both texture and color, but it should, is that correct ?

snoyer commented 1 year ago

Honestly no idea. According to http://paulbourke.net/dataformats/mtl/: "During rendering, the map_Kd value is multiplied by the Kd value." Assuming the per-vertex colors in the .obj are to be considered equivalent to the per-face Kd values in the .mtl then they should indeed be blended but I don't know what the correct output would be. It could also be another unspecified corner-case.

mwestphal commented 1 year ago

There is a similar ParaView issue for this here: https://gitlab.kitware.com/paraview/paraview/-/issues/21257

With an actual VTK code in it to make it work.

mwestphal commented 1 year ago

Do you think this one matters @Meakk ?

mwestphal commented 1 year ago

@Meakk

Meakk commented 1 year ago

Blending between texture and vertex color makes sense, so there's a bug here in my opinion. However, it's definitely not critical.