does GlBasic multiply alpha with images? (Blend mode issue)

Previous topic - Next topic

spacefractal

Its seen GlBasic does not load alpha infomation from png file correct and change the gray shadow very much. Its look like GlBasic MultiPly alpha info, where its should not.

And yes I have tried to set various values of ALPHAMODE as well SMOOTHSHADING without any luck.

Here is the image (Gl Basic is left, but its should look like right):


I'm are simply not sure what it happens, nor I cannot uploade a test sample, since I allready have tried all compos right (howoer I could do a later simple test app when needed).

EDIT: PS. I use ROTOZOOMSPRITE (and yes I do draw the tilemap using POLYVECTOR).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

I guess GlBasic is missing a important command from BlitzMax: SetBlend().

Code (glbasic) Select

Function SetBlend( blend )
Description Set current blend mode
Information SetBlend controls how pixels are combined with existing pixels in the back buffer when drawing commands are used in BlitzMax.
blend should be one of:

Blend mode Effect
MASKBLEND Pixels are drawn only if their alpha component is greater than .5
SOLIDBLEND Pixels overwrite existing backbuffer pixels
ALPHABLEND Pixels are alpha blended with existing backbuffer pixels
LIGHTBLEND Pixel colors are added to backbuffer pixel colors, giving a 'lighting' effect
SHADEBLEND Pixel colors are multiplied with backbuffer pixel colors, giving a 'shading' effect


Possible to add such of command like this to the next RC GlBasic update, so we can have the blend mode we want?

I guess GlBasic use MaskBlend (or SHADEBLEND), where its should been AlphaBlend mode, so the issue could been fixed.

PS. Seen its glBlendFunc() I want to use.... But not sure how to call it directly and its without break compatible.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrTAToad

I do find either -1.0 or -0.99 helps

spacefractal

I have allready tried it.

Its not a ALPHAMODE issue, but its a BLENDMODE issue, since the glbasic draw the alpha darker, while its should have draw it ligther (I used -1 here).....

Its something with OpenGL glBlendFunc(), while GLBasic use SHADEBLEND, but I want to use ALPHABLEND mode.

So I think its a INLINE call I need to use (but also make sure to have compatible with all major platforms or how to do that).

Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

erico

I guess -1 uses your ´normal´alpha mode while >0 gets additive.
PNG coming out of photoshop...single layer image with layer transparency.

spacefractal

We have tried various values and tricks in differenct way to make sure its not a PS or Paint Shop Pro issue. The graphican thinks glbasic multply when it blend it. I think its due its using SHADEBLEND instead of ALPHAMODE (I have seen that in BlitzMax too i remember, until I fixed it with SetBlend mode) and then its "darker" the ground instead "ligthing" it (ALPHAMODE 1 look like the mouse is on fire, so its completly wrong).

So its all just about a wrong BLEND mode its use, no other. ALHPAMODE command alone cannot fit it all. Its More or less just a OpenGL call to the glBlendFunc() before render it with the right value (And I is nothing how to do that).

Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

erico

try off that png with a proper alpha channel on photoshop(ie: R G B A window) then save png 32bits.
Try with a mask too or combinations, you may alto keep the background black or white or grey with these...

When we started gfx for HIT THE DECK, we ran into these and a few other troubles considering alphas and blending modes.
The first run we gave, got into the 'right' image on your example, or trouble was the opposite and a few other things.

I can´t clearly remember how we resolved the whole issue unfortunantly... :(

spacefractal

its a OFFSCREEN issue, not a png issue I just foundout. the PNG does read correctly in GLBASIC.

But when the offscreen image (screen 2) is draw to the backbuffer, then alpha is simple draw darker due CLEARSCREEN is set to black on backbuffer. If its set to white, then its works.... but then I have a white border instead of black.

I do wonder why GlBasic does that because I fully draw a bg image to the OFFSCREEN screen before I draw the picture.

So there might been a bug here?

_____

Finally fixed it by cleaning screen 2 with black instead of screen 0 (back buffer). screen 2 was cleared with transperancy, which I guess caused the issue and then it did multipled alpha to the back buffer.

So make sure clean offscreen buffer as sell, and not just on backbuffer if you see some issues like that.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/