Axis orientation in Prime/Unity

Going through a bit of trial and error here… Anyone knows how the transform the axis from Unity to Optix? They seem to be off

We’ll need a bit more information. What did you try to do, and what is the evidence that something is off?


David.

Hi David,

it’s fairly simple, I have one triangle in the scene and I want to shoot rays to see if they hit.

So I manually create the mesh and both assign it to meshfilter etc. in Unity as well as pass it to OptixPrime API (via DLLImport, which works surprisingly well)

I then create some rays, read the hit data and generate debug rays in Unity to check what hit and what didn’t.

My expectation is now that the mesh that I generated in the scene and the ray hits overlap.

The first thing that happens is that I don’t even hit anything when I shot down the Z axis (forward in Unity). When I turn this 90 degrees I do get hits, but the triangle is very distorted.

So I was just wondering how the axis work with prime or if I am missing something else. (I tried a bunch of variations, but somehow can’t visualize the problem properly to fix it)

It’s still very hard to say. If your rays are the same in Unity & OptiX, and if your triangle vertices are the same in Unity and OptiX, then you should have the same intersections.

Are you creating the rays yourself in both cases, or is Unity creating rays for you? One thing to be aware of is that Unity has a left handed coordinate system, which could be confusing if you’re using right-handed conventions when you generate your rays for OptiX.

Do you have any transforms or matrices in your setup?

I don’t think there’s anything in OptiX Prime that you’re missing or that could even mess you up. It seems more likely there is a translation error somewhere between your Unity data and OptiX data, that you’re not creating the same rays or verts for some reason, or that Unity is doing something you’re not aware of. Double check that there isn’t an indexing typo & that vector components aren’t being transposed.

For a single triangle and a single ray, you should be able to write down all the coordinates and verify whether it’s working on paper. Feel free to post those here if it still seems like OptiX is not doing what you expect.


David.

Hi David,

you’re correct. I tried a few things, the one triangle was me also with a piece of paper, until it eventually clicked. So I can’t put my finger on what it was in the end. But yes, one of them was taking care of the handedness.

I also double checked the buffer types and sizes, and switched from System.Numeric.Vector3 to Unitys.

(Just in case someone google their way here. Outside of the handedness there is no magic at work)

Thanks!