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
Rendering artifact with scaled textures #5261
Comments
I think it is the same kind of issue that beginner have when scaling down/up image with opacity. The opacity layer is also stretched, and leads to issue with transparency; |
I don't have much time to try solving this, but maybe ask on any OpenGL forum, they may help. Also you can use a tool like apitrace to see the order of GL operations. |
Thanks for testing - I'm just reporting, no rush in my end. Seems like this is because Kivy uses post-multiplied alpha. Changing to pre-multiplied reduces the artifact (mine, yours w/premultiplication of pngs), but of course it breaks everything else. Unfortunately I don't know if this this is even the expected result -- is it possible that a separate issue is preventing it from being completely sharp? diff --git a/kivy/graphics/instructions.pyx b/kivy/graphics/instructions.pyx
index 0e1c77c6..9549641b 100644
--- a/kivy/graphics/instructions.pyx
+++ b/kivy/graphics/instructions.pyx
@@ -33,8 +33,9 @@ cdef void reset_gl_context():
cgl.glEnable(GL_BLEND)
cgl.glDisable(GL_DEPTH_TEST)
cgl.glEnable(GL_STENCIL_TEST)
- cgl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
- cgl.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE)
+ cgl.glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)
+ cgl.glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA,
+ GL_ONE, GL_ONE_MINUS_SRC_ALPHA)
cgl.glActiveTexture(GL_TEXTURE0)
cgl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1) It may be possible to add env/config option so advanced users can bake their assets accordingly... but it needs more work than an "if" here. Eric Haines has a good article on the subject: http://www.realtimerendering.com/blog/gpus-prefer-premultiplication/ |
Versions
Description
A rendering artifact appears when image textures are scaled. This test case is two 100x100 PNGs, when overlaid they align to fill the 100x100 pixels exactly (top/bottom half transparent). This works as expected when not scaling, but with scaling there is an unexpected artifact.
Code and Logs
The below examples reproduce the issue on my systems using different approaches.
Example 1
Example 2
This is correct on load, not when scaled
Example 3
This is correct on load, not when scaled
The text was updated successfully, but these errors were encountered: