Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

bogdanontanu

2D harder to do than 3D today?

This topic is 6925 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

As i told before i work at a 2D RTS game (and i have more than the openning screen ) Now i have a speed problem: -because of my own alph blending routine i had to move all the surfaces into system memory leaving only the flipping chain and maybe user interface into videomemory. Basically i do all blits in system memory then a blit from system to video back buffer. This makes my game slow ...but i cant do else because i must make lots of apha blending (explosions, fire and cloaked units) Oh and my resolution is 800x600x16.... so i think that when i dress my gane up with all units bitmaps (at least 32pictures of 128x128 per unit type) it will anyway get out of video ram.... Anybody has any ideea al all what can i do to speed my game up? i am almost done with graphics engine and i have to start AI pretty fast... so please help?

Share this post


Link to post
Share on other sites
Advertisement
Don''t know if this will help and someone else correct me if I''m wrong.

First, DirectDraw doesn''t support alpha blitting or better said it supports it only in HAL and I don''t think there are many cards that do alpha in 2d. From what I''ve read you are basically going to have to accomplish it with software with your own code. Now, I''m going to assume this is the way you are doing it. If not remember alpha blitting in 2d is not widely supported so you will get better support on different machines if you write your own code for it.

That said you said that your alpha surfaces are in VRAM. Are you blitting to SYS? SYS to VRAM is slow, the opposite direction an even slower. Also there may be issues on alterating your surfaces after they already reside in VRAM. Software examples of alpha blitting that I have seen do their work in SYS then send the altered surface to the video card. Chances are you are encountering one of the above scenarios and its killing your performance.

Now even more bad news! Even asm code for alpha blitting will give you only marginal speed. If you remain in 2d I would suggest using it quite sparingly if you want to keep your fps at a decent level.

Hope that helps,

Sieggy

Share this post


Link to post
Share on other sites
hi bogdanontanu,

this might not improve performance much... but one tip. don''t have a flipping chain.

you have your offscreen surface in system memory. you have your primary surface in vram. do everything in system memory and than bltfast to the primary surface on vsync. i''ve never tried that yet, but apparently it is possible to blt on vsync.

if you know you only want alpha blending for certain things, there are probably some tricks that could be done. say, if you wanted to do shadows. you could have some background tiles in a temporary surface in system memory, alpha blend a shadow, then blt those to vram. if that''s all you did, then you could store a bunch of sprites in vram... that would mean that shadows wouldn''t darken sprites, only the background. i''m not sure how well this would work... but i thought it might get you thinking

- n8




nathany.com

Share this post


Link to post
Share on other sites
thank u guys for answering

but it dosent help me very much

first i make it clear that ALL of my surfaces are in system ram because i do intensive alpha blending for:
-shadows for units (yes they have to apear on other units)
-all units can be translucent from time to time (cloaked mode in my game)
-menus witch apear over the game surface and game is stiil going on under the menu (Real time huh?)
-explosions from dead units or fire upon units/buildings

and because i have animations of fair big units (128x128)
so its 128x128x2(16bits)x8(number of move animations)
now if i have 64 unit types ....
u get the picture...it JUST CANT FIT INTO VIDEO RAM!

Now for waht u said:
Method.1
-not having a flip chain....will not help much because the flip method is made by the hardware of the video board (and every modern video card has a flip today) so no flip will only save tiny speed but will get me to tear image on some video cards
Method.2.
-not to blit from videoram to system ram ....
thanks a lot ...but i dont do it NEVER i know it is extremely slow
-not to blit from system to video ram ....
hmmm can do that if i want to see smthing on screen...cant i?
-not to do alpha a lot ....
this means to sacrifice *quality* and this is really the last option....cant be done if i want a to make good game

What i think i will do:
(that is if i cant find some other great ideea)
-I am seriousely thinking to downgrade resolution from 800x600x16 to 800x600x8 or even 640x480x8

this makes me think to my old time of ZxSpectrum programming ....i guess computers didnt evolve that much ....at least on 2D speed i mean...huh?

What duo you guys think : can we do fast 800x600x16 2D graphics today? with alpha blending of course eh?

Share this post


Link to post
Share on other sites
Hah. This might be a little late in your project to do, but if you switch from 2D to 3D then you''re problem are solved. And when I say 2D to 3D I don''t mean change your whole game. Just make sprites a textured polygon facing the camera. All 2D graphics can be done this way. You get the speed of hardware accelerators + the alpha blending you so desparately need.

