The NEW Build Your Own Arcade Controls

Main => Software Forum => Topic started by: youki on February 15, 2007, 01:11:56 pm

Title: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 15, 2007, 01:11:56 pm

As i said in a post AtomicFE 0.19 (not yet released) is able to do some Reflection Effects and Gradual alpha blending.

this is a preview of what we can do.  It is just an exemple based on a _Shock's layout  .

I'm not an Artist , it is just a technical demonstration., we can do lot better!

It uses only DirectDraw and all is software.

A video here :

http://www.AtomicFe.com/video/shock.avi

Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: Aurich on February 15, 2007, 06:06:11 pm
Nice. I find it frustrating that Mala doesn't support true alpha channels personally.
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: johnperkins21 on February 15, 2007, 06:08:51 pm
That looks pretty hot. What sort of options are available for the reflection?  Does it have to have the wave, and can you move it and limit it to just the cap/vid?
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: shock_ on February 15, 2007, 11:16:05 pm
wow - nice work, youki!
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 16, 2007, 03:07:19 am
That looks pretty hot. What sort of options are available for the reflection?  Does it have to have the wave, and can you move it and limit it to just the cap/vid?

you do what you want with reflection , Reflection Zone are Atomic Layout Object as the others. so you place them where you want , you define the reflection source where you want , you can place it on the layer you want and it will reflects only layer that are below. And You can make move them or not. The moving is totally free as all Atomic object.   In addition on Reflection zone you can apply mask, gradual alpha blending etc..etc..

Here a exemple of a first try i did with reflection , the reflection is only under the cap/vid and use Gradual alpha :


