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

[3.x] Allow rendering of 3d content at lower resolution #74935

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

Ansraer
Copy link
Contributor

@Ansraer Ansraer commented Mar 15, 2023

This makes it possible to dynamically adjust the rendering resolution of 3D content. 2D content and UI stuff are still rendered at full resolution.

The user can adjust the target resolution with the Rendering/Quality/3D/Lower Resolution project setting.

The editor displaying a scene at 1/4 the resolution
image


This PR was sponsored by Ramatak with 💚

@Ansraer Ansraer requested a review from a team as a code owner March 15, 2023 09:47
@Ansraer Ansraer requested a review from a team as a code owner March 15, 2023 10:18
@YuriSizov YuriSizov added this to the 3.x milestone Mar 15, 2023
@fire
Copy link
Member

fire commented Mar 15, 2023

This is useful for mobile devices that require more performance.

@Calinou
Copy link
Member

Calinou commented Mar 17, 2023

Great work 🙂

Some comments (most of this can be done for future PRs):

  • I suggest renaming the option to Rendering > Quality > 3D > Resolution Scale to be more consistent with how it's named in 4.x.

  • If it works correctly, please allow resolution scales up to 2.0 to be used for supersampling like in 4.x. This provides SSAA which is demanding, but is effective on specular aliasing (there's no TAA in 3.x).

    • Resolution scales above 1.0 should force the use of bilinear filtering, as nearest-neighbor filtering will negate the benefits of supersampling.
  • Consider adding a project setting to toggle between nearest-neighbor and bilinear filtering, as nearest-neighbor filtering is noticeably sharper. Pixels will have even scaling if using a scale factor of 0.25, 0.333 or 0.5. See also this proposal which is specifically about 4.x.

  • The 3D editor's Half Resolution option can be adjusted to use this instead of relying viewport shrinking. This will fix several issues related to mouse coordinates when that option is enabled. This would supersede Fix GridMap cursor position when using half-resolution rendering #33940 in a way that works with multiple viewports (and also Rework how the 3D editor viewport's resolution scale is changed #45269).

  • For 3.6, we should consider decreasing the default 3D rendering resolution on mobile platforms using a mobile override in new projects: Tweak default environment and graphics settings in new Godot 3.6 projects godot-proposals#4834

@clayjohn
Copy link
Member

I have a feeling that this should be exposed on a per-viewport basis as it is in 4.0. Doing viewport within viewport is pretty common for things like screens and gun scopes. Users will need the option to render at their selected resolution for the inner Viewports or else it will be very difficult to manage

@Ansraer
Copy link
Contributor Author

Ansraer commented Mar 22, 2023

Updated the PR. The settings option has been renamed and an additional option for the filter mode has been added.

I also added overwrites for specific viewports to the Viewport Node:

image

If it works correctly, please allow resolution scales up to 2.0 to be used for supersampling like in 4.x. This provides SSAA which is demanding, but is effective on specular aliasing (there's no TAA in 3.x).

This won't be possible with my current code. At Ramatak our goal is to dynamically change the resolution while the game is running, so this PR doesn't actually change the size of the render buffer (buffer allocations are expensive).

@Calinou
Copy link
Member

Calinou commented Mar 22, 2023

This won't be possible with my current code. At Ramatak our goal is to dynamically change the resolution while the game is running, so this PR doesn't actually change the size of the render buffer (buffer allocations are expensive).

I see. We should try to support this use case in 4.x as well, likely by adding a separate scaling_3d_dynamic_scale that scales the viewport rendering without touching the actual render buffer size (with scaling_3d_dynamic_scale being adjustable without recreating render buffers if below scaling_3d_scale).

This way, we'd still support the current approach for resolution scaling in 4.x. This is faster when you don't need dynamic resolution, or when it never goes past 0.8 or so – which is common on mobile and consoles.

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

I think this should work more like it does in 4.0. Primarily in 2 ways:

  1. The upscaling should happen at the time you copy the 3D buffers into the 2D buffer i.e. during the final post-process pass, not before post processing occurs. The reason is twofold 1) performance, you avoid a couple full screen copies and you can avoid doing Glow, auto-exposure, DoF at full res 2) quality, things like glow and DoF will build on the upscaling artifacts, plus they are low frequency effects so they will suffer from upscaling artifacts less.

Also, since you are doing a full screen blit anyway, you should have no problem supporting MSAA. When rendering at a lower resolution AA becomes much more important as the upscaling will make AA artifacts even worse.

[b]Note:[/b] This changes the width and the height of the 3D resolution. So if you set this setting to 0.5 you only render 1/4 the pixels.
</member>
<member name="rendering/quality/3d/resolution_scale_filter_method" type="int" setter="" getter="" default="1">
The fitlering method that is used when upscaling the 3D image.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The fitlering method that is used when upscaling the 3D image.
The filtering method that is used when upscaling the 3D image.

This changes how the rendered image is filtered when it is upscaled. This defaults to whatever has been configured in the project settings.
</member>
<member name="resolution_scale_mix" type="bool" setter="set_resolution_scale_mix" getter="get_resolution_scale_mix" default="true">
If this is enabled the viewport specific scale factor is multiplied with the global scale factor that has been set in the project settings. If this is disabled the viewport scale overrides the global one for this viewport.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If this is enabled the viewport specific scale factor is multiplied with the global scale factor that has been set in the project settings. If this is disabled the viewport scale overrides the global one for this viewport.
If this is enabled, the viewport specific scale factor is multiplied with the global scale factor that has been set in the project settings. If this is disabled the viewport scale overrides the global one for this viewport.

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.

5 participants