Changing Additive Blending when bright and setting fps

Started by
3 comments, last by RealmRPGer 18 years, 4 months ago
As is well aware, additive blending works wonders, except against bright objects. Is there any solution to this? I remember reading about a possible one about a year ago in a topic titled something like "Correct Blending Mode for Particles?" Also, my scene slows down drastically after there are about 200 objects to render. This seems a bit small, is there anything to do to speed it up / any common mistakes that are made? I'm using AllegroGL and I don't have a frame limiter (the vsync() function crashes the program).
Advertisement
There's not a whole lot of information in your post, so I'm going to have to take a few guesses at some things. It would help if you were a little bit clearer on what it is you're trying to accomplish.

First, additive blending. Its name pretty much sums up what it does. Adding two bright surfaces together will most likely overflow and give you a clamped white value. What else did you expect it to do? :D

Secondly, rendering. "200 objects" doesn't describe very much. If your objects are only two polygons, then I'd say there's something going wrong somewhere. But if your objects are 1000+ polygons, then you need to start looking into culling objects that are outside your view frustum, or if they are all visible at once, then look into using LOD to reduce the polygons for models farther away.

As for the vsync function, I haven't used AllegoGL, so I can't offer much assistance there. However, a library function that crashes is not usual, and could be the cause of improper initialization, improper use of the function, etc. Reading the docs and googling can't hurt. :)
Yeah, I know what additive blending does. I want to be able to switch my rendering method when the object is in front of a bright scene.

Oh, right, I forgot to mention that it's a 2D game. Thus, every object is a quad. So a slowdown after 200 quads...
Quote:Original post by RealmRPGer
As is well aware, additive blending works wonders, except against bright objects. Is there any solution to this? I remember reading about a possible one about a year ago in a topic titled something like "Correct Blending Mode for Particles?"

experiment perhaps try one, one-src_color

Quote:Also, my scene slows down drastically after there are about 200 objects to render. This seems a bit small, is there anything to do to speed it up / any common mistakes that are made? I'm using AllegroGL and I don't have a frame limiter (the vsync() function crashes the program).

*use texture compression, lower quality textures, smaller texture size
*enable depth test/depthwrites
*disable blending
*make the particles have a maximum size

I tested out most of those things (texture size/object size and blending). Strange thing is, they didn't seem to make ANY difference. So I'm guessing there's one big thing that's slowing it down, but I can't figure out what.

Currently I'm storing the objects in an STL Vector and looping through them to draw. The Allegro Texture (which is just an unsigned int) is stored seperately, and the object references that. Other than that, I don't know.
Oh, I use gl_begin and gl_end for every sprite loop. Actually, I do most things for every loop. Bind the textures (you have to, though, don't you?), enable texture2D (unnecessary), etc.

I can't figure it out, and it's really beginning to eat away at me.

Edit: Turns out, the physics engine was the cause for most problems. I can now get 1000 quads / sprites without slowdown. This seems about reasonable, but my computer is quite new (GeForce 6800, 3.2gHZ P4, 1024mb RAM). What kind of numbers should I be expecting?
I'm running a full scene of 82 quads. Only two are "big" background objects (widescreen 1024x576), the rest are about 64x64. I then continuously add objects of size 32x16 to the scene to get the total count. I figure this is a reasonable way to estimate, considering most of the objects will be pieces from a particle system.

[Edited by - RealmRPGer on November 28, 2005 8:13:07 AM]

This topic is closed to new replies.

Advertisement