wahn/rs_pbrt

[parse_blend_file] vertex colors

wahn opened this issue · 2 comments

wahn commented

An interesting problem is how to deal with Blender's vertex colors:

vertex_colors_01

The pole-vintage mesh has 92928 vertex colors (this is the same amount as loops). Can we use those for rendering?

wahn commented

Looking at the Blender file (using blend_info) we see three data blocks belonging to the pole_vintage mesh, which have that many (92928) entries:

> ~/git/codeberg/rs_blender/blend_info/target/release/blend_info barbershop_v2_79.blend | grep MEpole_vintage -B 15
ME (1416)
  DATA[1] (SDNAnr = 9)
  DATA[1] (SDNAnr = 9)
  DATA[1] (SDNAnr = 0)
  DATA[1] (SDNAnr = 473)
  DATA[23452] (SDNAnr = 63)
  DATA[1] (SDNAnr = 473)
  DATA[46680] (SDNAnr = 60)
  DATA[3] (SDNAnr = 473)
  DATA[92928] (SDNAnr = 68)
  DATA[92928] (SDNAnr = 69)
  DATA[92928] (SDNAnr = 66)
  DATA[2] (SDNAnr = 473)
  DATA[23232] (SDNAnr = 67)
  DATA[23232] (SDNAnr = 65)
  "MEpole_vintage" has 14 data blocks

So, what are those data blocks?

> ~/git/codeberg/rs_blender/blend_info/target/release/blend_info barbershop_v2_79.blend | grep "\[SDNAnr = 68" -A 1
  [SDNAnr = 68]
  MLoopUV (len=12) {
> ~/git/codeberg/rs_blender/blend_info/target/release/blend_info barbershop_v2_79.blend | grep "\[SDNAnr = 69" -A 1
  [SDNAnr = 69]
  MLoopCol (len=4) {
> ~/git/codeberg/rs_blender/blend_info/target/release/blend_info barbershop_v2_79.blend | grep "\[SDNAnr = 66" -A 1
  [SDNAnr = 66]
  MLoop (len=8) {

Most likely MLoopCol is what we are looking for:

> ~/git/codeberg/rs_blender/blend_info/target/release/blend_info barbershop_v2_79.blend | grep "\[SDNAnr = 69" -A 6
  [SDNAnr = 69]
  MLoopCol (len=4) {
    char r;
    char g;
    char b;
    char a;
  }
wahn commented

Since commit feb61f8 those vertex colors render fine:

pbrt

But be aware that PBRT does not really support vertex colors. Even though the colors are defined per vertex in a loop, we expect triangles or quads in meshes and use only the first vertex color in a loop (assuming that all colors for a triangle or quad are defined the same).