GL_LINES/Draw performance question

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

GL_LINES/Draw performance question

Post by AssiDragon »

Yes, yes, yes. Yet another user bugging around about 2D lines. I've been trying to search around, but the searches didn't bring anything useful up on this question (maybe it's due to the keywording :/), so I'm gonna ask it here.

How much does using GL_LINES - for ogl - or Draw(array<Vector2>, int color) - for dx - kill performance for the video cards? I'm wondering wheter to make lines using those methods, or use a brute-force-approach, and handmake textures with lines in OGRE.

Any ideas?
Hope is the first step on the road to disappointment.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

I'm using the 'billboardChain' class here, works nicely and looks like it'll be included by default later on.
http://www.ogre3d.org/phpBB2/viewtopic. ... 8881#68881
AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon »

If you tell me how to use billboard chains to make 2D lines on an overlay, I'll be more than happy to use them. ;)
Hope is the first step on the road to disappointment.
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus
Contact:

Post by SuprChikn »

A mate of mine and I were struggling with this for a game we were/are working on recently. In the end we (mostly my mate) wrote our own class to make a 2D line show up on top of everything.

We took the 3D lines example in the wiki (here I think) as a reference, and made a rectangle (creating vertices and such in code). I'm not sure if the one we used in the end took textures (one of the earlier versions did) or just a colour you want it to be.

This rectangle was placed 100 world units into the screen, and knowing the distance it was, and the FOV of the camera, doing a bit of math we could work out how big to make the rectangle in world units so that it looked like the desired length at the camera.

The function we wrote took in the desired start and end positions of the line on the screen in relative coordinates (ie: 0.0 - 1.0), and used these to work out the required length of the line/rectangle, and the angle to draw it at.

It was put in the overlay queue (or one that renders on top of it) and added as a 3d object to an overlay. Note that if you do add 3d objects to the an overlay, and you move the camera around you may notice the object jittering around a bit as the camera moves (as has been explained in other threads).
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Re: GL_LINES/Draw performance question

Post by Vectrex »

AssiDragon wrote:Yes, yes, yes. Yet another user bugging around about 2D lines. I've been trying to search around, but the searches didn't bring anything useful up on this question (maybe it's due to the keywording :/), so I'm gonna ask it here.

How much does using GL_LINES - for ogl - or Draw(array<Vector2>, int color) - for dx - kill performance for the video cards? I'm wondering wheter to make lines using those methods, or use a brute-force-approach, and handmake textures with lines in OGRE.

Any ideas?
well the small example at the bottom is all you need. I think you can add it to the overlay with the 'add3d' or something function
btw before the demo add BillboardChain* m_pBillboardChain;


// Add it to the scene
mSceneMgr->getRootSceneNode()->attachObject(m_pBillboardChain);
-> after here use the add3d() thingy

maybe see this thread
http://www.ogre3d.org/phpBB2/viewtopic. ... ay+ogreode
AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon »

Thanks for the very interesting suggestions.

That said, I wonder how would it work with multiple cameras which would have to share these lines and not interfere with each other (say, you have a sniper scope or secondary view panel - you wouldn't want to see both the lines used in the scope's GUI and the main GUI in any of the views); if I use 3D objects moving relative to the camera nodes this could be a problem.

With add3D there is no such problem, but this jittering is... weird. Maybe it's just my PC but at large movements the jittering gets pretty bad (or I'm just picky).

I think I will just make textures of the 2D primitives in MSPaint, and play around with rotating/resizing them.
Hope is the first step on the road to disappointment.
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus
Contact:

Post by SuprChikn »

I think the jittering is because the 3D object attached to the overlay is one frame behind the camera movement, and so the faster you move the more you will notice it (and more again at lower frame rates).
This has been discussed in another thread somewhere, and the only real solution suggested was to not add the object to the overlay, but rather have it in the normal scene (but in the overlay render queue), and manually update its possition to match the camera, so that relative to the camera it never moves.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

the link I posted has discussion about how to fix this. It's further down
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus
Contact:

Post by SuprChikn »

Yeah, that's the thread I was talking about.
I probably should have clicked your link to see that we were talking about the same thing :)
AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon »

If I move those things relative to the camera, is there a way to make the other cameras not see them? As I said above, rendering these things into other - wrong -viewports wouldn't be a good thing.

Vectrex, that thread doesn't say how to fix add3D - it simply states the other method I also knew of. ;)
Hope is the first step on the road to disappointment.
Post Reply