Render #Sprite2D to #Sprite2D?

Advanced game related topics
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Render #Sprite2D to #Sprite2D?

Post by Shannara »

Is there a way to render a 2d sprite to another (blank = black) 2d sprite of the same size? Reason being, I am using the DisplayTranslucideSprite command. In order to use that command, you must use the StartSpecialFX and StopSpecialFX commands. If you did not know, use of this command will reduce your framerates to at least 1/3 of it's original rate. For example, my normal FPS is 60, use of this command have reduced it to 19.

This is unacceptable in any game so..... I was thinking of just rendering the translucent sprite w/ proper opacity onto a blank sprite of the same size (black background) only once, then use that sprite and render it as a transparent sprite, which should work and not impact the FPS so drasticly.

Since this will be done on load of the game, it shouldnt have an impact on gameplay. However, I have not found any commands (or im blind, or i didnt see them :D) in order to render (not copy, not grab) one 2D sprite onto another...

Have anybody done this Without any platform specific code?
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Take a look at the UseBuffer() command.
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

I have a screen saver i wrote that has 20,000 3D sprites that zoom in and out. and i still get at least 40fps you must not be doing something right
are you usering

StartSpecialFX()
DisplayTranslucideSprite(#Sprite, x, y, Intensity)
EndSpecialFX()
in your code? if not that is your problem

Sean
Soulfire
User
User
Posts: 23
Joined: Mon Mar 08, 2004 7:17 am

Post by Soulfire »

The reason StartSpecialFX() and StopSpecialFX() slow your program down so much is that it copies the entire current drawing buffer from video memory to system memory. This is because it is much faster to do complex operations such as pixel blending on data in system memory than it is over the agp bus to the video card's memory. The only problem is that it does take quite a long time to copy the entire buffer from video memory into system memory, and then back again once you're done with your special effects commands. I wonder, if it would be possible for Fred to add some arguments to StartSpecialFX(), like the dimensions of a rectangular area to copy. So you could do something like StartSpecialFX(50,50,100,100). This would only copy a 100x100 square starting at (50,50) of the current buffer. That way if you had a 100x100 sprite that you wanted to blend in at (50,50), all that you'd have to copy to the system memory and back would be the portion of the buffer that you are blending too, instead of the entire screen's worth of data. This would be much much faster!
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

download this and tell me if it's slow

it has 20,000 snow flakes and a translucent logo

http://www.3dcurrman.com/3DSnow.zip


Sean
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Pupil wrote:Take a look at the UseBuffer() command.
That worked perfectly. My 700x500 gfx now displays at 60 FPS :) Thank you.
scurrier wrote:I have a screen saver i wrote that has 20,000 3D sprites that zoom in and out. and i still get at least 40fps you must not be doing something right
are you usering

StartSpecialFX()
DisplayTranslucideSprite(#Sprite, x, y, Intensity)
EndSpecialFX()
in your code? if not that is your problem

Sean
The following is my code ... :)

StartSpecialFX()
ClearScreen(0,0,0)
DisplayTranslucideSprite(#FIRST_SPRITE, player1_x, player1_y, TranslucideValue)


StopSpecialFX()

====

It is actually from the SpriteFX.pb sample, however it uses a 700x500 sprite instead of the small ones they provide. Thus could be the reason of the slowdown. This does the fade in and out, no zooms as I have not found out how to do that with 2DSprites yet.

Soulfire wrote:The reason StartSpecialFX() and StopSpecialFX() slow your program down so much is that it copies the entire current drawing buffer from video memory to system memory. This is because it is much faster to do complex operations such as pixel blending on data in system memory than it is over the agp bus to the video card's memory. The only problem is that it does take quite a long time to copy the entire buffer from video memory into system memory, and then back again once you're done with your special effects commands. I wonder, if it would be possible for Fred to add some arguments to StartSpecialFX(), like the dimensions of a rectangular area to copy. So you could do something like StartSpecialFX(50,50,100,100). This would only copy a 100x100 square starting at (50,50) of the current buffer. That way if you had a 100x100 sprite that you wanted to blend in at (50,50), all that you'd have to copy to the system memory and back would be the portion of the buffer that you are blending too, instead of the entire screen's worth of data. This would be much much faster!
That would be excellent if it'll speed up the FX portion.
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

and i forgot a snow blower that works when you press the mouse button
to escape press the escape key


Sean
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

use sprite3D

much faster you can put in a smaller image then zoom it as big as you need it
try my demo and see what i am talking about
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

if you need some help in doing 2D stuff check out my 2D tutorial i just uploaded part 3 today
got to http://www.3dcurrman.com
than tutorals all the source is there and graphics well commented
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

did you get a chance to run either of them?
if you need any help i will be on for 10-20 mor minuts
then it's night night time for me


Sean
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Thanks for the info, I am looking through the tutorials now. As for the use of Sprite3D, I cannot use it as I do not want to restrict myself to the Windows Platform (according to the PB Docs), not to mention have a fricken huge "runtime" aka 3D engine.dll, AND the fact that you cant mix 2D commands and 3D commands (due to the flipbuffers required in Start3d/end3d, all of this is mentioned in the post found @ viewtopic.php?t=9832 )

Scurrier: If your on MSN IM, we can talk, shannara@unformed.com is my login. However, I havent looked through the tutorials for everything I need yet :)
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

[/quote]

The following is my code ... :)

StartSpecialFX()
ClearScreen(0,0,0)
DisplayTranslucideSprite(#FIRST_SPRITE, player1_x, player1_y, TranslucideValue)


StopSpecialFX()

[/quote]

take the ClearScreen(0,0,0) out of your SpecialEffects area put it befor starting SpecialEffects

try that it might help cause ClearScreen is not a specialEffect command
and from what i have heard if it's not a SE command it can realy slow you program down.


Sean
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

there are 2D special effects there called 3DSprites and it doesn't use the oger.dll it's part of the internal commands they are 2D sprites with some cool things you can do with them there just called 3dsprites but there part of the 2D libary the 3Dsnow is all 2D and uses the 3Dsprites to Zoom in and out and the Logo is also a 2D sprite and it's converted into 3DSprite with 1 command. and as you can see by the size of my EXE there is no OGRE.DLL there. Look in you PB help under 2D sprites and about 5 lines down there will be the 3D sprite stuff and from the main page you will see the 3Dstuff and if you look in there you will not find any sprite commands thats for a 3Dworld not what you want. but the 3DSprites are REALY 2D
trust me i have been doing this for a long time.


P.S what did you think of the 3DSnow?

Sean
Soulfire
User
User
Posts: 23
Joined: Mon Mar 08, 2004 7:17 am

Post by Soulfire »

PB docs say to put ClearScreen() inside special effects mode, most likely because it is faster to fill the entire screen with rgb(0,0,0) in system memory than it is to video memory!
DriakTravo
Enthusiast
Enthusiast
Posts: 346
Joined: Fri Oct 10, 2003 12:42 am
Location: Tampa,FL,USA
Contact:

Post by DriakTravo »

Code: Select all

download this and tell me if it's slow 

it has 20,000 snow flakes and a translucent logo 

http://www.3dcurrman.com/3DSnow.zip 
This progam gave me absolutly no lag at all, but for some reason, they all have a pink background, why?
Post Reply