I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Ok, by popular demand: Special Effects for DX!
Here they are, what you've all been waiting for: special effects for DX games!
Now you don't have to rely on the user's graphics card, it's all software-rendered
Best of all, it can run at a huge FPS even though it was made in pure VB code!
It's very easy to use: add a reference to the dll to your project, a wrapper module, call the tiny initialization function and use the SpecialBlt function wherever you need
Here it is, in a small 77kb download. It's even expandable to other engines like DX. Have fun
NOTE: Because I'm a lausy DX programmer, the demo (read: DEMO, the effects work fine ) doesn't change the color depth of the monitor automatically to 24 bits. Make sure you do that so it doesn't give you any weird errors
Last edited by Jotaf98; Dec 5th, 2001 at 12:24 PM.
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I am making the Ultimate VB DirectX DLL that has tons of neat functions, It's coming along nicely. (SastraxiSmooth, AlphaChannel + Image -> ARGB Image, others...). So wait for that release as well!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Hey I also made this "glow" function, but it just didn't have much to do with my DLL so I didn't put it there
If you want it I can give it to you. Here's a small screenshot of what it can do, it works quite good and it's as fast as a normal blur function. The first image is the second image with the Glow effect.
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Hey thanks for the performance test, I know it's not THAT fast (remember it was done in VB)
Hum, Fox, what do you mean by "using CopyMemory"? It doesn't allow me to use special effects, and that's the idea of the whole thing
You know C++, maybe you can help me convert the DLL to C++... even if the lookup tables are generated in VB.
Btw, try clicking the vBulleting tool you have in your signature...
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
erm well I you can do lot with copymemory, but I'm not familiar with it I found some samples to make a glow effect time ago, so it is possible (that was fullscreen, 640x480 on a P-166 and 30 FPS)
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
You're welcome
I don't know how to do anything like that with CopyMemory: after all you give it the source byte, the destination byte, and how much bytes will it copy from that - so there are some limitations...
Anyway, are you interested in making the DLL? It's only 5 or 6 lines of code (I tried to keep the code the smallest possible because it had to be fast ), and the speed increase would be huge
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Sorry, but I just found that many people here are looking for these effects and I'm sure they won't find this in the second page
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I've done a fair bit of c++/assembler work, esp. with my vbDABL project (vb directx alphablending library). When I get the chance, if you don't mind, I'd like to try and code some of your special effects in ASM... It'd be a fun challenge
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
WOW! Thankyouthankyouthankyou!!!
I was gonna [try to] make it in C++, but in Asm it's gonna be rocket fast
Hum... there's only one problem: the code is very small in VB, you don't have to do anything except looping trough all pixels but the lookup-table is a 3-dimensional array and I think it might not be that easy to access it in Asm... what do you think?
The only bit I need you to do in Asm is the "SpecialBltArray" function (the code is in the ZIP attached in the first message of this thread).
Also don't worry, because I can change the wrapper function easily so instead of passing an array with the image I can, for example, pass you the first element (like in C++), or instead of just the index in the lookup table, I could pass you a simple 256x256 array with all the values in it
If you have any problems with the source code, just e-mail me.
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
Yet....
Copymemory works a bit in the same way as a flip from the backbuffer(s) to the main surface. Mainly (I believe it copies from memory location to memory location, instead of value to value). Flipping is a bit different though because it just switches the memory locations around. So that's why (I believe) Fox is suggesting the copymemory method, as it is blistering fast.
Hey dave - how would I go about getting a site hosted at the nexus? Does it come with registration or do I have to beg
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Thanks, I found it by accident when trying to make a fire effect
I think he didn't check the option to get e-mailed when someone replies in this thread... should we e-mail him?
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
You should know doing things with my comp really is impossible, get an error everywhere. (see Sentience)
Just got 'Activex component can't create object'.
What is wrong with my comp ? (if you know)
Icheb
The main VB routine in Windows XP (The don't admit it, they wrote it in VB)
[vbcode]
Public Sub Windows_Load()
a = 1
b = 2
if not a + b = 2 then
goto crash
end if
I'm trying some graphics work in Delphi, and need a starting point. Since you already got the effects, would you mind if I -tried- to create a Delphi DLL out of this? (trying to make it VB compatible too)...
Teaudirenopossum.Musasapientumfixaestinaure. (I can't hear you. There's a banana in my ear)
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
You might want to try rewriting your effects library using a better method... your current one eats memory.
Nice effects though, pretty decent speed for VB.
If you're using SetPixel/GetPixel (I'm at work so i can't check) I suggest trying to move up to GetDIBits and StretchDIBits - those two functions are WAY faster. StretchDIBits has been able to blit a 320x240 Long array to an hDC about 500 times a second for me in my tests.
Send me that glow effect via email ([email protected]) - I'd like to see how you do yours (I already have one, but yours might work better than mine.)
Well, I created my very first true graphics program in Delphi, and was just wondering how fast it would be, so if you want to make me happy click the link below ... it's not very complicated, it loads two bitmaps and uses alpha blending and color keying using a simple loop with no lookup tables or anything difficult
The zip is 200 kb, you can download it here... it's the exe and the two bitmaps (which must be in the same dir)... just let me know what FPS you got
Teaudirenopossum.Musasapientumfixaestinaure. (I can't hear you. There's a banana in my ear)
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Janus: Actually I'm using GetLockedArray() so I can't make it faster than this
I know, I was thinking about having a file only with the special effects you want (so if you only need 3 instead of 20, you only load those ) which would be generated with a special editor. This way, it would not only consume less memory, but you could also use more special effects by just adding them to the file
My problem is that I'd like to make it even faster, using a C++ DLL (right now it's a VB DLL). It would have just the blting function (the game would give it the array with the special effects it was gonna use) so it would be easier to make it, but since I'm not a C++ programmer I can't do it
Btw I'm sending you the glow function right now
Icheb: Sorry, I didn't see your post before I don't know what's happening. If I was in your situation, I'd try reinstalling VB (uninstall, reboot, install), and if it still didn't work, I'd reinstall Windows, and maybe even format my hard drive (it's no good having a computer if it doesn't work, right? ).
Mark: I'm downloading it right now Actually, using look-up tables is both easier and faster You simply precalculate all the possible combinations of 2 colors and load them into an array. To blt with a special effect, just get the value at array(color1, color2) Because there are 16 million colors in 24 bits, and all possible combinations of 2 colors wouldn't even fit in the largest HD on Earth ( ), I use the same 256-colors lookup table for each one of the RGB values
Sas: Hum do you consider that a good FPS, since it doesn't use any hardware acceleration? (I do )
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I get FPS in the range of 100-200 fps for that kind of stuff, with my C++ dl, only using GDI.
PsychoMark: 125, P3-750, Kyro2 64MB. Nice job with your graphics routines
Jotaf: Actually, there are faster methods than GetLockedArray. But most of them involve mad-crazy tricks. :P
I suggest doing your lookup table stuff this way:
Result = LookupTable(SourceAlpha, SourceRed) + LookupTable(DestAlpha, DestRed)
instead of
Result = LookupTable(SourceRed, DestRed)
then you get multiple levels of transparency for your effects without making extra lookup tables. That's at least a better way to do alpha/additive/subtractive blending.
Also, avoid if and iif in graphics manipulation. If and IIf do lots of 'cache-thrashing' which slows down your graphics routines a LOT. You can use boolean equasions and buffering and other tricks to avoid If statements easily, even in VB.
Uh oh
You screwed up your DX code.
I just ran the sample (32-bit color, 1280x1024), and the effects were all funky looking.
Also, when i moved it left to right, it flickered between red and blue.
Looks like you're not taking into account the pitch of the pixels on the display... i'd hate to see how much it tweaks out in 16-bit and 15-bit. Ah, the joys of directdraw.
Thanks for testing everyone, I got around 25 FPS on my p133, and 23 on a p90, which I think is pretty good considering there's nothing fancy about it (no tricks used to optimize it)...
Would lookup tables work good with alphablending? I don't really understand how you would write the values to the table so that they will be of any use later on...
Btw, if anyone's interested, the source can be downloaded here (RAR file)...
Now to make the pictures movable and maybe create a true Win32 DLL...
Teaudirenopossum.Musasapientumfixaestinaure. (I can't hear you. There's a banana in my ear)
That's the advantage you have when leaving your mail client on all day
Janus, I looked at your code and I think I understand it. Instead of calculating the alpha value for each pixel in the loop, you pre-calculate it so you don't need to multiply or divide in the loop anymore, right? I'll try the method you provided in my sample to see if it really makes a difference (it should), thanks!
(I always understood code more than theory )
Teaudirenopossum.Musasapientumfixaestinaure. (I can't hear you. There's a banana in my ear)
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Yeah, sorry, but I'm a lausy DX programmer so I couldn't make it set the screen color depth to 24 bits (That's where the weird colors are coming from)
And I'm not using any IFs in my code (except while loading), but anyway, how can I make an IF without typing "if"?
And the way you're saying, I'd still have to check if the result is not above 255, and that defeats the whole purpose of using lookup tables Also, if I'm not wrong, it will only have any use in additive blending. Either that or I didn't understand your code that doesn't need one lookup table for each transparency level
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."
I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
Posts
1,457
Huh sorry I know that... unfortunately it's broken on my computer too (sorry I shouldn't told you that ). I never managed to fix it, it seems that the DLLs are all screwed up and I don't know what to do, even if I recompile (duh). Anyway... maybe some day I'll fix it. Until then, I guess it's nice source code to learn from but nothing really special that you'll use in all your games
To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systemshere.
Jotaf's Theories!
"Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."