How to fade a loaded animation?

Previous topic - Next topic

erico

Let´s say I loadanim "sprites.bmp", "sprites_day.bmp" and "sprites_nite.bmp".
Now, during game, I want to draw either day or nite over the former one, increasing transparency to simulate THE FAID! :o

Maybe I can use a screen buffer to do the fade and do a grab sprite at the end? It is my plan.

What are your ways of doing such?
It actually is like loading a new palette and I think this question was asked recently too. :-[

For some cosmic reasons, I foresee that doing this post effect as I planned may be a hog.
I could still optimize it to be good though, as the fx is not needed every cycle/frame.

What do you say?



mentalthink

Erico and you think in Polyvector, only changing the RGB values can have all the day cycle complete... The good thing it's you can use a simple image and more bigger than in LoadAnim, and if you need add details in example Clouds or other elements, you can make another polyvector over the background polyvector and changing the tone whit RGB....

You can do animations whit Polyvector too, put into an Array the images and then whit a counter display in the Polyvectors...

--------------------------------------------------------------------
Using LoadAnim...
I think a couple of thing... You draw the bottom layer and the put whit Alphamode a black Image... or you can put a Polyvector and changing the gradients...

Another thing in 3D:
Make a plane, and whit a simple Lights you go decreasing the intensity of the Lights (Here you take a look to Kanonet Library or mine about OpenGL, because GLbasic don't leave change the intensity of the lights, only the RGB's channels)

No more ideas:  :(

erico

I can´t use polyvectors on this project. :'( (could, but not worth, project is 99% complete :zzz:)

Quote from: mentalthink on 2012-Dec-15
--------------------------------------------------------------------
Using LoadAnim...
I think a couple of thing... You draw the bottom layer and the put whit Alphamode a black Image... or you can put a Polyvector and changing the gradients...

I is a nice idea, but I´m afraid drawing the screen contents 2x (one normal, another with alpha) would also be a hog?
Will compare this solution to the other one later to think...thanks.

For more cosmic reasons, the game sports 20-30 sprites going about, some are big, final resolution is 320x240 and scaled up on bigger screens. Would be nice if it would run on the likes of a caanoo. :-[

Also, thinking of compatibility with android things, I´m trying to keep all very simple on the graphics side, like only drawanim/sprite and collisions done by checking variables. I´m not sure this will prove much compatiblibility, but should be a good experience.

I need a resource cheap effect for weather change(sunny<->stormy) in a single screen game.

loud thinking: Maybe if I mix the 2 plans... do some screen layered fades, load nite/day  animsprite file, layer fade back.. sounds promising!

mentalthink

Yes Erico making Alphamode whit 2 images can be nice and simple... If you don't want get a lot of CPU make the images a bit minus big than the final resolution and the Scale or make a zoom, whit rotozoomanim...

About collisions I think the best method it's box Collision and mixing whit Circle Collision if the shape it's a bit more complex... I use box Collision because in 3D whit 2D Sprcoll stop for a bit the game... something internal whit OpenGl textures and check the Sprcoll...

I have alert about your game...

erico

#4
Ok, didn´t want to do a full black fade to load or switch sprites as it sounded lousy... :-[

So after drawing the first sets, if the weather target(0 or 1) is different than current, draws second sets with dec/increasing alpha mode from -1(there) to 0(faded).

Runs perfect and smooth and beautiful on my desktop... but as suspected before  :zzz: slugs around on the caanoo while fading. From steady 60 to 30fps and keeps 45fps on one weather as the loadbmp had to be over applied as a drawsprite. The later could be fixed by using a loadbmp of set 2 hoping the load won´t stop things for a part of second. If it dosen´t, then it would still jump background images, maybe better with BLENDSCREEN or USEASBMP...

It seems alphamode<>-1 on caanoo must be well thought since it is expensive.

I could speed up the code to accommodate things, but not worth as these post effects are extras.
Better think of a different approach to a more legacy "weather change" fx...

How the heck, back on amiga days, a simple and inexpensive pallete fade on AMOS would do and not nowadays!! :rant: :(


Hemlos

You will not regret switching to polyvectors like mental first mentioned.

Not only can you fade the brightness.....they are WAY faster than normal sprites.

Bing ChatGpt is pretty smart :O

erico

I went for drawsprite commands mostly for being used to them, and performance on caanoo.
I don´t think it worth changing for this one project at this stage and polyvectors have more limitations on caanoo.

Tried an alpha mode (-1 0) drawrect as a fade, is slugs a bit but it is more usefull.

Maybe I could avoid transparencies of alphamode (which seems taxing) while trying a mode ´dissolve´ fade, with dither?
Will give this a go, I also wanted a 2 layered rain effect which is similar to this approach.

Thanks all help.


   

Ian Price

QuoteI don´t think it worth changing for this one project at this stage and polyvectors have more limitations on caanoo.
Do they? I have a full screen poly in a Cannoo game I'm working on and it's fine. What are you finding problematic?
I came. I saw. I played.

kanonet

Maybe its worth trying the classic way of getting speed: trading space for speed. Maybe it would be possible to pre-render all your needed versions of that sprites and just load and draw what you need. It depends on how many sprites and versions you need, maybe its no way to go, but maybe its.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

erico

@kanonet, I thought of that but it would be too monstruous to do.
The game has a few drawanim and draw sprite calls in a set order, there maybe some 20 sprites going about at some time and making extra sprites would be too much. but sure fast.

@Ian Price, some GLB versions ago I tested draw/rotate/zoom/poly vector on caanoo, results at the time showed drawanim/sprite to be faster then poly by a little. They got similar speeds if moving a bunch of sprites or vectors of smaller then 320x240 size.

There are currently a lot of big sprites being draw, many are quarter screen size 6 or 7. The ones needed in game are all fine going. I´m currently polishing things and trying to squeeze a few effects into it, hence the pallete or sprite fade for a day/nite change and a rain and storm effect too. These are just extras and will stay if I can make it work. Biggest problem is that transparencies were never planned into the original game and cheaply adding it up is resource consuming.

But that a fade(crossfade) is working (on desktops full speed) and looking great, I don´t wanna let it go.

I will try coding that solution with dither, if it comes out nice, will release as a snipet.
One problem, the whole screen and everything must be draw twice so I can get a result screen cross faded.
But worst case, I could go make the transition operate as a wipe, maybe that will free processing a bit...

blackout12

I am a complete newbie. I have absolutely zero experience with programming. The only help I have is reading through the tutorials in the help guide.  I dont know how to put a backround on with my sprite. the guide just says "put an alphachannel in". I a new to this (2 days) and i dont know how to just "add an alphachannel". I dont even know if I should use an alphachannel according to one of those people that replied to me.
ps. I am just onthe "android" forum because I thought it was a forum with lots of people and I would have better chance of getting help.
Thank You    :nw:

Ian Price

Well, you don't need an alpha-channel if you don't want any part of another image to show through a background image - eg you just want a simple picture as the background, with no other image underneath to show through. In this case simply draw your background image fist, then draw everything else on top

eg
Code (glbasic) Select

DRAWSPRITE background,X,Y

DRAWSPRITE player, x, y


Alphachannels are added into your images with a paint program eg GIMP, PhotoShop etc. It all depends what you are trying to achieve with your graphics as to whether you really need them or not.
I came. I saw. I played.

erico

#12
...dithering quite didn´t work out. :(

If I´m to use transparencies, it must be something considered from start.
Worst case, I shall produce more images of each sprite fading and change things that way, probably a total of 4 or 5 steps as Kanonet suggested.
Good thing is that the app is currently small and seems to be able to handle lots of KB available for a good amount of GFX (even on caanoo).
Maybe it´s best to handle this when game is finished (core).

...but damit... the rain, as a  3 frames animated, 1/3 screen sized sprites (110x140), is taxing too, seems to steal 15fps on caanoo, ok on desktops as usual.
Maybe I change the rain to a set of smaller sprites or even dial a drop per sprite? Do you guys think that would help fps? (it´s an 8 bit vertical style rain that scrolls laterally according to the winds)

edit: I´m starting to glup the idea of optimizing a few code parts... :(


Kitty Hello

on the caanoo, smaller sprites is always a speed bonus.

erico

Good to know :good:

I will try sprite sized 1x110 and for next it.
Another good thing is that I won't need to draw a lot outside the screen this way (because of the scroll).

If not enough, I will try doing each drop, something like 1x10.

thanks!

ps: heck, why do we always keep adding to a game? The original design is complete, but now I want the fade and rain like I can't live without it... ;)