-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to mirror Camera around X-axis? #3001
Comments
This probably changes the winding of faces. Try disabling backface culling? |
Instead of mirroring inside the camera matrix, you can apply the mirror using TransformManager, in which case Filament will do the right thing. Filament auto-reverses triangle winding in this scenario (search for |
You could try to create a root transform, apply the scale on that, and parent everything else in the scene to that room transform. |
Thanks for the suggestions! Going to dive into this. |
I've looked into this and applying a scaling on the Z-axis does work now but the result looks strange; I can't really describe what's going on but maybe the material properties are wrong? Note that instead of mirroring the X axis as described above I'm mirroring on the Z axis. A: Here is an image without mirroring on the Z axis and a video. B: With mirroring on the Z axis and a video. I did another test with a test environment map to see if I could see if something obviously was wrong. C: No mirroring, and a video. D: With mirroring, and a video. I'm not entirely sure why the colors change so much, it's not something I would have expected. Any thoughts what might cause this? |
Looks like the normals are pointing the wrong way. |
Thanks, the normals seem wrong indeed. Am I doing something wrong when applying the transformation mabye: void FilaNode::testTransform() {
// Get instance and create mirror matrix.
filament::TransformManager& tm = ctx->getEngineRef().getTransformManager();
filament::TransformManager::Instance ti = tm.getInstance(fila_entity);
filament::math::mat4f scale;
scale[2][2] = -1;
/* Apply */
const filament::math::mat4f curr_mat = tm.getTransform(ti);
tm.setTransform(ti, scale * curr_mat);
} A. Rendering the |
The glTF spec merely says this:
However it seems reasonable that we should flip shading normals and do what Blender does. It might be interesting to check behavior in other renderers like Three, Babylon, Unity, and Unreal. Note to self: our reverse winding feature was added in #1654 I've also filed a bug against the glTF sample repo since this isn't a covered situation. |
Is there any progress on this? Thanks in advance, |
I'll take a look. It would be helpful to have a sample model that provokes the issue without any programmatic changes, since this would allow us to try it out on other popular viewers. |
This model might be interesting: |
I've reproduced this. Steve's method is the easiest way, or hacking the scale in the first node in the BusterDrone glTF. I'm still thinking about the best way to fix it for all cases (e.g. with and without provided tangents, clear coat normal, etc). |
This was tested by replacing the node 0 scale in BusterDrone with [-1, 1, 1]. Fixes #3001.
This was tested by replacing the node 0 scale in BusterDrone with [-1, 1, 1]. Fixes #3001.
This was tested by replacing the node 0 scale in BusterDrone with [-1, 1, 1]. For future reference, commit f728776 shows when we switched from transpose(inverse()) to cof(). This was a good change, but before that particular change, we had a "two wrongs made a right" situation for mirrored normals. Fixes #3001.
This was tested by replacing the node 0 scale in BusterDrone with [-1, 1, 1]. For future reference, commit f728776 shows when we switched from transpose(inverse()) to cof(). This was a good change, but before that particular change, we had a "two wrongs made a right" situation for mirrored normals. Fixes #3001.
This was tested by replacing the node 0 scale in BusterDrone with [-1, 1, 1]. For future reference, commit f728776 shows when we switched from transpose(inverse()) to cof(). This was a good change, but before that particular change, we had a "two wrongs made a right" situation for mirrored normals. Fixes #3001.
This was tested by replacing the node 0 scale in BusterDrone with [-1, 1, 1]. For future reference, commit f728776 shows when we switched from transpose(inverse()) to cof(). This was a good change, but before that particular change, we had a "two wrongs made a right" situation for mirrored normals. Fixes #3001.
I have download release 1.9.3 and it works great with our models, so I just wanted to thanks for fixing this issue so promptly. |
I want to mirror my scene around the X-axis so I tried to flip the X-axis by setting the X scale of my camera matrix to -1 but this results in a pure black scene. I'm trying to get the same behavior as in Blender. For example, consider this scene where I've set the X scaling to -1 of the default camera. When viewing through the default viewport camera you see the normal scene (w/o the X-mirroring).
Then, when I look through the camera with the -1 X scaling, I get:
When I render my scene without the negative X scaling it renders fine.
Is there an obvious answer to why this doesn't work in Filament? I've got an idea what might cause this in my engine, but before I dive into that I was wondering if there is a simple explanation why this might be an issue with Filament.
The text was updated successfully, but these errors were encountered: