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.

AppGameKit Classic Chat / A question about the transparent sprites overlapping "effect".

Author
Message
nickele upgraded
10
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Birthplace of Democracy
Posted: 28th Jan 2015 12:06
Whenever we use transparent sprites on screen, we can clearly see that the overlapping regions of the transparent sprites get an alpha value that is the "sum" (or is it average, cant be sure) of the alpha values of the individual sprites.

But what happens if we give all transparent sprites the same alpha value and we wish to maintain that same alpha value in the overlapping areas? Is there a way to achieve that in Tier 1? I included a png to roughly visualize the effect.

I searched a bit in the Internet and some answers I found state that this is a limitation of opengl. Is this true? Is there really no way/command to bypass this limitation?

Attachments

Login to view attachments
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 28th Jan 2015 13:01
I don't have AppGameKit available to test but I believe that SetSpriteTransparency could be used for this sort of thing..
I don't know which mode you need but one of them should help.

AGK V2 user - Tier 1 & 2
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th Jan 2015 13:35
Are your sprites static, relative to one another?

If they are, you could make them 100% opaque, render to an image, getImage(), then set your transparency.


I had this issue with transparency, I don't know if it is still an issue.

Quidquid latine dictum sit, altum sonatur
nickele upgraded
10
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Birthplace of Democracy
Posted: 28th Jan 2015 14:08
Unfortunately, I am considering the scenario of the sprites moving. I am experimenting with a bullet hell shooter, where some hundreds of bullets/sprites are moving on screen.

It is my intention to give these bullets an "aura" (basically, it's a sprite with an opaque inner circle area and a transparent outer circle area), but when two or more bullets overlap partially, then the overlapping area of the "bullet auras" -the transparent parts- becomes denser and almost opaque.
fog
21
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Newcastle, England
Posted: 28th Jan 2015 14:16
I've done this in the past with XNA and the same method should be easy enough in AGK.

Draw all your "opaque inner circle area" bullet sprites to a Render Image and then use a shader to add the transparent outer.

It looks great and with a shader it's easy to change the size, alpha, colour etc of the transparent area that is difficult to do if just using a sprite for it.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Jan 2015 14:43 Edited at: 28th Jan 2015 14:44
how it looks if you draw all your bullet sprites and then
the auras with additive blending (its part of agk v2 i think) over it.
means a depth (SetSpriteDepth) range for the bullets and a depth range for the aura.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
nickele upgraded
10
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Birthplace of Democracy
Posted: 28th Jan 2015 14:47
Thank you people for the answers.

I was worried that shaders would be involved somehow and now I am scared ...obviously because I know not-a-single-thing about shaders!

I couldn't help it, but while I was reading the last answer I unintentionally made a rhyme
"If you want a sprite, then you better take a hike
but if go shader, you're bad-ass like (Darth)Vader!"

Seriously now: Can you enlighten me with any good Internet resources that explore the mysterious world of shaders?

And again thank you all for your very helpful advice.
nickele upgraded
10
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Birthplace of Democracy
Posted: 28th Jan 2015 14:50
My apologies Markus, I didn't see your answer before my post.

You mean to first draw the auras as individual sprites and then draw over them the opaque bullets?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Jan 2015 15:25
mean
first draw the opaque bullets as individual sprites and then draw over the auras but with SetSpriteTransparency 2=additive blending
if it is supported yet.
this draw first and last you can handle with the depth value.
can't say if this look better or not.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
nickele upgraded
10
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Birthplace of Democracy
Posted: 28th Jan 2015 15:32
Markus: My mistake. I apologize and I thank you for your advice. I will try to see how the transparency behaves with a SetSpriteTransparency value of 2.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Jan 2015 16:42 Edited at: 28th Jan 2015 16:47
how look this?
my theory was not than i had expected.
its better to test with source code.






AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-25 17:53:27
Your offset time is: 2024-11-25 17:53:27