RBVI / LookSee

LookSee molecular viewer for Quest VR headsets
2 stars 0 forks source link

Molecule colors don't match ChimeraX #9

Closed tomgoddard closed 10 months ago

tomgoddard commented 11 months ago

The color of pdb 4hjv ribbon (blue/purple) in ChimeraX does not match the color in LookSee GLTF which is a light violet. This may be due to GLTF requiring sRGB color space for materials which is not what ChimeraX uses, or possibly the ribbon colors are vertex colors in the GLTF which should be linear, which could look very different. ChimeraX GLTF output uses the standard gamma color space vertex colors used in ChimeraX not linear color space. The stick atom colors are also not matching, being generally lighter in LookSee than in ChimeraX.

The different coloring is not a severe problem, but is worth investigating to understand the origin of the problem.

tomgoddard commented 10 months ago

Phil Cruz asked today about the mismatch in colors between LookSee and ChimeraX. Looking at the GLTF 2.0 specification I see that ChimeraX exported single colors use GLTF pbrMetallicRoughness.baseColorFactor which is in linear color space, and GLTF vertex colors are also documented in the spec to be linear color factors. But ChimeraX is putting its gamma-corrected RGB colors in these fields. So I need to make the GLTF exporter convert from the sRGB gamma-corrected colors to linear when writing the GLTF. For the vertex colors we use 8-bit color components, and for linear space a minimum of 16-bits are recommended to have fine enough color gradations. Going to 16 bit vertex colors will add 4 bytes per vertex which is not too much since vertices and normals are already 24 bytes per vertex. There is example Python code online to convert from sRGB to linear. For the vertex colors I should convert with numpy so export is not slowed down.

tomgoddard commented 10 months ago

Fixed.

I made the ChimeraX Send to Quest tool save colors to GLTF format using linear color space and now those GLTF files appear in the Quest headset to have colors matching the ChimeraX colors. This is a fix in ChimeraX which was writing incorrect GLTF files using sRGB (gamma-corrected) color space. No change was made to LookSee.