CesiumGS / obj2gltf

Convert OBJ assets to glTF
Apache License 2.0
1.72k stars 308 forks source link

[suggestion] In obj2gltf, create a flag --doubleSidedMaterial to allow materials to be doubleSided regardless of transparency #293

Open chetan-set opened 1 year ago

chetan-set commented 1 year ago

Currently, in the obj2gltf repo, a gltf output file will have the doubleSided property of its material tag set to true or false depending of the d or Tr parameters found in the mtl file of the obj model.

This is problematic because there are some obj models that have an alpha value of 1.0 but where not all faces of the model have been properly scanned.

One scenario that I am investigating right now is where a person did a 3D scan of a bridge by standing at the foot of the bridge and generated an obj file. The obj model renders fine but when converted to gltf, the top of the bridge is transparent because:

  1. that part of the bridge was never scanned
  2. at the top of the bridge, the normals are all facing downwards
  3. the model has an alpha value of 1.0

I have tested the model by setting the d value in the mtl file to 0.99. Things are marginally better but then when the model is rotated, at any given time, all faces of the model are visible even when they're not supposed to. (Eg. the foot of the bridge is visible when it's not supposed to while the camera is placed at a birds' eye view)

I would like to suggest adding an extra parameter named --doubleSidedMaterial to the list of command line arguments to toggle the material doubleSided property of the resulting gltf file. By default, this parameter will be false thus preserving the current behaviour of the converter.

Please give me your thoughts.