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

Allow any Vector2 value as a 3D rendering scale option #52232

Closed

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Aug 29, 2021

More powerful version of #52215. Follow-up to #51870.

This allows for finer control over 3D rendering resolution, including support for anamorphic scaling (different scale factor for the horizontal and vertical axis). Anamorphic scaling can be used to make the visual impact of lowering the rendering scale less noticeable, usually by reducing the widest/talleast axis' rendering scale first.

Supersampling can also be performed by setting a 3D rendering resolution above 1.0, which is useful for offline rendering or for very high-end GPUs.

Testing project (updated for this PR): test_render_scale.zip
Use ZQSD/Space/Shift to move. Use mouse wheel up/down to change the X rendering scale, F2/F1 to change the Y rendering scale. Press X to toggle the experimental dynamic resolution scaling (it targets ~200 FPS with the frametime variables, modify Label.gd to change this).

@clayjohn
Copy link
Member

I think we need to keep it restricted to the enum for now. Otherwise users will expect to be able to dynamically resize the viewport. Which isn't supported internally right now. With this PR, new textures are allocated every time the scale is changed. This would quickly become prohibitive if a user tried to smoothly adjust the 3D rendering scale over multiple frames.

IMO before we make 3d rendering scale fully dynamic we need to allow dynamically changing rendertarget resolution without allocating new textures.

In OpenGL this can be done with glViewport and some trickery in fragment shaders. In Vulkan I think it can be done with texture views.

@Calinou
Copy link
Member Author

Calinou commented Aug 29, 2021

I think we need to keep it restricted to the enum for now. Otherwise users will expect to be able to dynamically resize the viewport.

Could we add a note in the documentation for this? The dynamic resolution in my testing project is just an experiment, although it seems to work better than it did in 3.x at least (minus the flickering sky issue). I decided to include this experiment in the testing project in case we switch to texture views in the future, but dynamic resolution isn't something I'd advise doing in production right now.

Edit: Added a note in the Viewport class documentation.

This allows for finer control over 3D rendering resolution,
including support for anamorphic scaling (different scale factor
for the horizontal and vertical axis). Anamorphic scaling can be
used to make the visual impact of lowering the rendering scale
less noticeable, usually by reducing the widest/talleast axis'
rendering scale first.

Supersampling can also be performed by setting a 3D rendering
resolution above 1.0, which is useful for offline rendering or
for very high-end GPUs.
@Calinou
Copy link
Member Author

Calinou commented Aug 30, 2021

Closing in favor of #52215 per request of @reduz. The reason is that anamorphic scaling may break things such as derivatives in subtle ways, and therefore cause user shaders to break unexpectedly. It needs deeper changes to be exposed in a safe way, which will likely have to wait a future Godot 4.x release.

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.

None yet

2 participants