vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
470 stars 75 forks source link

Rendering in Cesium #15

Closed bertt closed 5 years ago

bertt commented 5 years ago

Hi, I'm evaluating this library and comparing to another one (glTF-CSharp-Loader).

One thing I noticed when rendering in Cesium (my target platform) the model boundaries are not rendered when using this library:

sharpgltf

When using glTF-CSharp-Loader rendering is better:

loader

I'm using VSCode with glTF Tools Extension to inspect the glTF's in Cesium.

Question: How can I render the model just like when using using glTF-CSharp-Loader?

I've attached the 2 glb's to inspect (building_sharp_gltf.glb and building_gltf-csharp_loader.glb)

Thanks! models.zip

experimental code see https://github.com/bertt/GltfExperiment

vpenades commented 5 years ago

Hi, so far, the only difference I can see between the two models is that the one you created with gltf-csharp-loader has normals, and the one you created with SharpGLTF does not have normals.

you have to change this line:

using VERTEX = SharpGLTF.Geometry.VertexTypes.VertexPosition;

by this line:

using VERTEX = SharpGLTF.Geometry.VertexTypes.VertexPositionNormal;

Notice that this new vertex type will require you to fill both the vertex and the normal.

Also, I've tested both models with GLTF Validator and the one you're creating with gltf-csharp-loader has lots of errors.

bertt commented 5 years ago

ok thanks! its fixed in https://github.com/bertt/GltfExperiment/commit/dbfaba86ccddaa42ce0eb0573a6d6b5555f5f6b0

fixed_sharpglt

Apperently Cesium needs normals for rendering well.

I know about the validation errors when using gltf-csharp-loader, it 's one of the reasons for evaluating this library.

vpenades commented 5 years ago

Most engines need normals for rendering, just a few are able to generate normals on the fly.

As the gltf-csharp-loader says, that library is more intended to "load" models than to build them from scratch and save them, which is quite difficult to do, and the reason why I wrote SharpGLTF.