vpenades / SharpGLTF

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

Example for the FOSS C# game engine Stride? #74

Closed tebjan closed 1 year ago

tebjan commented 3 years ago

Since the Stride game engine (fka Xenko) offers very high quality shaders, it would be great to have an example for this game engine, including material import.

There are some examples of building a model here:

https://gamedev.stackexchange.com/questions/182379/how-to-create-a-mesh-in-code

And creating a material is quite easy add well, by setting up a MaterialDescriptor and adding it to the model.

        // Create a material (eg with red diffuse color).
        var materialDescription = new Stride.Rendering.Materials.MaterialDescriptor
        {
            Attributes =
            {                   
                DiffuseModel = new MaterialDiffuseLambertModelFeature(),
                // Diffuse = new MaterialDiffuseMapFeature(new ComputeColor { Key = MaterialKeys.DiffuseValue }),
                Diffuse = new MaterialDiffuseMapFeature(),
            }
        };
        var material = Material.New(GraphicsDevice, materialDescription);      
    model.Materials.Add(material);
vpenades commented 3 years ago

Hi

I believe you're talking about integrating glTF with Xenko engine, right?

Unfortunately, it's not that easy... materials is usually the least problem, things like skinning animation and scene graph architecture worry me a lot more. Engine integration depends, to some degree, on the target's engine architecture, and needs to be done specifically for each engine.

So, bear in mind that SharpGLTF, as a stand alone library, must remain engine agnostic.

Having said that, I am currently contributing an engine integration of SharpGLTF with MonoGame, which is still in the works, you can see the repository here:

https://github.com/vpenades/SharpGLTF.Monogame.Example

Notice that it is not my intention to provide SharpGLTF integration for every engine out there , and any engine integration I might work with will be based purely on my own requirements.

In fact, the monogame's engine integration I'm working with is precisely an example of how to integrate SharpGLTF with other engines, so others can use it to take ideas and hints on how to do the integration.

The only parts that can be used for engine integration are the classes and methods found in SharpGLTF.Runtime namespace, which provide structures to handle animation transforms... but anything related to GPU resources like vertex buffers, textures, etc, needs to be handled by the target engine.

So, if the developers of Xenko/Stride need help or assistence, I can help in resolving any question they might have, but I could not do the integration myself since the Stride engine is unknown to me.

GeorgeS2019 commented 3 years ago

@vpenades @tebjan

I have evaluated Stride recently. Though the 3D features implemented very impressive. I think, I could be wrong, sharpGTF has a more comprehensive implementation on GTF than that used in Stride.