13.1.12

MonoGame 3D bugs

MonoGame has pretty good 2D support already. Kudos at its developer team for that. Unfortunately 3D support is still in its infancy. Here's a list of issues I ran into when trying to get the C#/XNA port of my Minecraft clone "Steinkraft" (originally written in C++ using GLES) to run under iOS using MonoGame:
Graphics related:
  • BasicEffect has no PreferPerPixelLighting-Property.
  • BasicEffect.FogEnabled-Property throws "NotImplementedException" on set.
  • Depth testing isn't working. On XNA it seems to be on by default. In MonoGame it's always off.
    • Enabling depth testing doesn't help since there's no depth buffer attached to the framebuffer in IOSGameWindow.
    • I fixed depth test issues by adding a depth buffer render attachment to the framebuffer, adding manual GL11.Enable(ALL11.DepthTest) and setting CullMode to CCW (which should depend on the corresponding RasterizerState.CullMode-Property).
  • Setting the sampler state to "SamplerState.PointClamp" does not work. It should use nearest texture filtering in GL but always uses linear.
  • Frustum culling does not seem to work.
  • Matrix.CreateFromAxisAngle seems to be buggy since camera movement works perfectly fine whereas rotation around Y-Axis yields some strange translation behavior which is probably because the resulting vector is not normalized anymore. Not so sure of that one. 
    • Okay CreateFromAxisAngle is probably okay. Y-Axis rotation yields to translation bug must be elsewhere.
Vertex Buffer related:
  • VertexBuffer has no (GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage bufferUsage)-Constructor.
  • VertexBuffer has no SetData(T[] data)-Method that works with T=float. It always requires T to implement the IVertexType-interface which float obviously doesn't.
  • VertexBuffer-Class stores buffers in fixed size array _allBuffers. There should be no arbitrary limit of the number of vertex buffers.
  • VertexBuffer-Class adds "GenerateBuffer"-Action to a list instead of immediately calling it. Seems like the developer wanted to defer it for some reason. BUT: the CreateFrameBuffers-method invoking each action in the list is actually NEVER called!
Here's a dirty fix for the VertexBuffer-class to work they way SteinkraftXNA uses it:
Note: I don't really get what all this _bufferPtr-crap is for. I personally never did anything else than saving the GenBuffers generated buffer id in an uint and nothing else.

    Since the goal (afaik) of MonoGame is to provide a XNA compatible API pretty much all of these issues should be valid. SteinkraftXNA runs without problems on both Windows Phone 7 and Windows 7 using the reference implementations of XNA from Microsoft.

    0 Comments:

    Post a Comment