Skip to content
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

Add an option to preview the 3D scene as a background to the 2D editor #51817

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Aug 18, 2021

master version of #51840.

This can be used while designing a HUD to make sure it's readable on top of a 3D scene. This feature was "unintentionally" available until #50007, but exposing it as an option that's disabled by default makes more sense.

The main limitation right now is that you can't move the camera by switching to the 3D editor then going back to the 2D editor. Instead, its position will be set based on the initial camera position when the scene was opened.

This closes godotengine/godot-proposals#2635.

Preview

Note: MSAA/FXAA/debanding support for the 3D preview was added after this video was recorded. It will be synchronized with the project settings, like in the 3D editor.

2d-editor-3d-preview.mp4

Copy link
Contributor

@nathanfranke nathanfranke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM 🙂

editor/plugins/canvas_item_editor_plugin.cpp Outdated Show resolved Hide resolved
This can be used while designing a HUD to make sure it's readable
on top of a 3D scene.
@Calinou Calinou force-pushed the 2d-editor-add-3d-scene-preview-option branch from 6f023ae to d0d59d4 Compare May 25, 2022 09:03
@Calinou Calinou requested a review from a team as a code owner May 25, 2022 09:03
@Calinou
Copy link
Member Author

Calinou commented May 25, 2022

Rebased and tested again, it works as expected.

Comment on lines -2390 to -2394
bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION));

if (shrink != (subviewport_container->get_stretch_shrink() > 1)) {
subviewport_container->set_stretch_shrink(shrink ? 2 : 1);
}
Copy link
Member Author

@Calinou Calinou May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is not present in Viewport::apply_project_settings(), but it was broken and did nothing in master anyway (it still works in 3.x).

This will need to be adjusted to support reading the 3D scale project setting, and also to support an editor-only override of the resolution factor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look related to this PR. You could split it into a separate one.

@nathanfranke
Copy link
Contributor

If you have two scenes open, one with a camera and one without, using the 3d background feature on the second scene incorrectly renders from the camera in the first scene.

image


In my opinion, it makes more sense to just use the 3D viewport's camera position. Although this would require a lot of technical work (data sharing between plugins 🤢) and there's edge cases (e.g. when the 3D plugin is disabled). Probably not within the scope of these PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow previewing 2D/control nodes in 3D camera preview
4 participants