(http://www.AtomicFe.com/divers/shock.jpg)
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 16, 2007, 03:31:37 am
2 preview of layouts that are "Work in progress" inspired from shock_ one too , featuring reflection, gradual alpha etc.....

These are done by a real Artist (not me!!!!) ,  totoleouf..

(http://www.AtomicFe.com/divers/maquette1.jpg)


(http://www.AtomicFe.com/divers/maquette2.jpg)
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: shock_ on February 16, 2007, 03:41:14 am
sing out if you need the original .psds!
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: Organic Jerk on February 16, 2007, 04:43:41 am
That's pretty sweet.... how does it look from a system performance level, though?  does it affect scrolling speed and such?  In fact on an  unrelated note does using Movies affect scroling speed in Atomic?

Nice. I find it frustrating that Mala doesn't support true alpha channels personally.

Yeah, me too actually... It's especially frustrating when I'm creating custom messages or console pictures to be used, because I have to coordinate the BG of the entire layout with the BG of the "snap", when I would much rather just being able to make it transparent..
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 16, 2007, 05:03:06 am
Quote
That's pretty sweet.... how does it look from a system performance level, though?  does it affect scrolling speed and such?  In fact on an  unrelated note does using Movies affect scroling speed in Atomic?

Of course performance depends on how much reflection zone you use , the size , if you use alphablending or not..etc..  But it does not consume more processor power that other effect in Atomic.

The reflection itself does not use lot of processor ,  the thing that consume more power is alpha blending. (gradual or not) . 

In clear if you make a layout using 4 layer differential scrolling, 7 reflection zone, 15 videos , and if you use alpha blending on each object.  You will need a P4 4GigaHz...

If you do a reasonnable layout, with said one background scrolling, video snap , one or 2 reflection zone , and few objects moving   , a 700 mhz machine will be enough.

For instance, the layout with the reflection only the snap. (the first image i posted) , use a video as "selection" in the list.  Runs perfectly on my Celeron 533Mhz.

The first one (the video) is not really usable on the celeron , the video have been taken on my P4 3 Gighz. , but processor used is only at 50%  .  So i guess it still should be ok on a 1.5ghz computer.


Quote
In fact on an  unrelated note does using Movies affect scroling speed in Atomic?

If your machine is good enough  not.  If the layout is too complex for your machine yes.  it really depends of the layout.  Knowing that Layout are really scalable , and there are lot of "tips" we can apply to optimize layouts.

Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: Havok on February 16, 2007, 08:40:40 am
That's pretty sweet.... how does it look from a system performance level, though?  does it affect scrolling speed and such?  In fact on an  unrelated note does using Movies affect scroling speed in Atomic?

I'm running Atomic on an AMD Sempron 3300+ and have video snaps - my scrolling speed is great. The movies also come up instantly when I select them on the list.

Youki - this is looking great!
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 16, 2007, 09:15:13 am
That's pretty sweet.... how does it look from a system performance level, though?  does it affect scrolling speed and such?  In fact on an  unrelated note does using Movies affect scroling speed in Atomic?

I'm running Atomic on an AMD Sempron 3300+ and have video snaps - my scrolling speed is great. The movies also come up instantly when I select them on the list.

Youki - this is looking great!


oops..you was talking about the list scrolling not image scrolling on layout...

Video comes up instantly on my old celeron 533
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: Havok on February 16, 2007, 09:20:55 am
oops..you was talking about the list scrolling not image scrolling on layout...

Video comes up instantly on my old celeron 533

Haha - yeah, but image scrolling also works great too!

 :dizzy:
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: johnperkins21 on February 17, 2007, 01:27:42 am
This is awesome!  :notworthy:
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: swindus on February 17, 2007, 02:34:31 am
Yes, looks really nice! I also like the small font in the game name. Good work!
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 17, 2007, 03:10:39 am
Thanks

I also like the small font in the game name.

I guess we will see that soon in Mala too.  ;)
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: swindus on February 17, 2007, 03:20:03 am
Wrong guess, no need for this.
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: squirrellydw on February 17, 2007, 10:51:47 am
Hey SWINDUS, any chance in getting the refection thing in MaLa? please please please
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: FrizzleFried on February 17, 2007, 10:52:16 am
No need Swindus,  but it sure would be nice!
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: swindus on February 17, 2007, 12:24:10 pm
Hey SWINDUS, any chance in getting the refection thing in MaLa? please please please

MaLa is a pure GDI application and not a DirectX application. I don't think that it is possible to do this with GDI stuff.
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: Howard_Casto on February 17, 2007, 06:04:33 pm
Hey SWINDUS, any chance in getting the refection thing in MaLa? please please please

MaLa is a pure GDI application and not a DirectX application. I don't think that it is possible to do this with GDI stuff.

It's possible, it'd just be slow.  The trick is you render the object twice, once upside-down.  The blending is just regular blending effects.  Or at least it would be if I had coded it. 
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: headkaze on February 18, 2007, 05:11:31 am
You could use AlphaBlend API function.
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: audiomidiman on February 18, 2007, 04:35:10 pm
Nice......
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: Howard_Casto on February 18, 2007, 07:07:31 pm
You could use AlphaBlend API function.

Yeah I mean even if you don't have the gui setup to rotate objects sending stretchblt with a top lower than the bottom automatically mirrors any image.
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 19, 2007, 03:49:41 am
Quote
MaLa is a pure GDI application and not a DirectX application. I don't think that it is possible to do this with GDI stuff.

It is easiest with GDI, as said HeadKaze use AlphaBlend function.  Not sure about performance, but it supports hardware acceleration , so if you have a modern video card it should be good. 
The function does not support mirroring, so i guess you will have to mirror before alphablend.

The other solution is to manipulate directly image bits.  (it is what i do with DirectDraw , because DirectDraw doesn't support Alpha Blend without a specific hardware doing that... and i never saw a "commun" video card supporting that feature (via DirectDraw) )  but if you use only GDI i think the Alphablend function would be the best solution.



Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: headkaze on February 19, 2007, 04:52:01 am
Yep, your both right, I just knocked up a demo using GDI+ to create a reflection...

You use StretchBlt to flip it vertically to a MemDC (using CreateCompatibleDC/CreateCompatibleBitmap), then use AlphaBlend to draw each part gradually fading to the bottom.
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: Howard_Casto on February 19, 2007, 04:22:41 pm
It's a little frightening when we are all on the same page.  I keep expecting the earth to crack open and hell-spawn to pop out.   ;)
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: headkaze on February 20, 2007, 02:01:01 am
lol Who will be the first to greet this hell-spawn? I vote you first >:D
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 20, 2007, 03:27:14 am
It's a little frightening when we are all on the same page.  I keep expecting the earth to crack open and hell-spawn to pop out.   ;)

lol ... inded really terrifying!!   :-\
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: csa3d on February 20, 2007, 07:11:50 am
so which one of you agreeing parties is going to write that Mala Plugin to support this 'not needed but much anticipated' functionality?  :)

-csa
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 20, 2007, 07:14:42 am
so which one of you agreeing parties is going to write that Mala Plugin to support this 'not needed but much anticipated' functionality?  :)

-csa

This plugin already exists ... it is called AtomicFE !  ;D    Just run Atomic from Mala!  ;)
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: headkaze on February 20, 2007, 07:31:38 am
hehe but seriously, you can't write a plugin to do this, swindus will need to think it's worth adding to the Mala FE. Personally I think using the method proposed by me would work great with Mala. In fact it would work for Atomic or GameEx as well. The thing is, what you failed to metion Youki is that you can get a handle to the dc of surfaces in Direct Draw. So you can actually BiBlt to them or whatever use AlphaBlend API. It would probably be faster than doing per bit alpha bending like you've done. You might want to include that as a feature for slower machines.
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 20, 2007, 08:03:00 am
In fact not.  It is one of the first thing i tried 3 years ago before starting to write my own routines.

