Author Topic: OpenGL optimization techniques  (Read 8019 times)

sfx1999

  • *
  • Posts: 1142
    • View Profile
OpenGL optimization techniques
« on: 2004-12-10 00:03:36 »
I was wondering if anyone would like to share there OpenGL optimization techniques?

I will share one:

Scissor testing portals and lights:

Whenever you use per pixel lighting and/or portals, you can do this. There may be a problem scissor testing portals and lights, though. You can project the boundaries of lights and portals into screen space, and then use scissor testing to eliminate polygons from ever going to be depth tested.

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
OpenGL optimization techniques
« Reply #1 on: 2004-12-11 13:27:44 »
I'm programming with OpenGl for some time, but I wasn't using any optimalization techniques, they were of no use on so basic aplications. Are you developing some 3d FPS game engine ?

sfx1999

  • *
  • Posts: 1142
    • View Profile
OpenGL optimization techniques
« Reply #2 on: 2004-12-11 13:54:24 »
No, but I would like to know them if I ever do.

Right now, I am trying to do something with Quake, but the outcome isn't looking to bright.

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
OpenGL optimization techniques
« Reply #3 on: 2004-12-12 18:04:17 »
Search the internet. There have to be lots of those described out there. I'd suggest trying www.gamedev.net

If I would be developing 3d game I would use portals (or how is it called) ...  on level loading (or even sooner) splitting levels into groups of rooms, and defining which rooms can you see from each room .... at the draw time you can remove ones you cannot see. This should speedup engine alot.

Then also you dont have to draw polygons that are behind your back.

sfx1999

  • *
  • Posts: 1142
    • View Profile
OpenGL optimization techniques
« Reply #4 on: 2004-12-12 19:16:31 »
You might not have to draw objects behind your back, but you will probably need to draw their shadows.

Anyway, does anyone know how to do the fatboy effect (like in Unreal)?

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
OpenGL optimization techniques
« Reply #5 on: 2004-12-13 09:17:57 »
Quote from: Anyway, does anyone know how to do the fatboy effect (like in Unreal)?

Well yea, it could be done either by multiplying x & y coords of the model, or to first calculate normals of model faces, and then to move face vertices in the normal direction by some amount. 2nd one would look better, and I think that's the way they done it in UT.

Micky

  • *
  • Posts: 300
    • View Profile
OpenGL optimization techniques
« Reply #6 on: 2004-12-13 14:58:50 »
Quote from: sfx1999
Anyway, does anyone know how to do the fatboy effect (like in Unreal)?

I haven't got unreal, but from mirex description I'd guess it displays a normal proportioned model like an overweight model, doesn't it?

I'd guess they just put a scale onto the root joint of the sceleton. If they have soft skinning then this will only apply to the body, and it will be blended out towards the limbs automatically.

Phantasy star online has this effect as well when you create a character.

You could experiment yourself with some modellng software, after you've skinned your mesh try to scale the skeleton.

sfx1999

  • *
  • Posts: 1142
    • View Profile
OpenGL optimization techniques
« Reply #7 on: 2004-12-13 19:15:23 »
Well, the fatboy effect is also used to make a glowing shell around players, so that is one of the reasons I need to know.

Anyway, I think most model formats have the normals stored already, but wouldn't this method you have described create broken polygons?

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
OpenGL optimization techniques
« Reply #8 on: 2004-12-14 07:43:13 »
Quote
but wouldn't this method you have described create broken polygons?
No, you will move only vertices of each polygon so no gaps will be present.

Also in the game Oni there is a shield around creatures, and i'd say its done this way: Creature consists from many body parts, and each body parts vertices are premultiplied to make the body parts larger and taken as coords for the shield ( for example with 1.2 multiplier )

See Oni character with shield here: http://oni.mypage.sk/Done/gallery/Bio_lab.jpg

By the way I'd like to know how was this one done ... http://oni.mypage.sk/Done/gallery/wonderkonoko.jpg
 ... the glow moves with the character and character is leaving trails of movement everywhere ... was it bitmap bilboarding for the glows and some transparent trail-polygons for the movement ?

Or this one http://oni.mypage.sk/Done/gallery/NRG_rush.jpg or this http://oni.mypage.sk/Done/dodger.jpg

sfx1999

  • *
  • Posts: 1142
    • View Profile
OpenGL optimization techniques
« Reply #9 on: 2004-12-14 22:42:26 »
Trails are done by a number of things. Sometimes they are models stitched together, and other times they are sprites sticthed together.

The glowing effect seems to be done bu using billboards in a blending mode that adds to the color of existing polygons. I don't know how it is done exactly, but I think you would set it like this:

Code: [Select]
glBlendFunc((GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
OpenGL optimization techniques
« Reply #10 on: 2004-12-16 13:37:30 »
Yes but how would you program model to leave those trails / shadows (http://oni.mypage.sk/Done/dodger.jpg) ?

Qhimm

  • Founder
  • *
  • Posts: 1996
    • View Profile
    • Qhimm.com
OpenGL optimization techniques
« Reply #11 on: 2004-12-16 14:55:38 »
Well you can render the glows separately and using the accumulation buffer...

sfx1999

  • *
  • Posts: 1142
    • View Profile
OpenGL optimization techniques
« Reply #12 on: 2004-12-17 03:43:20 »
You would make a billboard and stitch them together. You would use a different blend function, though.

Your texture would have an alpha channel, and a line of smoke on it.

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
OpenGL optimization techniques
« Reply #13 on: 2004-12-17 06:43:08 »
Well cannot be done by billboarding, because all trails / shadows are fully 3d

Qhimm

  • Founder
  • *
  • Posts: 1996
    • View Profile
    • Qhimm.com
OpenGL optimization techniques
« Reply #14 on: 2004-12-17 06:49:50 »
Quote from: mirex
Well cannot be done by billboarding, because all trails / shadows are fully 3d

Which is sort of ironic, seeing as at least 'trails' are usually an optic effect in the eye/camera (thus 2D) and only in special cases actually 3D (like fire or glowing gas).

Well, already having forgotten how the trails looked, I suppose you could have a small polygonal shape (maybe just a particle) for the glow which is then cloned and distributed between the individual points of the model skeleton every frame of animation... The brute-force but arguably popular way of doing 'trails', just look at every game where slashing your sword leaves a mid-air 'trail'.

Micky

  • *
  • Posts: 300
    • View Profile
OpenGL optimization techniques
« Reply #15 on: 2004-12-17 10:51:40 »
Quote from: Qhimm
Well, already having forgotten how the trails looked, I suppose you could have a small polygonal shape (maybe just a particle) for the glow which is then cloned and distributed between the individual points of the model skeleton every frame of animation... The brute-force but arguably popular way of doing 'trails', just look at every game where slashing your sword leaves a mid-air 'trail'.

I read a post from the programmer of one of the Blade games, IIRC they were doing exactly that, they are drawing a triangle strip for the sword trail.
Alternate ways are to capture the framebuffer, scale it, and add it to the next frame. I think the accumulation buffer is not supported in hardware on many boards anymore, but you can use floating point framebuffers as a replacement.

sfx1999

  • *
  • Posts: 1142
    • View Profile
OpenGL optimization techniques
« Reply #16 on: 2004-12-17 18:32:51 »
I think I got it. Draw a bunch of sprites, but lock them around where the trail should be. That way, when you look at it, it wll face you, but still be correct.