stride icon indicating copy to clipboard operation
stride copied to clipboard

Gltf Importer

Open ykafia opened this issue 3 years ago • 17 comments

PR Details

This PR aims to add SharpGLTF as an asset loader for gltf/glb files

Description

  • Added a project Stride.Importer.Gltf
  • Added the necessary files to handle the gltf importer in Stride.Assets.Model

Related Issue

#603 #336 (to some extent)

Motivation and Context

glTF is a relatively new 3d scene file specification, being able to store way more information than common specifications. It's open source and doesn't need any native binding of any sort. It's also a very well supported file specification across well known 3D softwares (Maya, 3DSMax, Blender, ZBrush)

Types of changes

  • [x] Docs change / refactoring / dependency upgrade
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [x] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • [ ] My change requires a change to the documentation.
  • [ ] I have added tests to cover my changes.
  • [ ] All new and existing tests passed.

Gltf samples working

multi model files are annotated with MM

  • [x] 2CylinderEngine
  • [ ] AlphaBlendModeTest
  • [x] AnimatedCube
  • [ ] AnimatedMorphCube
  • [ ] AnimatedMorphSphere
  • [x] AnimatedTriangle
  • [ ] AntiqueCamera
  • [x] Avocado
  • [x] BarramundiFish
  • [x] BoomBox
  • [ ] BoomBoxWithAxes
  • [x] Box
  • [x] Box With Spaces
  • [x] BoxAnimated
  • [ ] BoxInterleaved
  • [x] BoxTextured
  • [ ] BoxTexturedNonPowerOfTwo
  • [x] BoxVertexColors
  • [x] BrainStem
  • [x] Buggy
  • [ ] Cameras
  • [x] CesiumMan
  • [ ] CesiumMilkTruck
  • [ ] ClearCoatTest
  • [x] Corset
  • [x] Cube
  • [x] DamagedHelmet
  • [x] Duck
  • [ ] EnvironmentTest
  • [ ] FlightHelmet
  • [x] Fox
  • [ ] GearboxAssy
  • [ ] InterpolationTest
  • [x] Lantern
  • [ ] MaterialsVariantsShoe
  • [ ] MetalRoughSpheres
  • [ ] MetalRoughSpheresNoTextures
  • [ ] MorphPrimitivesTest
  • [ ] MorphStressTest
  • [ ] MultiUVTest
  • [ ] NormalTangentMirrorTest
  • [ ] NormalTangentTest
  • [ ] OrientationTest
  • [ ] ReciprocatingSaw
  • [ ] RiggedFigure
  • [ ] RiggedSimple
  • [ ] SciFiHelmet
  • [ ] SheenChair
  • [ ] SheenCloth
  • [ ] SimpleMeshes
  • [ ] SimpleMorph
  • [ ] SimpleSkin
  • [ ] SimpleSparseAccessor
  • [ ] SpecGlossVsMetalRough
  • [ ] Sponza
  • [ ] Suzanne
  • [ ] TextureCoordinateTest
  • [ ] TextureEncodingTest
  • [ ] TextureSettingsTest
  • [ ] TextureTransformMultiTest
  • [ ] TextureTransformTest
  • [ ] ToyCar
  • [ ] TransmissionTest
  • [ ] Triangle
  • [ ] TriangleWithoutIndices
  • [ ] TwoSidedPlane
  • [ ] UnlitTest
  • [ ] VC
  • [ ] VertexColorTest
  • [ ] WaterBottle

ykafia avatar Mar 09 '21 20:03 ykafia

I'm sorry for creating another pull request, i preferred creating it from another branch instead of my master! Also @xen2 do you have a bit of time to help me with the Stride.Importer.Gltf.csproj parameters i need to add ? I have a bit of trouble understanding how to integrate the project well in Stride. The issue being : when i compile Stride.Importer.Gltf, dlls of the referenced projects are not found (TFM issue it seems)

ykafia avatar Mar 09 '21 20:03 ykafia

CLA assistant check
All CLA requirements met.

dnfadmin avatar Mar 25 '21 11:03 dnfadmin

