Search Unity

Who do I reach out to about investigating and improving upon Unity's math package?

Discussion in 'General Discussion' started by SoundStormLabs, Jan 23, 2024.

  1. SoundStormLabs

    SoundStormLabs

    Joined:
    May 6, 2017
    Posts:
    187
    Just what the title says, my project involves inverting large matrices every frame. Id like to develop a better method of matrix inversion, if it's not already implemented.

    But, how/who do I contact to find out specifically how Unity inverts matrices?
     
  2. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Unity is not open source so your best bet to improve it would to become a Unity employee.
     
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,175
    Unity's built-in libraries like Mathf are only somewhat available for public viewing but viewing is all you're allowed to do with them without an enterprise source license so they're only practical for understanding the internals at a very basic level.

    https://github.com/Unity-Technologies/UnityCsReference/tree/master

    Unity's packages on the other hand are available in their entirety on GitHub, and I think they allow push requests but you're only able to contribute under the Unity Contribution Agreement. You'll want to read through the entire license.

    https://github.com/Unity-Technologies/Unity.Mathematics
    https://unity.com/legal/licenses/unity-contribution-agreement
     
    Last edited: Jan 23, 2024
  4. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    618
    A few points of caution about Unity.Mathematics specifically:
    • A lot of it is meant to be optimal with Burst, so it would be good if optimization came from the assembly code level
    • The types in that library are restricted to common fixed sizes (basically up to 4x4 matrices), it seems like writing a layer on top of the math methods with your own independent data structure is the way to go, which then means you’re looking at optimization of the math methods individually or your use of them, which may or may not have overlap with optimal matrix operations on their known set of types
    • That repository states user PRs aren’t accepted, so take that for what it is
    Some packages like entities aren’t hosted by UT proper, but are at least available in unofficial mirror repositories by needle-mirror. Then there’s Burst which is mainly a bunch of binaries and isn’t currently hosted and maintained on github to my knowledge.
     
    Last edited: Jan 23, 2024
    MadeFromPolygons and Ryiah like this.
  5. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    If Unity math lib with burst is not sufficient and can not find proper repos with libs, which I suspect does somewhere exists, I suggest you develop own solution.

    You could easily build math lib of your own, tailored for what you need and making it compatible with burst.
    In the end, these are just typically multiplication and additions.

    Don't bother asking Unity, if you consider moving with project in upcoming months. Safest to assume is, your request never will be fulfilled by Unity. That way you avoid unnecessary waiting, and wasting time, on something which may or may never happen.
     
    Last edited: Jan 24, 2024
    manutoo and Ryiah like this.
  6. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    If its specifically matrix inversion you want to handle, and you have an algorithm ready to go - its very trivial to wrap that up as its own library. That would be my suggestion rather than trying to deal with unity which will likely take a long time, may not actually take your feedback / do anything with it, and leave you wanting to pull your hair out.

    Individually the employees are great and want to help, but the organisation as a whole moves at a snails pace and processes like taking feedback and implementing it take a long time and go through many peoples hands before its actually actioned, by which time you will have grown old and retired :p
     
    Last edited: Jan 29, 2024
  7. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Unless Unity happens to do exactly what you need already, I'd ignore what they're doing and write my own C# solution and see if it meets my needs. Having the solution built into Unity does not magically or automatically make it faster.

    If it's in the C# portion of the engine then anything they can do, you can do, so you don't need them to do it.

    If it's in the C++ portion of the engine then marshalling to and from could easily eat any algorithmic efficiencies you introduce, even if you could get over the various hurdles to somehow get it included (which is pretty unlikely unless it addresses a common use case). I certainly wouldn't assume that something being native in Unity makes it faster. Also, you can write your own C++ plugin without it being built into Unity.

    Just how large, and how many each frame?
     
    neginfinity, Ryiah and spiney199 like this.
  8. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
    One minor detail.

    Extension methods exist and are useful for those sorts of situations.
     
    MadeFromPolygons and ippdev like this.