-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Make RenderSceneData take projection correction into account #93630
Make RenderSceneData take projection correction into account #93630
Conversation
ee278a1
to
99aca6b
Compare
Just double checking, @akien-mga @AThousandShips it was |
This was exposed in 4.3 AFAIK so not even sure compatibility binds are necessary Edit: Yep, there's no |
DOH! off course! |
@kebabskal would you mind checking this out as well and see if this has any effects on your project? Yours is probably the most extensive use case of compositor effects so if we're overlooking anything, hopefully we can uncover it quickly. |
7a2d92d
to
a31e958
Compare
a31e958
to
fd8a313
Compare
@@ -41,8 +41,12 @@ Transform3D RenderSceneDataRD::get_cam_transform() const { | |||
return cam_transform; | |||
} | |||
|
|||
Projection RenderSceneDataRD::get_cam_projection() const { | |||
return cam_projection; | |||
Projection RenderSceneDataRD::get_cam_projection(bool p_flip_y) const { |
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.
Is there any way that we could detect if the RenderSceneData is being used in ReflectionProbes? I would really like to remove the p_flip_y option if we can.
For starters, it will always be false in the GLES3 version of this class. So the user shouldn't have to think about that.
Perhaps we could store whether a ReflectionProbe is being used when we create the class?
Alternatively, we could overhaul the renderer so we aren't rendering upside down. As far as I can tell there has never been a benefit to rendering upside down.
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.
Just to clue everyone else in on our discussion this morning.
Our decision for now is that for 4.3 we'll try and make the logic in RenderSceneData* automatic, I'll look into the needed changes to make this possible and update this PR.
Than for 4.4 we're going to investigate removing the flip logic all together. I'll raise a proposal with the details for this.
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.
If we could just render right side up always, in both RD and compatibility, that would be amazing! :-)
fd8a313
to
6ed6212
Compare
@@ -2562,6 +2562,7 @@ void RenderForwardClustered::_render_shadow_append(RID p_framebuffer, const Page | |||
SceneState::ShadowPass shadow_pass; | |||
|
|||
RenderSceneDataRD scene_data; | |||
scene_data.flip_y = !p_flip_y; // Q: Why is this inverted? Do we assume flip in shadow logic? |
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 something to investigate later, I'm pretty sure we've hardcoded the flip in the shaders used here,. I've left this comment here so we are reminded to do this as part of the planned flip-y clean-up (ditto on mobile renderer).
As you saw, tried it on stream and it seems to work perfectly! Thanks! |
Yup, and really cool to see using the scene data UBO directly working |
Taking the projection correction matrix into account seems to have fixed the issue completely, compositor effect shaders are behaving as expected. Can't wait for this to get merged :) |
Thanks! |
This came out of #90148 and deals with the comment made by @xcodian
We now make sure that
get_cam_projection
andget_view_projection
return corrected projections to deal both with our reverse-z and flip-y logic.This also adds logic to keep the flip_y state in our scene data object and remove passing this around as a parameter, in doing so it highlights there are a few other scenarios where we flip y.
The compatibility renderer has not been touched as it currently does not support compositor effects but has similar logic we'll look at as part of a planned cleanup in 4.4.
For testing, this is @jake-low's original MVP adjusted for master including fixing memory leakage and adjusting it for this change.
MVP-90148-corrected-v2.zip
Note:
(note, the cube was moved into the cone on purpose, was just testing if depth was correct here)