-
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
Fixed Matrix Multiplication Shaders #12349
base: main
Are you sure you want to change the base?
Fixed Matrix Multiplication Shaders #12349
Conversation
Thank you for the pull request, @GGajanan1! Welcome to the Cesium community! In order for us to review your PR, please complete the following steps:
Review Pull Request Guidelines to make sure your PR gets accepted quickly. |
|
Thanks @GGajanan1! I can confirm we have a CLA on file for you now. |
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.
Thanks for the changes so far @GGajanan1!
I think there are a few other places where this update is needed as well:
DepthPlaneVS.glsl
EllipsoidVS.glsl
GlobeVS.glsl
modelToWindowCoordinates.glsl
Thanks @GGajanan1!
|
Also added my name in CONTRIBUTORS.md |
Perfect, thanks @GGajanan1! We typically don't assign issues except for our own internal issue on the Cesium team. |
@jjhembd I think this is all correct, but could you please take a pass to confirm these updates are valid? Please go ahead and merge if happy. |
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.
@GGajanan1 thanks a lot for this work!
I'm still testing on my end to verify the rendering result. Meanwhile, I have one comment about a typo in MultifrustumSpec
below.
I have added the changes |
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.
Hi @GGajanan1, thanks for the update!
I looked through a little more closely, and noticed a few things in the code. Once these are fixed, I can run the rendering tests to confirm.
@@ -30,7 +30,8 @@ | |||
*/ | |||
vec4 czm_modelToWindowCoordinates(vec4 position) | |||
{ | |||
vec4 q = czm_modelViewProjection * position; // clip coordinates | |||
vec4 positionEC = czm_modelView * position; | |||
q = czm_projection * positionEC; |
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.
q
was not declared. The first use of it should include the type:
vec4 q = ...
@@ -5,6 +5,8 @@ out vec4 positionEC; | |||
void main() | |||
{ | |||
positionEC = czm_modelView * position; | |||
vec4 positionEC = czm_modelView * position; | |||
gl_Position = czm_projection * positionEC; |
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.
I don't think we need this change. Now we are redeclaring positionEC
, and defining gl_Position
twice.
@@ -13,8 +13,8 @@ void main() | |||
vec4 p = vec4(u_radii * position, 1.0); | |||
|
|||
v_positionEC = (czm_modelView * p).xyz; // position in eye coordinates | |||
gl_Position = czm_modelViewProjection * p; // position in clip coordinates | |||
|
|||
vec4 positionEC = czm_modelView * position; |
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.
This change is now multiplying by czm_modelView
twice, which will affect performance. We could do the multiplication once, then re-use the result for the vec3
variable.
vec4 pEC = czm_modelView * p;
v_positionEC = pEC.xyz;
gl_Position = czm_modelViewProjection * p; // position in clip coordinates | ||
|
||
vec4 positionEC = czm_modelView * position; | ||
gl_Position = czm_projection * positionEC; |
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.
positionEC
is not the same as p
, so this is changing the result.
With the change from the previous comment, this line could be:
gl_Position = czm_projection * pEC;
@@ -114,7 +114,8 @@ vec4 getPositionMorphingMode(vec3 position, float height, vec2 textureCoordinate | |||
float yPositionFraction = get2DYPositionFraction(textureCoordinates); | |||
vec4 position2DWC = vec4(height, mix(u_tileRectangle.st, u_tileRectangle.pq, vec2(textureCoordinates.x, yPositionFraction)), 1.0); | |||
vec4 morphPosition = czm_columbusViewMorph(position2DWC, vec4(position3DWC, 1.0), czm_morphTime); | |||
return czm_modelViewProjection * morphPosition; | |||
vec4 positionEC = czm_modelView * position; |
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.
This is significantly changing the output. For a consistent result, this could be:
vec4 positionEC = czm_modelView * morphPosition;
However, we may want to avoid using the positionEC
name for modified positions, because that name has a very specific meaning in most of the rest of the code.
@@ -237,7 +237,11 @@ describe( | |||
vs += "in vec4 position;"; | |||
vs += "void main()"; | |||
vs += "{"; | |||
vs += " gl_Position = czm_modelViewProjection * position;"; | |||
vs = ` | |||
gl_Position = czm_modelViewProjection * position; |
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.
I think this is a copy-pasting error. gl_Position
is now defined twice.
Description
Fixed Matrix Multiplication in shaders
fixes #4250
Issue number and link
Testing plan
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change