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 / negative alpha blending for black smoke (source/no media)

Author
Message
Suicidal Sledder
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 16th Oct 2011 17:50 Edited at: 16th Oct 2011 17:58
I am trying to use negative alpha blending to make black smoke and I am so close but yet so far. The problem is if I use ghost object on 1,1 to enable negative alpha blending I cannot fade the object out gradually to make the smoke "dissapate"(sp?). If I use positive alpha blending (using set alpha mapping on obj,perc) the smoke comes out white no matter what. I would like to be able to use set alpha mapping on in conjunction with ghost object on (flag = 1). this would be perfect but it seems the two commands are incompatible. If the object is ghosted using ghost object on then set alpha mapping on has no effect. If I use only set alpha mapping on then the alpha blending is always positive besides the fact that I cannot properly hide the "edges" around my circular smoke texture.

Here's what I got so far:



As it stands now, altering the set alpha mapping on percentage has no effect. (Therefore impossible to fade away my smoke objects). comment out ghost object on (line 20) and you can now very smoothly fade the object in and out but obviously the edges are still there.

Anyone have any idea how to do this? If you would like my full source code for my smoke demo just ask and I'll post.

PS sorry for the sloppy code... its been edited and re-edited to death

thanks!

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Oct 2011 20:37
Try making the smoke white but faded to black to start with and then gradually un-fade it so that it goes back to white and transparent.

[b]
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 16th Oct 2011 21:14
I use ghosted objects the less as possible due to zdepth craziness. It just loves to pop before everything else.

By the way it is called negative ghosting...

Use black smoke texture with alpha mapping. That way you can fade out either by making frames of the smoke, or by command too.

set alpha mapping on ObjNum, Percent

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Suicidal Sledder
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 17th Oct 2011 21:08
Hey thanks both for the responses. I tried them both but the problem is if I dont ghost the image then the background behind my texture is still visible (causing a nicely faded white plane). If I use set image colorkey to make white the transparent color then it obviously only makes pure white transparent meaning around the edges where its supposed to fade out it is very blocky and causes a sort of ring around the actual texture part. Similar to using the paint bucket tool on a jpeg due to lack of pixel perfect quality.

Thanks all

Suicidal Sledder
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 17th Oct 2011 21:24
i suppose the easiest way to accomplish what I am trying to do would be to fade the texture on the object. I tried using fade object object,percentage but it seems that textures are unaffected by this command.

thanks again

Suicidal Sledder
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 28th Oct 2011 10:30
does anyone know how to accomplish this? my project is stalled until I can resolve it.

Thanks

Sadly, programming is only a hobby for me right now. As it turns out, driving a 70 ton, 7 million dollar Abrams tank requires less qualification than pecking away at a keyboard. Who'da thunk it?

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Oct 2011 13:32 Edited at: 28th Oct 2011 13:35
Quote: "it seems the two commands are incompatible"


They are not, if I remember correctly, you cannot use [set object transparency] and [set alpha mapping on] at the same time either; they override each other. I think that alpha mapping is just an object based 'see-through' setting, for use with things like glass or water; object transparency is a per pixel alpha setting; you specify what is opaque and what is not using pixel alpha channels.

This doesn't mean that your goal is impossible; you just need more control over the pixel rendering. To gain the control you need, as stated earlier, you can animate the dissappearing smoke effect on a series of texture frames, and play back the animation and use [set object transparency]. In code the object will remain visible but in the view it will disappear because of what is on your textures; eventually nothing.

The other way is to use one texture in conjunction with a HLSL shader. If you know how to use shaders, you can copy a basic pixel shader and just decrease the alpha element in the ARGB [COLOR] array over time using the [TIME] variable to control how long it should take; and using a FX constant to determine when to start the effect.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 28th Oct 2011 17:48
Is this what you're after? You need IanM's Matrix1 plugins to compile it.

Suicidal Sledder
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 28th Oct 2011 22:13
checking it out ill get back to you. thanks

Sadly, programming is only a hobby for me right now. As it turns out, driving a 70 ton, 7 million dollar Abrams tank requires less qualification than pecking away at a keyboard. Who'da thunk it?

Suicidal Sledder
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 28th Oct 2011 23:03
Hey GG thanks a million it worked like a charm with a little tweaking. I cant wait to put this into my game, it will look awesome. Here's my full smoke demo below if you are interested in seeing my final results.



Thanks again!!

Sadly, programming is only a hobby for me right now. As it turns out, driving a 70 ton, 7 million dollar Abrams tank requires less qualification than pecking away at a keyboard. Who'da thunk it?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th Oct 2011 03:26
Very nice effect. I see you simplified my code a bit too. Well done.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 31st Oct 2011 16:11
Could you not have just used a black smoke texture with png alpha transparency?

My signature is NOT a moderator plaything! Stop changing it!

Login to post a reply

Server time is: 2026-07-10 01:59:33
Your offset time is: 2026-07-10 01:59:33