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.

DarkBASIC Professional Discussion / Fading limb? Alpha shader?

Author
Message
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 23rd Sep 2011 20:13
So I've been going through dozens of these threads, but haven't found a solution yet.
So I want to fade a limb like set alpha mapping on does, how can I achieve such simple task?

I've also googled for transparency/alpha shader, but I haven't found such yet. Just a shader that makes object 0 to 100% see-through.
I could just separate them to objects, but seems troublesome just for fan low to high speed(3D fan blades to 2D image) translation.

I'm 100% sure there is alpha shader, and DarkBASIC itself probably uses it for alpha mapping.

Sorry for bringing this up again...
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 24th Sep 2011 12:37 Edited at: 24th Sep 2011 12:37
Quote: "I've also googled for transparency/alpha shader, but I haven't found such yet. Just a shader that makes object 0 to 100% see-through."


Doesn't that fix your problem then?

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 24th Sep 2011 13:04 Edited at: 24th Sep 2011 13:04
But there I haven't found such shader as I said, nor I can code them.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 24th Sep 2011 16:12
"Set Object Alpha" I've used lots of times...

Warning! May contain Nuts!
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 24th Sep 2011 17:10
But set limb alpha doesn't seem to work for me. Around 80% it dissapears or apperas, there is no translation.
I don't think that it's even a DB command, it isn't in the command list nor has help file.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 24th Sep 2011 17:17
Probably the only way then is to separate the part you need to fade as an individual object. It would be useful if all object commands would work on limbs too.

Warning! May contain Nuts!
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 24th Sep 2011 17:32
I thought of that in the first post also:
Quote: "I could just separate them to objects, but seems troublesome just for fan low to high speed(3D fan blades to 2D image) translation."

But I'm sure that there is a transparency shader that could be easily set to limb.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 24th Sep 2011 18:20
We can use a plug-in to do that. You'll find it here:


http://forum.thegamecreators.com/?m=forum_view&t=81750&b=18


Cheers.

I'm not a grumpy grandpa
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 24th Sep 2011 19:10
Well, that is what I tried because there is no set limb alpha in DB
Quote: "But set limb alpha doesn't seem to work for me. Around 80% it dissapears or apperas, there is no translation."

I noticed that this happens because I use set object transparency. Without transparency it fades, but I need the transparency.

Only thing I would need is a alpha shader. If there is none, I will just separate the objects.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Sep 2011 23:02 Edited at: 25th Sep 2011 01:12
IIRC, that plug-in already uses a shader to produce its effect.

Anyhow, here's a short example I've thrown together ... I haven't touched shaders in far too long

limb alpha.fx:


limb alpha.dba:


[edit]
Minor change to shader to use defined constants instead of numbers on SrcBlend and DestBlend for readability.

And another to remove unnecessary operations, plus minor improvement to the demo code (background object).

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 25th Sep 2011 00:21
IanM

Thanks

Cheers.

I'm not a grumpy grandpa
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 25th Sep 2011 12:45 Edited at: 25th Sep 2011 12:48
Thanks, but it seems like it has the same disadvatages as the limb alpha plugin does.
Try to set object transparency 1,4
You'll see that it gradually fades, but then suddenly dissappears around 80%.
This doesn't happen with (1,2,3,5) transparency modes, just the 4(which I have to use unfortunately).

But there is also this problem with all transparency modes:

It will do alpha mask that makes the object see-through behind it also, until the final 0.

Seems it isn't so simple after all, I guess it's way more easy to just separate the objects, especially when it's about as meaningless as fan blade translation.
I think other people will run into this problem with more important uses though, so it's good that you wrote the shader so users with knowledge can fiddle with that.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Sep 2011 13:24
Well when the help for SET OBJECT TRANSPARENCY reads 'only render beyond 0x000000CF alpha values' for that mode, what do you expect?

Quote: "Seems it isn't so simple after all"

Yes it is, when we're given the full information.

So when rendering the limb being affected, do you want that cutoff:
- maintained (obviously not, but I have to ask for completeness)
- scaled with the alpha level you set
- eliminated altogether

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 25th Sep 2011 13:25
Quote: "You'll see that it gradually fades, but then suddenly dissappears around 80%."


What dissapears, your object mesh or your object texture ?. Are you using image with alpha channel?


Cheers.

I'm not a grumpy grandpa
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Sep 2011 14:10
Actually, I withdraw the 'simple' part - it looks like you can't enable both alpha-blending and alpha-testing at the same time within the shader states (or at least, I can't). You would need to carry out this testing at the pixel shader level.

The thing to know here is that transparency mode 4 isn't actually a true transparency mode - a pixel is either rendered in full, or it isn't, and this depends on the alpha of the pixel being rendered. Transparency mode 4 just determines visibility, not the level of visibility.

TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 25th Sep 2011 17:27
Quote: "So when rendering the limb being affected, do you want that cutoff:
- maintained (obviously not, but I have to ask for completeness)
- scaled with the alpha level you set
- eliminated altogether"

I didn't get what you meant by the cutoff thing, I don't really know how rendering stuff works internally at all.
This is what I'm after:

I used separate objects and it works like 1,2,3.

Quote: "What dissapears, your object mesh or your object texture ?. Are you using image with alpha channel?
"

The limb which I'm trying to fade. In this case, the fan blades.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Sep 2011 17:50
I'll try to explain again.

The SET OBJECT TRANSPARENCY for mode 4 is not a real transparency. It basically says 'if the alpha level for a pixel is below 'x', then don't render that pixel' - the default level for transparency is 207 (or 0xCF in hex).

So when any of your pixel alpha values drop below that value, those pixels are no longer rendered. Hence when your alpha drops below that value on what were full-alpha pixels, they are no longer rendered.

This will happen even if you separate out the limb into its own object, as long as you continue to use transparency mode 4.

Your choices are:
1. Pick another transparency mode that does NOT have this test of alpha levels.
2. Write a pixel shader to do the testing for you, but have the level of that test scaled to your specified level.

In fact, you can keep the mode-4 transparency on the object and set the limbs transparency to the equivalent of mode-1, by adding the following line to the shader pass:


TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 25th Sep 2011 19:00 Edited at: 25th Sep 2011 19:02
Oh yes I get it now. I knew that "So when any of your pixel alpha values drop below that value, those pixels are no longer rendered" for image alpha channels, but I didn't know it realates to this.

If I separate the objects, I don't have to use the transparency mode 4.

AlphaTestEnable=FALSE; Does indeed seem to solve the problem.

I decided just to separate the objects because my lack of knowledge about this shader stuff. Works perfect with separate objects.

Thanks for the info and help though!

Login to post a reply

Server time is: 2026-07-11 14:37:04
Your offset time is: 2026-07-11 14:37:04