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 / alpha channel of a 3D shader ?

Author
Message
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 18th Jul 2019 18:46 Edited at: 18th Jul 2019 18:47
Has anyone got the alpha channel working with a 3D Shader

I can set the colours of a 3D shader like below and fake a transparency effect
but ideally ide like to just adjust the alpha of an object based on a given world
coordinate (height)
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 18th Jul 2019 20:53
You're very close to what you need... all you have to do is remember that the Shader ONLY has the information you pass into it, so if you want the World Height; this can't be calculated within the Shader.
Remember that you're objects are ALWAYS World Coordinates 0,0,0 with an Offset … i.e. Relative, if you want Absolute Information then you need to transfer that in.

Which actually is quite easy to do... as remember we're talking about Relative Position, all you need is thus the Object Offset in World Coordinates that are then applied to the Relative Values.
So, just pass in the Object Position in (AGK) World Space … then Add said Input Value to your current "Faked" approach.
Does that make sense?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 18th Jul 2019 23:47 Edited at: 28th Jul 2019 02:54
thanks raven
Do you know if its possible to actually set the alpha channel and get it to set transparency
of an object using this method.

ie the video below sets object visibity on and off based on a height of player ideally id like it
to work on objects gradually ie half an object full opaque half full transparent

EDIT video removed for space please see latest post
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 19th Jul 2019 00:01 Edited at: 19th Jul 2019 00:03
try changing:

gl_FragColor = vec4(color,1.0);

to

colorA += vec4(color, 1.0);
gl_FragColor = colorA;

Remember that the 1.0 in the vec4( ) constructor is for the .w term (or .a in the case of a colour) and thus is your Alpha Output.
I'm not sure (although I think it's automatically handled in AGK) if you also need to 'Set Blend Mode' to Multiply-Add but if you were using DBP you would as otherwise it ignores Alpha.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 19th Jul 2019 00:13 Edited at: 28th Jul 2019 02:54
thanks raven I modified the code a bit and think I have it now



EDITED nope still not quite there I don't think I can use posvarying like this
EDIT video removed for space please see latest post


anyone got any ideas ?
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 19th Jul 2019 02:52 Edited at: 28th Jul 2019 02:53
setting the blendmodes of the object I get this
EDIT video removed for space please see latest post
if agk didn't change the colour of the objects on the same level I could work with it

mythoughts
it might be the way i calculate posVarying in the vs shader as it depends on camera and i dont want it to
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 19th Jul 2019 09:41 Edited at: 19th Jul 2019 10:26
Not sure if this is the result you are looking for:


Explain a bit and we can maybe work out a fancy effect for what you are trying ?

[Edit] Ops didn't update the site an now there are 4 more posts
in one of your videos you can see mixed front and back objects thats because objects set with SetObjectTransparency have SetObjectDepthWrite disabled by default, lets see how it looks if you turn it on.
Alse if you don't need a transparent gradient use SetObjectAlphaMask it doesn't have problems with depth ordering.[Edit]
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 19th Jul 2019 14:54 Edited at: 28th Jul 2019 02:53
Thanks janbo
SetDepthwrite() fixed most the problems

The main thing now is the stairs disappear at the top of them but move a bit and they are visible
not sure that might have something to do with my positioning calling shader or possibly use different
settings for the stairs (mind you they started off as escalators lol)

but I really am after a way of making the current player floor level more visible than the above and
below ones. Im not sure if I want it like the video below or the other floors totally non existant
EDIT video removed for space please see latest post

the shader currently looks like

and models setup like



I added full source to git hub here https://github.com/fubarpk/Macroaction
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 19th Jul 2019 18:55 Edited at: 19th Jul 2019 19:08
Still, the depth is the problem.
Hm if you have got the shader pack you could use the see through shader or clipping shader for this...or maybe just an outline if you are behind things.
There are so many ways to keep control of the player in such a situation.

[Edit]I tried your game and I would like to help you out a bit.
But first of why is everything transparent and has wired ghost like effects ? Thats not from the revealing shader effect thing, right ?
for example... the "enemys" work perfectly...bzw you can build on that
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 19th Jul 2019 21:39 Edited at: 19th Jul 2019 21:44
Thanks janbo I have the shader pack but the outline transparency thing did strange things
it never worked well with the floors. I gave all objects transparency to set the shader thing
but the load scene originally only planned transparent floors

if you comment out the the bits that set up the objects in main and leave the pathpoint bits


and



and remove any shader commands
thats how the original worked

the stairs a bit touch ive been playing with them a bit but I can fix that later

in main you will notice this bit which uses object visibility to turn objects on as you head up stairs



any help is greatly appreciated I wanted to make it kind of a sideways scroller like elevator action
but following an idea I had a very long time ago where you are inside a Microsoft building. The plan
being destroy the workers and the boss being bill gates at the top that's the funny boss you should
see on the ground floor in the middle atm

The scene is created in blender as a group object and exported with a scene editor which modifications
has been made to add pathways and pathpoints. but that is something that blink shared and has had
some mods to it so will have to get blinks permission first if for some reason you need to reposition
objects as that all has to be in the exported files and made to the map file
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 21st Jul 2019 01:08 Edited at: 10th Jul 2020 03:44
The following shader changes with an example ready to run

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk

Login to post a reply

Server time is: 2024-11-22 15:58:39
Your offset time is: 2024-11-22 15:58:39