Pre sort them https://pastebin.com/Sdj3vvwz
This is a test for Indexed this time.
But i’m unaware of the OpenGL pipeline and whether it shares same approach, various contexts, reusage of shaded contexts and so on.
In current code the 3db model contains ~6000 _3d structures for making calls to DrawIndexedXXXXX. However, they’re ordered by a material so calls to shading context occurs 3 times only. Calls to draw don’t matter almost as shaded context for a particular material is reused.
I’m unable to measure CPU load because of 8+8 cores on modern hardware. Task manager shows 6-8% lol. Gotta surf the web for some specialized tool.
This model has arbitrarily bloated number of VMeshGroups in mesh for no reason whatsoever. It’s not engine job to resort and merge groups, it is exporter job to produce sane result by combining face groups matching material within each LOD of each compound part.
I’ve just re-exported it in Maxlancer which resulted in only 6 VMeshGroups. 6 draw calls is all it takes and all it should have ever been in the first place. There never was any excuse to have any more than that.
It’s rendering optimization/resorting.
Well, there’s another bug that came in sight both in my attempts and LibRelancer: not all parts’ maxtrices are applied in real.
These are 3 Aurora nebulae in Ku02 system in original Freelancer:
But in SystemViewer all three are rendered in one position:
Mine renders same as i started “optimizing”. Unlike old archieved build, where i used to reapply shader on each mesh and reset matrices for each part, but that, of course, impacts performance. (images are HD just in case, right click - open, my browser cuts large previews here so i reduce them)
I’m personally planning to bind a buffer of part indices parallel to vertices and allocate Parts[MAX_PARTS] in a shader. More no thoughts yet.
About blending, texture’s runtime format is incorrect. In my code (and this is Direct3D) there’s a conversion:
Alpha := FreeImage_IsTransparent(Targa); if Alpha then Format := DXGI_FORMAT_B8G8R8A8_UNORM else Format := DXGI_FORMAT_B8G8R8X8_UNORM; ```All i know is this makes match Freelancer in drawing starspheres.
I don’t check this very often, so if you’re having rendering bugs like in Ku02 please report them in the github issues with the version of the software you’re using.
R.E. that awful cmp/mesh:
- There is a very limited amount of mesh fixups applied in the engine on load time, but they’re only applicable in very small amounts of situations. The only solution there will be to export the model properly, as the FL resource loading model simply doesn’t work in such a way that I can modify the vertex buffers at runtime and maintain full vanilla compatibility.
And with “Latest SystemViewers work for me, but not gameengine itself. Some of previous daily builds work, some don’t.” this is not something I can do anything with as there is simply not enough info. There’s a lot of game engine work going on at the moment, and while it does work with vanilla I can’t guarantee mod compatibility. Especially if you’re not using the nice Copy Details button I made when there are crash errors
Mini investigation for fun:
The reason you’re getting 6200+ drawcalls and 10fps on that specific model, besides the fact it is completely broken, is because Librelancer could not find the materials at load time. If the .mat file is loaded before the model (e.g. you set the archetype right), it is safe enough to apply the reordering optimisation and it drops down to 6 drawcalls, proper FPS. Though it’s not guaranteed if it can’t find a place to shove the new index information.
The game engine crashes on intro scene’s end (in New Game start) for me.
GL Error: Invalid Value at LibreLancer.GL.CheckErrors() at LibreLancer.UniformBuffer.BindTo(Int32 binding, Int32 start, Int32 count) at LibreLancer.BasicMaterial.Use(RenderState rstate, IVertexType vertextype, Lighting& lights) at LibreLancer.CommandBuffer.AddCommand(RenderMaterial material, MaterialAnim anim, WorldMatrixHandle world, Lighting lights, VertexBuffer buffer, PrimitiveTypes primitive, Int32 baseVertex, Int32 start, Int32 count, Int32 layer, Single z, DfmSkinning skinning) at LibreLancer.Utf.Dfm.DfmMesh.DrawBuffer(CommandBuffer buffer, Matrix4x4 world, Lighting light, Material overrideMat) at LibreLancer.Utf.Dfm.DfmFile.DrawBuffer(CommandBuffer buffer, Matrix4x4 world, Lighting& light, Material overrideMat) at LibreLancer.CharacterRenderer.Draw(ICamera camera, CommandBuffer commands, SystemLighting lights, NebulaRenderer nr) at LibreLancer.SystemRenderer.Draw() at LibreLancer.RoomGameplay.Draw(TimeSpan delta) at LibreLancer.FreelancerGame.Draw(Double elapsed) at LibreLancer.Game.Run() at lancer.MainClass.<>c__DisplayClass0_0. <main>b__0() at LibreLancer.AppHandler.Run(Action action, Action onCrash)Recent daily build. Another crash was about [; parsing aka disabled ini section when i tried to load a mod. I'm running virtual machine actually, wherein 4.7.1 NET is installed only. Systemviewer is stable for me though. ______ Looks like i fixed parts in my code by resetting cached material index when a new different part starts rendering https://pastebin.com/yru1Rq7E</main>
Amazing work Ichiru. I’ve dreamed for an open client to help me learn programming through. Textbooks on C# can teach me basics, but seeing so many examples of how things are implemented, can help me wrap around more game-related, practical uses. Going to love this. Downloading it and the source now, for when I get a rainy day and can jump back into learning C#. I have some scripting/programming OOP knowledge from full-stack web development, but nothing software. Hoping it still affords a good headstart into basics.
Thanks again. This is an amazing project and a great start.