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 / "Correct" alpha-blending

Author
Message
Sandwich
7
Years of Service
User Offline
Joined: 23rd Sep 2017
Location:
Posted: 22nd Aug 2018 08:12
Hi again!

I searched the forum but found nothing that worked for me.

I have an object with custom shading, the shader sets alpha values between 0 and 1 for every fragment. So there are parts of the texture that are more translucent than others.
I played for hours with the commands SetObjectAlphaMask, SetObjectTransparency, SetObjectBlendModes and also with SetObjectDepthWrite.

But I cannot achieve the desired drawing mode:
The less the alpha value, the less the fragment should be drawn above the background (until it gets invisible for alpha = 0.0).

As I said, the alpha-channel is varying per pixel of the texture, so there are some pixels full translucent (=invisible), some full opaque and some between.

What I achieved with playing with the parameters is:
- Object not drawn at all
- Full Translucent parts of texture correct cropped, but some strange depth issues (only parts of object get drawn if there is another object behind it)
- Correct cropping but complete object is semi-translucent
- ...

Can someone suggest a possible correct parameter-set for this case?

Thanks in advance,
The Sandwich
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 22nd Aug 2018 09:01
It is of my understanding that if the shader is setting the transparency of the object not how you want it
then it is the shader that needs to be modified. Im not sure what you desire but if you don't want the
alpha channel to draw you might change the gl_fragcolor command to something like this gl_FragColor = vec4(color,1.0);
if color is the value used if color is already a vec4 then you might do something like gl_FragColor = vec4(color.rgb,1.0);
both commands will set full alpha if you want a more complex change you will need someone to take a look at the
shader
fubar
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Aug 2018 10:33
Can you post your shader code?
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 22nd Aug 2018 12:25
I've had his......you still need transparency set to mode 1 in agk, then it's all the shader.

So if you put gl_FragColor = vec4(red,green,blue,0.5) it should be 50% transparent. My guess is you've gone wrong with the alpha part of your gl_FragColor statement.

Login to post a reply

Server time is: 2024-11-23 17:37:17
Your offset time is: 2024-11-23 17:37:17