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

Clamp textures with alpha to transparent color #21549

Closed
wants to merge 2 commits into from

Conversation

sarbes
Copy link
Member

@sarbes sarbes commented Jun 13, 2022

Description

On OpenGL, textures are usually clamped to the edge. If a texture has no white space around and the texture is not sampled in a "pixel perfect" manner, outside texels in the clamped portion have some influence on the pixel.

Motivation and context

This PR changes the clamping behavior to GL_CLAMP_TO_BORDER on systems which support it.

How has this been tested?

The OpenGL part looks fine. I would like to get some feedback for GLES.

What is the effect on users?

Better behaving textures containing an alpha layer without white space.

Screenshots (if appropriate):

The texture (zoomed in). Note that three sides of the circle are touching the border:
source

The affected regions are marked in red (zoomed in):
affected-regions

Before the patch:
before

After the patch:
after

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@sarbes
Copy link
Member Author

sarbes commented Jun 13, 2022

Obviously, one could debate about this being an issue of the asset. But we don't have GUI elements which rely on the edge clamping behavior, so it should be fine to do.

@sarbes sarbes added the Type: Improvement non-breaking change which improves existing functionality label Jun 13, 2022
@sarbes
Copy link
Member Author

sarbes commented Jun 13, 2022

Another try. TVOS was not defining the parameters, so I've added that. If the platform does not support it, it shouldn't get past the extension check.

Or should I ifdef TVOS out?

@jenkins4kodi
Copy link
Contributor

I've made some formatting changes to meet the current code style. The diffs are available in the following links:

For more information please see our current code style guidelines.

@sarbes
Copy link
Member Author

sarbes commented Jun 17, 2022

After thinking about it a bit more, this approach is not viable, as edge clamping might be desired in case of gradients or other effects.

The easiest way to fix this would be on content level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: GUI rendering Type: Improvement non-breaking change which improves existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants