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 Nearest Neighbor Scaling to 3D Viewport Options #859

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

therabug
Copy link

@therabug therabug commented Nov 14, 2024

This PR adds a "nearest neighbor" scaling mode to the 3D viewport, expanding the available scaling options alongside bilinear and FSR. Nearest neighbor scaling offers a simple and efficient way to scale without interpolation, ideal for pixelated or retro-styled visuals. Unlike bilinear or FSR scaling, this method preserves hard edges and pixelation, which can be useful for both performance optimization and specific aesthetic effects.

Changes Made

  1. Added Nearest Option to ViewportScaling3DMode Enum:

    • Introduced a new VIEWPORT_SCALING_3D_MODE_NEAREST option within the RS::ViewportScaling3DMode enum, allowing users to select nearest neighbor scaling for 3D viewports.
  2. Updated _configure_3d_render_buffers to Support Nearest Scaling:

    • Modified the _configure_3d_render_buffers function in renderer_viewport.cpp to support nearest scaling. When the VIEWPORT_SCALING_3D_MODE_NEAREST mode is active, the target render resolution is set based on the desired scale, and the texture storage filter is set to nearest neighbor, applying a non-interpolated scaling approach.
  3. Enabled Nearest Mode Selection in viewport_set_scaling_3d_mode:

    • Updated the viewport_set_scaling_3d_mode function to handle the new nearest scaling mode, allowing users to select it and trigger the appropriate configuration changes through _configure_3d_render_buffers.
  4. Added BIND_ENUM_CONSTANT to viewport.cpp for Nearest Scaling.

  5. Added Nearest Scaling Enum to viewport.h.

Additional Note

This new scaling mode is ideal for projects needing a retro, pixelated aesthetic or seeking optimized performance by reducing the overhead of more complex scaling methods. It provides greater flexibility and control over the appearance and performance of 3D viewport scaling.

@therabug
Copy link
Author

I can't find a way to disable bilinear. Nearest now exists but doesn't change anything? There is some "Bilinear overlay (?)" on top that I can't disable.

@SkogiB SkogiB marked this pull request as draft November 14, 2024 14:55
@SkogiB
Copy link
Contributor

SkogiB commented Nov 14, 2024

Marked this as a draft until you have it ironed out, just for clarity on our end. Appreciate looking into this

@therabug
Copy link
Author

Marked this as a draft until you have it ironed out, just for clarity on our end. Appreciate looking into this

thank you!

@therabug therabug changed the title Add Nearest Neighbor Scaling to 3D Viewport Options Add Nearest Neighbor Scaling to 3D Viewport Options [WIP] Nov 14, 2024
@therabug therabug changed the title Add Nearest Neighbor Scaling to 3D Viewport Options [WIP] Add Nearest Neighbor Scaling to 3D Viewport Options Nov 14, 2024
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.

3 participants