Author Topic: ALPHAMODE error with values 0.1 to 0.14 ? Glitch on ZOOMSPRITE +other  (Read 3384 times)

Offline AndyH

  • Dr. Type
  • ****
  • Posts: 383
    • View Profile
    • http://www.ovine.net/
I think I have found a bug with the ALPHAMODE command and also an issue with ZOOMSPRITE, tested in Vista, I have the latest graphics card drivers which I believe has updated the OpenGL support to work correctly.


FIRST PROBLEM

Code: (glbasic) [Select]
SETSCREEN 320,240,0
LIMITFPS 60

LOADBMP "gpxsplash.png"
SYSTEMPOINTER TRUE

LOADSPRITE "test.png", 0

GLOBAL ang = 0
GLOBAL size = 1
GLOBAL alp = -1.0

WHILE TRUE

LOCAL mx,my,a,b
MOUSESTATE mx,my,a,b

alp = (mx/160)-1
PRINT "Alpha setting: "+ INTEGER(alp*100), 4,4

ALPHAMODE alp
ROTOZOOMSPRITE 0, 120,120, -ang+45, size

ALPHAMODE 0

INC ang,0.2
size = SIN(ang)*1.5

SHOWSCREEN
WEND
Images required:




Move the mouse left and right and you will see the alpha value go from -100 to +99 ... I've *100 and displayed as an integer to make it easier to read.

This value is used as the parameter for ALPHAMODE.  Note that the sprite will flick on to normal display mode when this =0.

I'm not sure I understand what it is I am seeing with this command.

* At -1.0 I see the sprite as normal - as if ALPHAMODE is 0.  All pixels displayed normally.
* between -0.15 and -1.0 it goes from semi-transparent with a darkness to normal full colour pixels.  Shouldn't it be going to darker nearer to -1.0?
* between -0.14 and +0.14 I get no image drawn at all.
* between 0.15 and 1.0 it looks like an additive blend, although there's very little difference above (about) 0.6 to 1.0 that I can tell anyway.

Should it be working this way or is it a bug?  


SECOND PROBLEM
The test.png image when scaled up with ROTOZOOMSPRITE is showing a thin black line on the rightmost edge.


THIRD PROBLEM
Am I correct in saying values passed to ALPHAMODE of <0 being subtractive blends and values >0 being additive blends?  As described in the First Problem I'm not sure I am seeing this.  Assuming it is a bug which can be fixed, we therefore have additive and subtractive blend modes but what about just semi-transparency levels (no additive or subtractive blends applied)?

BlitzMax has a command called SetAlpha taking a value 0.0 to 1.0 to specify the alpha blend ratio and a separate command called SetBlend to change the type of blending it will do.  It takes values of ALPHABLEND (missing in GLB?), LIGHTBLEND (values of >0 in GLB) and SHADEBLEND (values of <0 in GLB).  For information it also takes SOLIDBLEND and MASKBLEND to tell it to use or ignore the transparent color.

So you first choose what type of drawing mode you want with SetBlend, then you choose what ratio to display at using that blend with the SetAlpha command.  

Could we have a command in GLB to allow us to do similar functionality as seen in MAX?

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2702
    • View Profile
I don't know if its related, but if you examine the image I posted on this thread...

http://www.glbasic.com/forum/viewtopic.php?id=1404

...and display it in GLBasic (even before the GRABSPRITE alpha bug), it seems to have lost the lower alpha values (The smooth bar colour transition is now gone, lower alpha detail has been lost)? Display the same image in GLBasic and compare it to you browser image to see the difference.

Gernot is still on vacation, so if its a bug, it may need to wait for his attention.
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline AndyH

  • Dr. Type
  • ****
  • Posts: 383
    • View Profile
    • http://www.ovine.net/
Ah yes.  If I use your image with my code the parts that have a high transparency do not get drawn at all, and as you move the mouse form left to right of the window, various parts get wiped out.  Including the text.

Is that what you see bigsofty?  It's not what I'd expect to see, so hopefully Gernot can fix when he's back.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10760
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Prog1:
* At -1.0 I see the sprite as normal - as if ALPHAMODE is 0.  All pixels displayed normally.
* between -0.15 and -1.0 it goes from semi-transparent with a darkness to normal full colour pixels.  Shouldn't it be going to darker nearer to -1.0?
Negative means blending from background (-0.001) to your image (-1.0) linear. Seems OK.

* between -0.14 and +0.14 I get no image drawn at all.
Oh dear. It's a bug. I lited this up to 0.05. If I set it to 0, then grabbed images might have an ugly border where they should be transparent.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10760
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Problem 2:
Fixed in next update.

Problem 3:
Can you give an example of what is what?