» VL: Switch to Xenko Math
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

VL: Switch to Xenko Math

In preparation for the Xenko game engine integration we decided to change the default math library of VL from SharpDX to Xenko. The decision was particularly easy since both math libraries have the same origin and most types and methods are identical. And thanks to the VL import layer it's easy to switch out the types, without any noticeable changes for the VL user.

What you get:

  • Existing VL patches will continue to work as before
  • No conversion needed when working with Xenko
  • Faster matrix uploads to GPU (see below)

Trivia

We are (again) in luck with Xenko since it just so happened that Alexandre Mutel, who developed SharpDX, was a core developer at Xenko. We actually didn't know that at the time we started to work on the VL core library. We chose SharpDX mainly because it was well established, complete and open source. So it was quite a nice surprise when we browsed the Xenko source code for the first time and saw that they basically use the same math code.

Download

Here are direct links to the latest preview versions:
vvvv gamma 2019.1 preview 624
vvvv_50alpha38.2_x64
addons_50alpha38.2_x64

Technical Details

This section is only relevant for library developers.

Transposed Matrix Memory Layout

Xenko's 4x4 matrices have a transposed memory layout compared to SharpDX. This is not to be confused with transposed matrix elements (M11, M12, M13 etc.), it is only relevant when doing low-level operations with memory and pointers, such as uploading them to the GPU. The big advantage of it is, that Xenko's matrices can directly be uploaded to the GPU without the overhead of transposing them.

Changes on C# Projects

Most C# projects written for VL don't need to be changed. Only if they use the SharpDX.Mathematics nuget to work with vectors, matrices, rectangles etc.:

In order to transition your C# project to Xenko, remove the SharpDX.Mathematics nuget and install Xenko.Core.Mathematics instead. Then change the using statements in the C# files:

//old:
using SharpDX;
 
//new:
using Xenko.Core.Mathematics;

If you then get an error on compilation, your project might be in the old format. Upgrading is quite easy, it just involves changing the header and deleting most lines in the project file. Follow this guide or join our chat if you need help.

Please give the new version a spin and send us a report if anything doesn't work as before.
Happy calculations!

Yours,
devvvvs

tonfilm, Friday, Aug 23rd 2019 Digg | Tweet | Delicious 6 comments  
domj 27/08/2019 - 12:18

I'm sure this is the right way going forward in preparation for Xenko but it might not be as smooth a transition for old patches as you might think.

The issue I'm having is with Deserialization. I have loads of files with serialized data which also use the SharpDX data types. Now VL has no idea what those types are.

Do I have to find and replace all the references (possibly automated) in the XML files, implement my own serializers or is there some way to add some sort of type alias so that VL would automatically recognize the old types and load them as Xenko types?

Thanks

tonfilm 27/08/2019 - 13:14

@domj That should all work fine, VL doesn't save a type hint to SharpDX in the files. This was of course tested. Can you describe in a forums thread what you did in order to get SharpDX type hints into your files?

domj 27/08/2019 - 15:18

@tonfilm by building a silly application that seems to explore many VL corner cases :D. I'll post in the forum with details but I think the gist of it is serializing collections of Objects which of course need type hints to be read back.

velcrome 26/02/2020 - 11:04

chances are that this will not affect anyone else at this point in time. however, if you do have to upgrade, plan in a little more time.

as the first post stated, only csproj files adhering to the new sdk-style will work. this is 100% true.
however, the upgrade process is definitely not an easy one, like fixing the first line and being done.
after manual tinkering the file for a few hours with little effect but frustration, I ended up making a new folder, creating a new .net standard 2.0 project and reimporting all used files, nugets, and other dependencies.

because it is missing in the original post: as of vvvv beta39 you have to use Xenko.Core.Mathematics 3.1.0.1-beta02-0741. it is available only from nuget.org, vvvv.org seems to have rolled over it long ago.

the good thing that came from it: the csproj is now only a tenth of its former size, and no packages.config at all.

tonfilm 26/02/2020 - 15:44

@velcrome yes, making a new project file is the easiest. most vvvv/vl projects are tiny and you only need to set the dependencies. c# files get listed automatically with the new project format.

about the Xenko.Core.Mathematics reference, you can use the official release one, the specific version shouldn't have an impact: https://www.nuget.org/packages/Xenko.Core.Mathematics/3.1.0.1

  • 1

anonymous user login

Shoutbox

~10h ago

joreg: vvvvTv S02E01 is out: Buttons & Sliders with Dear ImGui: https://www.youtube.com/live/PuuTilbqd9w

~7d ago

joreg: vvvvTv S02E00 is out: Sensors & Servos with Arduino: https://visualprogramming.net/blog/2024/vvvvtv-is-back-with-season-2/

~8d ago

fleg: hey there! What's the best tool for remote work? Teamviewer feels terrible. Thanks!

~21d ago

joreg: Last call: 6-session vvvv beginner course starting November 4: https://thenodeinstitute.org/courses/ws24-5-vvvv-beginners-part-i/

~1mth ago

joreg: Missed the last meetup? You can rewatch it here: https://www.youtube.com/live/MdvTa58uxB0?si=Fwi-9hHoCmo794Ag

~1mth ago

theurbankind: When is the next big event, like node festival ?

~1mth ago

~1mth ago

joreg: Join us for the next vvvv meetup on Oktober 17th: https://visualprogramming.net/blog/2024/25.-vvvv-worldwide-meetup/

~1mth ago

joreg: 6 session beginner course part 2 "Deep Dive" starts January 13th: https://thenodeinstitute.org/courses/ws24-5-vvvv-beginners-part-ii/