Hello, I’ve a problem with transparent images. I’ve this code, it shows an image with transparency:
import direct.directbase.DirectStart
from direct.gui.OnscreenImage import OnscreenImage
from pandac.PandaModules import TransparencyAttrib
img = OnscreenImage( 'arrow.png' )
img.setTransparency( TransparencyAttrib.MAlpha )
run()
But what I see is:
(you can see artifacts in lower-left and upper-right corner). If I open the image with other softwares, I don’t see these artifacts. Here is the file arrow.png. How can I get rid off these artifacts? Very thanks!
You have saved your PNG in 8bit methinks. I am not sure, but try to save it in 24bit. It will give much more quality to the opacity of the image. For now, you only have Transparency or No-Transparency, and your image has blurs on the edges, which creates the artifacts (because 8bit can’t depict blurred edges). In photoshop, every tool except for the pencil leaves blurs. Try the 24bit PNG if you wanna keep the blurs or try GIF as a last resort. You can even try the pencil tool.
Thanks for the answer! I’m using Gimp, and AFAIK it uses 8 bit for each channel. But I double-checked this: I ran ImageMagick on the image and it told me that alpha channel depth was 8 bit.
I can’t: OnscreenImage doesn’t support GIF.
Yes, I thought so much about this possibility before posting, but I observed that if I opened the same file with other programs, they managed it correctly. Panda is the only (in my few tests) that produces this artifact.
Anyway, I found a “workaround”, maybe it could be useful to circumscribe the problem. If I make transparent all the pixels on the edges of the image (1-pixel stripes are sufficient), the artifact is not present. (and this second image has the same depth settings, so maybe is not a channel-depth issue)
your issue results from texture-tiling mode in compbination with texture-filterin. the GPU , by default, tiles your texture over and over again. it also filters texture to interpolate between pixels. that’s when edges bleed over. panda3d.org/manual/index.php … Wrap_Modes
setting it to “clamp” mode fixes this (usualy)
your workaround works for you right now. if you scale the model down, or someone with low screen resolution look at it it might break again due to the filtering beeing applied to more than just one pixel width.