-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix the transformation of plane's normal #9110
Conversation
Thanks for the pull request @baothientran!
Reviewers, don't forget to make sure that:
|
It is weird that |
Source/Scene/Model.js
Outdated
@@ -4799,13 +4818,15 @@ function modifyShaderForClippingPlanes( | |||
shader += | |||
"uniform highp sampler2D gltf_clippingPlanes; \n" + | |||
"uniform mat4 gltf_clippingPlanesMatrix; \n" + | |||
"uniform mat4 gltf_normalClippingPlanesMatrix; \n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The normal matrix should probably be a Matrix3
everywhere. This keeps it consistent with czm_normal
which is also a Matrix3
.
@baothientran only one suggestion here (which is small but affects a lot of files). I tested non-uniform models and point clouds and it works well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are doing inverse transpose in a lot of different areas now, it could be useful to move that into the Matrix3
and Matrix4
files and add a couple unit tests, similar to what you did in PlaneSpec.js
.
Also, I know @lilleyse suggested using Matrix3
but I feel like Matrix4
makes more sense. For clipping planes, we would no longer need to pass an additional u_normalClippingPlanesMatrix
. Instead, we just pass u_clippingPlanesMatrix
which has the inverse transpose built in. Then czm_transformPlane
becomes more simple and we can do return transform * clippingPlane;
(if my understanding of https://stackoverflow.com/questions/7685495/transforming-a-3d-plane-using-a-4x4-matrix is correct). This would also remove the need for calcNormalClippingPlanesMatrix
functions, since the inverse transpose will happen as part of calcClippingPlanesMatrix
. Unless I'm overlooking something I think this will make the code change in this PR a lot smaller.
Thoughts @baothientran @lilleyse ?
@IanLilleyT it is indeed a lot simpler to do |
@IanLilleyT there is a little complication. It seems like |
@IanLilleyT I close this and open another PR #9135 instead. The approaches between two PR are quite difference, so it may be better to start a new one to prevent accidental changes |
Fixes #9109
This PR will convert the transformation matrix to a normal matrix before multiplying with the plane's normal. Most of the fix happens in glsl
czm_transformPlane()
function andCesium.Plane.transform()
@lilleyse Can you please take a look at it?