Single Surface Vs Sprites

Blitz3D Forums/Blitz3D Programming/Single Surface Vs Sprites

KuRiX(Posted 2005) [#1]
Heeello.

I have been searching in the forums, and i have found some interesting things about this, but can't find the winner.

What is better? I have around 200 sprites in my game. Is it better to use single surface meshes? Is it better to use CopyEntity for each sprite or mesh?

thanks!


Bouncer(Posted 2005) [#2]
aaaarrgghhh! not this debate again :)
If you do it right single-surface is always faster... alot. Don't let anyone tell you otherwise.


KuRiX(Posted 2005) [#3]
Sorry to ask again.

Anyway, is it worthy for only 200 sprites (all the same) to make single surfaces???


Bouncer(Posted 2005) [#4]
Depends on your target platform... but optimizing is always good.


KuRiX(Posted 2005) [#5]
Ok thanks, but could you explain why a single surface moving vertex is faster than sprites?


Rob Farley(Posted 2005) [#6]
It doesn't take much to get the answers... google is your friend.

http://www.google.co.uk/search?hl=en&q=single+surface+site%3Ahttp%3A%2F%2Fwww.blitzbasic.com&btnG=Search&meta=


Ross C(Posted 2005) [#7]
It's all to do with surfaces. Blitz stalls the gfx card everytime it rendersa surface if i remember correctly. And that causes slowdown. The less surfaces in your game, the beter :o) Therefore using single surface for grass, particles...etc is faster :D


Techlord(Posted 2005) [#8]
KuRiX,

Ross C does a good job explaining the need for Single Surface Sprites. I haven't seen 'Single Surface' mentioned in other game dev forums so I suspects its specific to Blitz3D.

There is a great deal more work that needs to be done with Single Surface 'Sprites' when one considers Single Texture Image Sets, Pixel Perfect Resolution, Transformation, and Collision. You have to code this functionality. I have a good discussion going here to unlock its mysteries.

Coding the functionality I mentioned above can be tricky and there are several Single Surface Libraries that can make your life easier. After playing with several, I decided to give a crack at my own. I'm writing a open source single surface lib.

One of my first goals with the lib is create a 3D command set to replace Blitz3D's 2D Image, Graphics Drawing, and Collision commands. This will allow folks to transform there 2D games into 3D with relatively small fuss.


GQ(Posted 2005) [#9]
Just some confused about some things.

When we talk about single surface 'sprites'? Are they actually image sprites or are they single surface quads/tris?

If single surface tris/quads are faster than the native blitz3d sprites, is this because the native sprites are implemented using 2D calls?
or are there other reasons why a single surface is faster than a sprite?


KuRiX(Posted 2005) [#10]
To use Single Surface you will need to use VertexCoords and sin/cos to rotate. So i don't know why this should be faster than native sprites... but everybody says so...


GQ(Posted 2005) [#11]
I'm thinking along the same lines myself. At least in theory, it seems to me that sprites should actually be
faster... unless there is something in blitzbasic that
I'm not aware of.


Ross C(Posted 2005) [#12]
Ok. Everytime you create a new sprite, it creates a new surface, because each sprite can have a different texture. Everytime renderworld is called, it's renders the world, stalling slightly between each surface (as far as i understand), which takes time. So, the less surfaces you have in your game, the better. If your using 100 odd sprites in your game, essentially it's 100 surfaces. That's a hell of alot of surfaces, for just one thing.

Now, using single surface, you have one surface, one mesh. It renders far quicker then the sprites, because theres no stalling inbetween, as it's the one surface. That the real speed up. transforming and manually rotating the quads is actually very quick. The math for one thing, is done very quickly. The biggest slowdown you'll normally experience in a game, is the graphics rendering. Shaving a milli-ultra second off by making your math formula shorter, ain't gonna help you out. :o)


KuRiX(Posted 2005) [#13]
Ok, thanks Ross c for the explanation.

If i use the copyentity, i duplicate the surfaces too?


KuRiX(Posted 2005) [#14]
Ohh, i have been making tests, and it seems like single surface is faster, but... i can't set the alpha of each quad like they were sprites!!!

Any Idea?


Gabriel(Posted 2005) [#15]
i can't set the alpha of each quad like they were sprites!!!


VertexColors has an alpha parameter.


KuRiX(Posted 2005) [#16]
I have tried it, but i can't make it work, my fault i thinks. (i set the entityfx 32 too) :(


KuRiX(Posted 2005) [#17]
WORKING! Set the entityfx to 1+2+32!!!


KuRiX(Posted 2005) [#18]
Ok, my last question!:

How can i make every quad to be always pointing the camera?


Ross C(Posted 2005) [#19]
Now that. Heh. You need to rotate the quad to the camera pitch and camera yaw variables. I believe this can be done using the tformpoint command. I used some pretty hairy maths to align mine. I'm not gonna subject you to it, but this can be done with tformpoint. I'll have a look to see if i can find the thread.


KuRiX(Posted 2005) [#20]
Yep, Resolved with TformPoint and TformVector!

Now all is Working Perfectly.

Faster than Sprites? It seems so, but now i have lot of code, with TformPoint, Math, VertexCoords! Tests Will Decide!


Ross C(Posted 2005) [#21]
Trust me, it will be miles faster. Try putting 1000 odd particles on screen. That's all the testing that should really be required :P


KuRiX(Posted 2005) [#22]
Mmm, and... if i am going to use one sprite for the HUD, then there is no need for making a mesh? Because it will use one surface too?


Ross C(Posted 2005) [#23]
Yeah, basically :o)


KuRiX(Posted 2005) [#24]
Well, then Thanks to all the people that have helped me. Now i have my own single surface lib perfectly working in my multiplayer racing ode game. (hehe, sounds great)


Techlord(Posted 2005) [#25]
Awesome discussion!


_PJ_(Posted 2005) [#26]
Yeah, this I think will help with Galactic I use a lot of sprites for both engine trails, starfields and smoke/fire. If these were combined into single surfaces, it would make things much quicker.

It runs smooth anyway, but I know it does cause a lot of slowdown which will become apparent once more of the engine calculations are inserted into the loop.