Xeethrax's picture

Alphablending linux != alphablending windows..

This image basically shows just a part of a white oval with 50% alpha, with a glow, on top of a blue-ish background, in win/linux. The results, as you can see, are quite different.

I initialize the window using only the width/height constructor, thus using default options. Is there any reason that's immediately obvious to any of you devs as to why the resultant color would be different? My code is identical on either platform.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Xeethrax's picture

Another image for clarity..

the Fiddler's picture

What video card and drivers are you using on each OS? What linux distro? As a sanity check, check the GraphicsMode property on linux and see if it is using 16bit color (it shouldn't - but you never know).

Another wild guess: make sure you are rendering objects back to front.

If you are using the open-source drivers on Linux, consider reporting a bug to mesa. The developers are very responsive and may have some insight to offer (their knowledge of 3d hardware is unparalleled). You can see if you are using the open-source drivers with GL.GetString(StringName.Vendor) (it will read "Mesa" or similar).

Xeethrax's picture

Hello again, and thanks for your reply :)

My dev machine is a laptop with ATI Radeon Mobility HD5870 with latest Catalyst drivers.
The target hardware is an EEE Box with NVidia ION GT218 GPU, using latest Ubuntu and Nvidia proprietary drivers (270.41.06).

The objects are z-sorted indeed :)

GraphicsMode.Default.ColorFormat.BitsPerPixel returns 24. Setting the GraphicsMode manually didn't make a difference either. GL.GetString(StringName.Vendor) returns "Nvidia Corporation".

This issue has persisted for a while (several months at least, probably longer), and on different target hardware as well. All target hardware is running NVidia GPUs though. This haven't been a problem of great enough magnitude to merit any attention previously, but now things have changed. I'm at a bit of a loss in regards to where I should begin troubleshooting, and all attempts so far has resulted in null. Just thought maybe it could be related to the window- / context-creation and thus was hoping you'd know what the problem was, or could be. I'd hate to have to traverse all that fine code, if it'd turn out to be a wild goose chase anyway ;)

Xeethrax's picture

So it seems I've finally figured out what's causing the issue. Apparantly the mono version of the PNG-loader premultiplies the alpha, which fits my problem quite neatly.

For those interested: Bugzilla link

Anyone happen to know of a PNG-loader for .NET or a libpng wrapper? Doesn't seem to be any (why would there be as Image.FromFile works perfectly.. in Windows, that is).

smiley80's picture

Here's a png decoder:
http://pastebin.com/xDDdfWkd

You also need the zlib part of libtiff.Net
http://bitmiracle.com/libtiff/

Usage:

using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
	using (var binaryReader = new BinaryReader(fs))
	{
		PngDecoder dec = new PngDecoder(binaryReader);
		GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, dec.wid, dec.hei, 0,
			  OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, dec.rgba);
	}
}
Xeethrax's picture

Thank you very much smiley80!

However, it seems I'm still in need of the classes PngHeader, PngPalette and PngTransparency.. I don't suppose you have those handy too? :)

smiley80's picture

Oops sorry, this should contain all necessary files:
https://sites.google.com/site/infralicht/stuff/PngDecoder.zip

Xeethrax's picture

Thank you!

I can confirm that using this PNG-loader, my issue is indeed solved.