-
the author‘s original code by WebGL, which is right-hand coordinate system |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Importing the .obj file is done using Unity's standard Asset Import Pipeline, which handles loading data from .obj in the correct way. So the mesh doesn't need any manual conversion, because Unity does it for you. In the shader I do perform some coordinate system conversion. This gets a bit messy to explain, because the original code itself flips y-and z, but only for synthetic and unbounded 360° scenes (can be seen here https://github.com/google-research/jax3d/tree/main/jax3d/projects/mobilenerf if you diff the three view_*.html files). They do it inside the evaluateNetwork() function in the fragment shader. In my Unity viewer, I opted to do that conversion in the vertex shader instead, where I also apply the conversion to a left handed coordinate system at the same time. This happens in the shader generation part where I'm replacing the AXIS_SWIZZLE keyword in the shader template: MobileNeRF-Unity-Viewer/Assets/Editor/MobileNeRFImporter.cs Lines 550 to 552 in 917704e Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
This negation also happens as part of the coordinate conversion the original code does based on which type of scene it is. So it's actually not just switching y-z. This can be seen if you compare the following code snippets: One is: the other is: As I've said I've opted to combine these conversions and do them in a single place, but I can see how that might have made things a bit more confusing. |
Beta Was this translation helpful? Give feedback.
-
To be more clear, the negation of z is to match the original code. |
Beta Was this translation helpful? Give feedback.
Importing the .obj file is done using Unity's standard Asset Import Pipeline, which handles loading data from .obj in the correct way. So the mesh doesn't need any manual conversion, because Unity does it for you.
In the shader I do perform some coordinate system conversion. This gets a bit messy to explain, because the original code itself flips y-and z, but only for synthetic and unbounded 360° scenes (can be seen here https://github.com/google-research/jax3d/tree/main/jax3d/projects/mobilenerf if you diff the three view_*.html files). They do it inside the evaluateNetwork() function in the fragment shader.
In my Unity viewer, I opted to do that conversion in the vertex shader instead, …