This is obviously a big task. I only mention it because it seems the only way to keep all this intensive alpha-blending in your game.

The only problems I can see with it is that your game will now require a 3D accel, and it might be more work than its worth. But thats for you to decide.


I guess this is where most people put a famous quote...
"Everything is funnier with monkey''s" - Unknown

Share this post


Link to post
Share on other sites
There isn''t much I can see to help you right now, without taking closer examination and more time.
Just one thing,
Make sure your blending routine is as fast as possible - see the gamedev.net article ''MMX enhanced alpha blending''
If you profile your code and find out where most of your time is going, then you may find (doubtful though) that doing more buffering will help out.

See what comes up,

-Mezz

Share this post


Link to post
Share on other sites
Thanks
i am late in my project...as i still have only 6 moths until alph release is expected....
and i dont think that 3D is an option...after all is a 2D game...but then i will make a try and see if its much faster

Anyway this dosent solve my question because running from 2D in 3D means that 2D is slower than 3D isnt it?

And for timmings ...
i have done that with QuerryPerformance counter and i had found that my ASM alpha blending routine is fast even without MMX....
My problem is at LOW SPEEED system memory to system memory BLT''s ....proble is i have a lot of BLT in a 2D game and alpha blendig has to be done in system memory to be that fast ....
so what i win at alpha blending i loose at system to system blt....this is my dilema....ohhhhhhh
Thanks anyway

Share this post


Link to post
Share on other sites
bogdanontanu:

Right, it''s quite obvious that you at some point have to blit from SYS to VRAM. The point I was trying to make is that you have to manage it appropiately due to the expense that it incurs.

It sounds like, though, you have a great deal of alpha blending going on. As others have said, it''s going to nail your performance. Software implemented alpha blending, even on the "speed machines" of today, can only be used sparingly. I imagine all the alpha blending that you are doing is going to continue to hurt you until you cut it back or find less processing intensive special effects. All the 2d games I currently have use very little alpha effects (i.e. starcraft, aoeii, etc.).

Its not particularly nice but unfortunately a lot of these fancy effects are a great deal faster and better looking on hardware accelerators. The difference between a software engine and hardware accelerated engine is often night and day and not just in performance. I would also suggest migrating to a 3d engine (I did such a thing for an iso RPG I''ve been working on) as the others have. You gain the benefits of hardware acceleration and numerous special effects and possibilities at your disposal. However, as you noted you are in a time crunch and I will point out that interfacing (with d3d at least) is no easy task, particulary if you are new to it.

Perhaps someone else here can offer some better advice. I encountered many the same roadblocks you did when working in 2d so my heart goes out to you. When it comes down to it, 2d is very limited as to what you can do with it (relative to accelerated 3d). Good luck, and hopefully someone else will have some better answers to your problem,

Sieggy

Share this post


Link to post
Share on other sites
Well... Dune 2000 recommends a 2MB card and a P133 and has a resonable amount of alpha fx. I believe it is running at 640x480 though. You may want to drop downn to 640x480 x 16-bit, or support both resolutions. Also, are these menus often on screen? Anything really big that doesn''t really need alpha would be a canidate for dropping.

Otherwise I think it''s just a matter of optimizing your asm more, including a custom routine for non-alpha Blts. You may be able to write some specialized alpha routines for "darken/lighten" or using a common alpha for an entire sprite vs alpha maps. With a few ASM routines for each and the use of function pointers... should be able to get it pretty fast.

Maybe compressed or compiled sprites are an option? Let''s see if anyone posts a reply regarding those under the "Should I write my own Blt?" thread.

Dune 2000




nathany.com

Share this post


Link to post
Share on other sites
I faced the same problem a couple of months before and I researched a lot.

3D Acceleration is really only 2d acceleration. The hardware only draws triangles.... It''s really simple to implement or modify an engine to Enhanced 2d engine using d3d, for example. The results are incredible. And I think that there''s no problem to ask for "3d" acceleration on a 2d game.... There are some very good articles both in gamedev.net as in gamasutra.... also check the zip files from gdmag.com



Despotismo AKA Javier Otaegui
Sabarasa Entertainment
www.sabarasa.com.ar

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!