Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Yet Another Transparency Issue

Author
Message
Avan Madisen
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: The Castle Anthrax
Posted: 1st Aug 2010 22:31
Hi Guys

It's been almost 5 years since I've been on these forums, and I notice a few people are still around from those days, maybe someone still remembers me.

Anyway, after learning C++ (that being the reason I disappeared all those years ago) I hadn't done much coding due to having a full-time job. But I recently decided to have a go at using the DGDK in what little spare time I have. But I've hit a problem and it's only been a few days since I started.

Before anyone asks, I have searched the forums for a solution, but I can't find only threads where other people have had the same problem.

Basically, the first thing I started playing with was the transparency support on images, such as .png format with an imbedded alpha channel. Using some rendering software I have I created a few images to play with but I've noticed a really bad problem.

The way that DGDK blends the colours when performing transparency works on the by blending the two colours using the alpha value, so if you're blending pure white with pure black at 50% transparency you'll get a 50% grey colour.

The problem comes from the fact that the software I use to make the images has already processed the transparency scaling on the colours before saving the image. This means that when DGDK does the blending the colours get a double hit, where 50% transparency actually ends up being only 25% of the original colour.

The attached screenshot shows what I'm talking about, the image on the left of the picutre was pasted with no transparency but the one on the right had the transparency set to '1'.

The way I need this to be processed would work by only multiplying the colour of the background with the transparency colour, rather then multiplying both colours. This would result in images being identical when pasted onto black regardless of whether transparency is used, but the method DGDK is using is causing all my images to appear darker then they should.

I appeciate that one solution would be to modify by images so that the colours are not pre-multiplied for the transparency, but this is not possible within the software I use to create the images, and considering how many images I'm likely to need for a game, modifying every single one manually would be a massive undertaking, probably a bigger job then producing the images themselves.

The only other solution I can think of is to write the 2D rendering code myself. Possible, but that kinda defeats the object of using DGDK.

Does anyone have any suggestions, or would I need to ask the dev-team to add a new feature?

I am ready to meet my maker.

Whether my maker is ready for the ordeal of meeting me is another matter.

Attachments

Login to view attachments
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 2nd Aug 2010 13:42
Quote: "The only other solution I can think of is to write the 2D rendering code myself"


You could do this by writing a simple shader, that processes the alpha channel just as you like. But this would only work if you use 3D objects (planes) to display your 2D images...
I've done this a while ago for a custom particle system.

But then if I remember right, there is another flag value to the set transparency command that controls the way the blending works (or was it just for ghost object? Don't know...) .

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 2nd Aug 2010 16:00
Make a converter app which will load in an image specified on the command line, and then will undo the transparency scaling on the image, saving it out again after.

The easiest way to modify an image is to use dbMakeMemblockFromImage and then edit the memblock.

[b]

Login to post a reply

Server time is: 2024-11-19 20:58:01
Your offset time is: 2024-11-19 20:58:01