Sojour

The solo virtual table top

Tag: Graphics Engine,

  • DirectX Separation & PBR

    Dorian now supports PBR (Physical Based Rendering)!

    The graphics engine for Sojour 2 has had two quite large enhancements made to it.

    Firstly the lighting and materials rendering system now uses Physical Based Rendering (PBR). This is a rendering technique that uses approximations of actual lighting physics to produce more natural lighting.

    The other advantage of PBR is that it can simulate practically any material that you can think of with the correct textures and setup.

    For example, the sphere shown above is actually a smooth sphere, but looks rocky thanks to the textures below combined in magical mathematical PBR ways:

    Dorian now accepts many texture types to support its material modelling.

    Here is the same sphere with different textures and materials applied, as you can see, it’s totally smooth!:

    Applying different materials to anything is a doddle!

    Even where a model has no textures, like the TIE Fighter for example, you can easily change its look on the fly:

    I’d like a TIE fighter please Sir! But in Chrome!

    The next huge undertaking was removing DirectX from the engine and keeping it completely separate:

    DirectX-11 has now been separated from the Engine!

    It was a huge job, but it is necessary to allow the engine to support other backend renderers such as DirectX-12 or Vulkan.

    This was a huge undertaking as all aspects of the system got altered to support a more abstracted means of rendering.

    What makes writing a graphics engine difficult – apart from the complexity – is ensuring performance is not compromised by code changes such as the refactor above.

    The amount of code changed to separate DirectX-11 was staggering and the initial performance results were not too good (all graphs measure the scene you see above):

    Whilst the new one held 120 FPS (my TV’s refresh rate) – it took a noticeable dip in performance for 1% and 0.2% lows.
    These are frame times. Lower is better and you can see that the newer version’s performance really falls away compared to the pre-DirectX separated version. It also has a ton of random spikes in frame time. (Frame time is a better measure for performance)
    This graph really brings home how much worse the newer system was in terms of performance.

    Detailed performance measurements when creating a graphics engine are critical. It’s almost impossible to see the above differences by eye – so you must take the measurements before and after each change.

    In this case I traced the problem to the fact that material caching had been broken by the refactor. After around a day of coding, everything is now back where it should be (and in fact a little better than it was!):

    Much better! In fact we are now performing a little better than the original system!
    The new version produces lower frame times across the board! The only thing left to investigate are the occasional big spikes.
    For smooth frame times the newer Direct-X system is way better than the old one! Quite amazing given how much more complex the new version is!

    This is one of the reasons why engine development takes so long. You aren’t just writing code that works, you are also writing code that’s highly performant!

    I’ll leave you with a You-Tube video showing everything in motion. As usual, the smooth framerates never seem to translate well on You-Tube. If you look carefully, you’ll see me toggling the TIE Fighter to chrome and back!

    Dorian in action!

    Still a long way to go, but we are getting there.

    I know writing Dorian seems like a diversion, but Ionian which is the engine used in Sojour cannot be used in conjunction with the latest technologies hence the re-write. (To be fair, Ionian lasted over twenty years, so it has had a great run for its money!)

    Have Fun!

    RobP

  • Back to Dorian – Sojour 2’s new graphics engine

    Dorian being put through its paces!

    I took a month off to pursue other hobbies and have now returned to continue work on Dorian, Sojour 2’s new graphics engine.

    Dorian is needed because Sojour 2 will use Microsoft’s latest .NET framework, and that framework comes with a development environment that can only compile 64-bit applications. Alas, Ionian, the graphics engine used in Sojour 1, is only 32-bit, hence the need for a new engine.

    On the plus side, Dorian can render to multiple windows simultaneously, which has huge implications for Sojour 2, including the ability to project a DM-only view of a map during in-person games.

    During this development tranche, the ECS engine received a major overhaul. I now have a much deeper understanding of the ECS architecture, which enabled me to make some significant performance improvements.

    I’ve also added the ability to import external 3D models, giving the engine feature parity with Ionian.

    Finally, the lighting engine has been improved, although there is still a long way to go.

    Here is a video showing the current version being put through its paces. The measured frame rate is accurate, as verified using NVIDIA’s FrameView tool.

    I’m running Dorian with VSync disabled and letting it run flat out, which explains the rather high frame rate.

    Unfortunately, game engine videos on YouTube never look quite as smooth as they do in person, but the engine itself is ultra-smooth. You can watch the video here:

    There is still a great deal more to do, but once Dorian is complete, I can turn my attention to developing Sojour 2 itself, which will incorporate this graphics engine.

    As noted in previous posts, Sojour 2 will be free for all existing Sojour customers.

    Have fun!

    RobP