So yes, the C# code on both top/bottom videos is actually identical. If we had Unity source, it would be a ~10-line change + you need to make UI for the user to add actual colliders to the wheels. But since we don't have it, we do it in arcane ways.
...aand somehow it actually WORKED 🤪
Even if you don't have Unity source code, you still have the asm and the pdb, so it's ALMOST like having source code 😂
And I wrote a DLL that exposes a function with a similar signature, but instead, adds actual wheel shapes to the car and calls PxVehicleSuspensionSweeps. I also had to convert data between raycast/sweep queries.
But it's not going to stop us... us being me and Alex (@Meetem4 on twitter) who wondered if we can just hack it into Unity. And we tried.
Thanks to Unity.pdb
Alex managed to find where it calls PxVehicleSuspensionRaycasts and replace it with a jump to custom mem where he forwarded it to a DLL
...but not in Unity. As it turns out, PhysX supported non-ray wheels for about 10 years. It's mentioned in 2017 on Unity forum... https://discussions.unity.com/t/physx-v3-4-new-vehicle-module-changes/666355
Yet Unity never exposed this abiltiy (even though they kept updating PhysX version).
Do you also dislike how Unity's WheelCollider only casts 1 center ray, so cars jump on every tiny bump?
Did you also see 3rd-party assets doing like 16 rays per wheel and thought maybe it's kinda expensive?
Did you know that PhysX can actually sweep convex shapes instead of rays?
Apart from that the code is pretty simple. Dot gives you a blob, centered around object's pivot; sum of two pows gives a longer tail (GGX-ish, can probably do the same without pows).
Light has stable world-space size done via this w*w dark magic. I remembered Humus' "phone-wire AA" using w for stable wire thickness, tried it here and it almost worked, but was still off... I squared it because it looked like it needs squaring, and it worked!
...and TBH I'm still not entirely sure why squaring makes it work mathematically.
Improvised a little lampshade shader that imitates scattered light from inside. Code in the pic! :)
Details in the comments...
#gamedev