I mean it doesn't work in the context of Atomic with some guide line i wanted for Atomic.

I wanted to Atomic works on 16bit colors depth  not 24 or 32. Just to save "memory" . Remind that i wanted Atomic works on a very wide range of configuration (slow, average, fast...) . And i planned to do advanced animated layout that could require lot of images in memory...

Alphablend function with 16bit image does not manage "Transparent" color.  you can only set the same transparency on all points of the image.  But not say, the RGB(255,0,255) is not visible for the entire image.

And AlphaBlend function does not manage Gradual Transparency on 16 bit image.  If you want to that, you have to use 32bit/pixel images.

In addition the fact to use 32bit/pixel image with Alphachanel in a layout would require that the user who is making the layout knows this concept and knows how to work with Photoshop to do what he wants. That's require some graphics skill that not  everybody have.  I wanted something as simple as possible when you build the layout.  Atomic use simple image, and you can apply AlphaBlending (gradual or not) on every images, you don't need to play with AlphaChannel or so...

So mainly due to this 3 points , i decided to go to my own routines.

Now, in the context of another Front End , of course it should work.

Quote
you can't write a plugin to do this,

It depends only how your plugin system is done.  Technically it is perfectly doable from a plugin.
Swindus would have to enhance his current plugins system , i think.
 
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: headkaze on February 20, 2007, 08:33:16 am
No but your wrong, I'm talking about using AlphaBlend function in a loop, so you use for example divide the height up into 10 peices then AlphaBlend them one by one using different levels.

It is still faster than using per pixel alpha blending.

The "gradual transperancy" you descripe is accomplished in the loop, in chunks, not per pixel like you do.
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 20, 2007, 08:59:27 am
So you are saying is i want alpha blend 64000 pixels with no contigous alpha value  , i call 64000 times AlphaBlend??

Even if you try to optimise by finding "contigous" values and Alphablending little zones , that you could win using the alphablend  you will lost by finding the chunks where you will have anyway to go pixel by pixel.

Or may be i don't  get your point ?

Anyway i'm pretty sure that 64000 call to a Alphablend function is slower than changing 640000 WORD directly in memory on the back buffer.

Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: headkaze on February 20, 2007, 09:10:56 am
No, I'm saying use AlphaBlend in chuncks, not pixel by pixel.

Code: [Select]
StretchBlt(hMemDC, 0, 0, width, height, hDCSrc, 0, height - 1, width, -height, SRCCOPY);

for(int i=0; i<levels; i++)
AlphaBlend(hDCDest, left, top + height + i * Size, width, size, hMemDC, 0, i * Size, width, size, fcn, 0);
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 20, 2007, 09:42:37 am
ok, you are alphablending by strip here.

But i don't really see the interrest.

Except you could have a different alpha value for each strip.    But the effect you obtain is really limited.

And you don't manage ColorKey (Transparent Color) .

In this particular case, i agree i should be faster that the pixel method , but it would be only for a very particular case.


Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: Howard_Casto on February 20, 2007, 03:44:42 pm
Way back in the day when dinosaurs roamed the earth I used to "fake" a similar effect in lazarus.  It would slow down the rendering a tad, but it should give for a more realistic blend.  The details escape me, but basically you'd take a black to white (or white to black) gradient, xor it with the image and then render them with the transparent paint option in the gdi.  Now it wasn't prefect, but it got the job done.  Sometimes you had to change the color of the gradient depending upon the background image though or else it'd stick out that it's not really a gradual fade. 
Title: Re: Reflection + Gradual Alphablending on a Layout
Post by: youki on February 21, 2007, 03:15:22 am
I know this method it is something i used on my Atari St to do this kind of Effect. Indeed, you can simulate a kind of alphablend effect with the XOR.