Known issues so far

  • Color vertex models render weirdly (most likely due to a bad VertexDeclaration conversion
  • Normal map textures are correctly imported but render fails on some models (DamagedHelmet and Fox). It might be due to the fact that i extract the textures and save them (probably in the wrong format)

ykafia avatar Apr 02 '21 14:04 ykafia

This PR is ready for review. Most features are handled, no breaking changes introduced. If any bugs appear on the import this should probably go to new issues.

ykafia avatar Jun 21 '21 13:06 ykafia

Is this ready to be re-reviewed/merged in ? Looking at the first post there seems to be quite a lot of things not supported yet ?

Eideren avatar Aug 05 '21 00:08 Eideren

Yes it's ready to be re-reviewed. Most tests i made didn't fit with Game Studio since they contains complex scenes with multiple objects while we only need to import one model so it should be alright. In the future if any issues arises on importing gltf models i'd do my best solving them

ykafia avatar Aug 05 '21 09:08 ykafia

What gltf feature does this PR not support yet ?

Eideren avatar Aug 05 '21 10:08 Eideren

  • Importing scenes as a whole, with lights and cameras.
  • Multi model scenes import, currently only imports the first model present in the scene. Related to first point. Reason for that is because importing a model in Game Studio is designed to import one object only.
  • Only vanilla gltf specification is supported, some extensions can be added though

ykafia avatar Aug 05 '21 10:08 ykafia

I see, I'm pretty sure the fbx importer imports multiple models as one model asset, I think it makes sense for the gltf importer to replicate that behavior ?

Eideren avatar Aug 05 '21 10:08 Eideren

Haven't realized that about fbx but yes it makes sense to replicate this behavior, i think i had a draft somewhere about merging gltf meshes, animations will need more work though

ykafia avatar Aug 05 '21 11:08 ykafia

I see, I'm pretty sure the fbx importer imports multiple models as one model asset, I think it makes sense for the gltf importer to replicate that behavior ?

This limit of the FBX importing isn't necessarily a good thing. Its actually a little tedious to have to export each element of a scene separately and import it separately, and maybe realign it to a scene. As a user it would be preferable if this were optional in Stride. Sometimes I would like to import a scene for its parts to be separated into their own model assets, maybe with the translation and rotation initially set by the mesh's transformation data. It means a user could tweak the location of objects in levels or treat parts of the scene as prefabs. Importing character models and animations may also be a little simpler this way.

YanYas avatar Aug 05 '21 13:08 YanYas

@YanYas I don't believe you would rather have only the first model of a multi-model file be imported, like ykafia said for the current state of this PR.

Defaulting to splitting 3d object files into multiple model asset isn't any better than merging everything down to one, it depends on the user and/or file content whether it makes more sense to go for the former or latter.

Anyway if you want to continue this discussion open a new issue instead, it's not really related to asset format but how assets are stored; models can hold multiple meshes, you can split them into separate assets after import but it needs to be supported by the editor's asset reload function.

Eideren avatar Aug 05 '21 14:08 Eideren

Indeed, but to repeat it would be preferable if this were optional in Stride, (I say this meaning the Game Studio in particular). I bring this up here only because I would rather that this approach to importing was expanded ahead of time rather than defaulting to something I see as limited, but I see your point.

YanYas avatar Aug 05 '21 14:08 YanYas

Oi, again, just create a new issue mate, this is out of scope of this PR.

Eideren avatar Aug 05 '21 14:08 Eideren

Hello @ykafia, how's this PR coming along ? Should I mark this PR as a draft or is this ready to be reviewed ?

Eideren avatar Jan 04 '22 13:01 Eideren

You can mark it as a draft, I will focus my attention on the Assimp PR.

ykafia avatar Jan 04 '22 13:01 ykafia

Would this topic be available for funding from the open collective?

Aggror avatar Jan 21 '22 19:01 Aggror

Hey, any progress on this?

NicusorN5 avatar Dec 02 '22 02:12 NicusorN5

Not much progress except I've made a C# port of MikktSpace tangent generation.

ykafia avatar Dec 02 '22 10:12 ykafia

MikktSpace tangent generation

Shouldn't we use the tangent generation that we already have, because it will fit with the Stride PBR material shaders?

tebjan avatar Dec 06 '22 15:12 tebjan

Are there any updates on this? Im sure people would support an open collective as mentioned before. It could even be related to the opencollective project about support for multiple animations per file. An update would be nice since we have already prototyped a vvvv vl.stride plugin for GLTF but having it work in stride itself would be much nicer since everyone would benifit.

vjgegenlicht avatar Jul 28 '23 10:07 vjgegenlicht

Very old PR, should be started again since it's in conflict with the assimp library.

ykafia avatar Nov 18 '23 13:11 ykafia