warrenm / GLTFKit2

A glTF 2.0 asset loader and exporter for Objective-C and Swift.
MIT License
150 stars 26 forks source link

Broken surfaces in RealityKit #59

Closed agg23 closed 2 months ago

agg23 commented 2 months ago

This may be an issue with my models, but these are correctly rendered in Blender.

On several different models I have observed various surfaces being transparent in RealityKit on visionOS. Due to difficulty manipulating a 3D object on Vision, I have not been able to confirm if the surface normals are simply reversed. Blender doesn't show this issue.

Blender

image

visionOS (RealityKit)

image

Attached are two different forms of the same simple model that exhibit this issue: Brick Repro.zip

warrenm commented 2 months ago

This is a winding order issue. Your model appears correct in Blender because it's doing double-sided rendering, such that winding order doesn't matter. But upon export, I suspect it's writing out primitives that are wound clockwise, which differs from the convention specified by glTF. You should be able to get correct results in RealityKit by reversing the primitive winding order and re-exporting.

For comparison, this is what your model looks like when rendered by Gestaltor, a popular glTF editing tool:

winding
agg23 commented 2 months ago

Thank you for your help. I'll look into getting the models fixed. I apologize for my inexperience.

warrenm commented 2 months ago

No need to apologize, and don't hesitate to file issues in the future should you encounter any further difficulty. That's how we collectively improve.