I noticed a problem in p5.js when rendering png images with soft alpha in WEBGL mode.
I'm rendering 10 images that are supposed to be "halos", made in photoshop all white with a blurred point mask, exported as PNG24.
In canvas mode this works ok and images overlap as supposed.
However in WEBGL mode I get a dark halo around the images
any ideas?
I discovered it has to do with known issues of trasparency in WebGL, and the way P5.js manages it:
https://webglfundamentals.org/webgl/lessons/webgl-and-alpha.html
In my case I managed to make it work this way:
//renderer is a p5.js renderer
var gl = renderer.GL;
// Turn off rendering to alpha
gl.colorMask(true, true, true, false);
BUT I lost canvas transparency, that would be quite useful for this project.
Related
I want to be able to overlay a semi-transparent PNG with a single colour using an arbitrary blending and keep the alpha.
I'm aware of this solution:
How to tint a transparent PNG image in iPhone?
Unfortunately, DestinationIn / SourceOut / Mask all display noticeable visual artefacts in the alpha regions. This is especially noticeable when layering graphics:
Aside from using Core Graphics, I've tried CoreImage, which does not display any artefacts in CIMultiplyCompositing, but has no corresponding filter for the other Core Graphics blend modes (such as Screen and Overlay)
I've also worked with GPUImage but encountered the same visual artefacts, although this appears to be a bug in the library.
I found and fixed the bug in GPUImage which was causing the problems. I then manually implemented all the blendings as shaders.
I've seen many questions asking how to draw transparent images, but my case is quite the opposite. I have a TPicture where I load any file type, including PNG. I then read TPicture.Graphic and call Draw directly in a TBitmap's canvas. However, when the image is drawn, it carries over the transparency of the original PNG image.
The current code is very simple, just...
MyPicture.LoadFromFile(SomeFilename);
MyBitmap.Canvas.StretchDraw(SomeRect, MyPicture.Graphic);
Now the issue is that the canvas which I'm drawing to already has an image, and this PNG is being drawn over a portion of it. When the PNG has a transparent background, normally it appears white. However, since it's directly drawing a transparent graphic to the canvas, it keeps those areas transparent.
How can I draw a PNG Graphic directly to a canvas without its original transparency while using only the canvas drawing methods? I don't want to create too many graphic objects and draw too many times, hence the reason I only have 2 lines of code above. I'm hoping there's a way I can do something like BitBlt with some special mechanism for this purpose.
The only method pre-built in Delphi XE2 has a defect and doesn't work properly. Instead, draw whitespace, or whatever background you desire, to a blank canvas. Then draw the transparent image on top.
In case you aren't drawing onto a blank canvas, you can call FillRect method of the bitmap canvas for the region you're planning to draw the png.
(i can't post images so i posted links instead)
i'm working on a 2D platform game using pixelperfect.
The problem is about the png images used in-game. On transparency, there are some blur.
like this :
http://i.stack.imgur.com/lBX3A.jpg
If i open the texture with TheGimp, this is what i get :
http://i.stack.imgur.com/pOeF4.jpg
this is a sample of my map (zoom 1600x).
As you can see there is no blur around the black. (the grey squares means transparency).
Tests i did :
save without compression and re-opened it = no blur.
to be sure, i added a white background in gimp (it's easier to see the dark blur on white) :
(http://) i.stack.imgur.com/jfhWv.jpg
of course, i removed the white background because i wanted it transparency.
last information : there is blur on every transparency png images, even on my spritesheet character. When i animate it, i can see the blur from others frames.
After my tests, i concluded that gimp isn't the problem.
Can you help me ? Thx for reading.
xna4, c#2010 express edition, gimp2.611.
Sorry about my english ^^
This happens because of "texture filtering", which xna does by default.
You probaly can disable this.
found something: https://gamedev.stackexchange.com/questions/6820/how-do-i-disable-texture-filtering-for-sprite-scaling-in-xna-4-0
I'm using the color information in the texture still when the alpha is set to 0. The PNG file is correctly saved with the color preserved. If I use the content pipeline and set it to non-premultiplied, everything works fine. Texture2D.FromStream is documented as non-premultiplied but it's wiping out the color. When debugging in PIX and looking at the texture, all pixels with 0 alpha are set to black.
Is there a way I can bypass the content pipeline and still keep my color for transparent pixels?
I'm not able to help too much just now as I don't have code in front of me but I done this a few days ago myself and it had all the correct transparency that was expected. Perhaps it's your image that has an issue? I used a PNG saved using Paint.Net.
As seen in this image http://imgur.com/Qrqqo the boat, tree trunk and ladder all have transparency which allow them to be on a second layer and the tileset itself is loaded using from stream (User generated content ftw).
So if no-one has answered this before I get to my computer with code then I'll take a look at what I have and post a sample if needed.
I am able to use PNGs that have drop shadows but the effect when displayed on the BlackBerry looks like it collapses the transparent channel down from its original smooth gradient to only several transparent values giving it a choppy look.
The same issue is encountered by drawing on the UI using BlackBerry fields or the graphics.drawBitmap method. Anyone want to share hints for getting great looking transparent effects on the BlackBerry?
Dither your images or pre-composite them. When loading an image on a BlackBerry, you get at most 4 bits of alpha data, which allows 4 bits each for RGB. So, if you want to dither your transparent images, go for RGB4444. If you don't dither them, that's what causes 8-bit alpha to just be mapped to the nearest 4-bit value.
If you include no alpha data (i.e., precomposite), you can get RGB565, which will have a better image quality overall, but you will have to deal with static positioning for your dropshadows.