Love this kind of effects, can't tell if it's a good design choice performance wise

Hey people,

I was toying around in blender internal, and I made this thing by accident:


Ain’t it pretty? It’s just a volume material being influenced by object color, two textures playing with the alpha and face orientation set to billboard, nothing all that complex. I added in a script that moves the UVs around, you can’t see that in the picture obviously, but it makes the flames dance quite nicely. I had to struggle a bit with my own code to make sure only one instance of the same mesh could manipulate the UV coordinates at a time, but other than that, this little overnight experiment went good. I’m pretty thrilled to be honest, I used to think fire this shiney couldn’t be pulled off in the BGE without some particle system.

Anyway, just to keep up with a theme as I go along with my studying and stuff, I’d like to try out what else can be done with this formula, take a crack at smoke, clouds, halos and such, see what the limitations are. Does anyone have any knowledge on how these blender render materials could impact performance? I’m not really making anything much more detailed than a hundred vertices and the textures I use are mostly low resolution (~512-ish and 1k only for characters and important props), but you never know… lack of understanding of technicalities has bitten me in the arse before.

Do a benchmark test = test with 1, 2, 10, 100, 1000 … until your system can’t handle it anymore.

Ain’t it pretty?

looks good indeed.

Does anyone have any knowledge on how these blender render materials could impact performance?

Well, performance wise, the alpha is the biggest and heaviest of them all. But other then that if you don’t have hundreds of them it should be fine.(you can move them around when they are out of view to limit the count)

I’m not really making anything much more detailed than a hundred vertices and the textures I use are mostly low resolution (~512-ish and 1k only for characters and important props), but you never know

512 is mid range, 1024+ is high end. So low resolution is more like 128/256. But it all depends on what your target is. Pc’s older then 5 years don’t like a lot of 1024 textures to be honest, unless they have a decent graphics card.

I am also assuming that you use a lamp with it? Be careful with lamps, like above… older pc’s can handle 8 at most. So with a few fires going you need to create a light manager as well(or as said above, move them around).

lack of understanding of technicalities has bitten me in the arse before

Nothing you can do about it, at some point it will bite, it will always bite at some point!

I agree with everything Cotaks said, but I would like to add that shadow casting is also a major cost…I don’t imagine you will have the fire actually cast shadows, but it still good information.

Enable additive alpha for some more “oomph” in the fire.
But yes, scrolling textures is often better than particles for fire. This is how it is done in AAA games

You can use object color and a node material for scrolling, which avoids the overhead of updating the vertex buffer on the GPU and can improve performance, but doing so prevents material batching (but I don’t think BGE has that).

With regards to performance, the main thing to avoid is texture samples. A texture sample is easily 10-20 times slower than a “normal” operation such as adding vectors/colors/numbers. The other big limitation is sending data to the GPU. This occurs when updating armatures, shapekeys, UV, anything that changes the mesh. So if possible, pack do it on the GPU. This isn’t always possible though.
The node editor is very powerful, and you can achieve great things with it. A modern GPU is extremely powerful, and even on integrated hardware you can do a huge amount (is in calculate and deform 65,000 poly meshes in a vertex shader at 60FPS).

Shadows are the major performance hog, as for each shadow the entire scene is rendered. So yeah, don’t use shadows, or if you do, do it at the lowest possible resolution.

Many thanks to you all c:

I resized all the images (my numbers were way off, whoops!), and did some further testing this morning. Frame drops some if I have around a hundred instances on screen, but just including the fire into a scene more sparingly as I normally would doesn’t seem to be causing any trouble, so I guess all I really need is a manager for lamps, and I was planning on writing it at some point anyway, so that’s not a problem.

It’d be cool to use a less expensive method for texture scrolling though, I just don’t know any. A friend that specializes in making sprites told me I could pass GLSL code to python via string to modify the texture coordinates themselves over time rather than messing with mesh data directly; the workload is more or less the same, but it gets dumped exclusively on the GPU which could be useful if my logic starts getting more demanding. The problem is that would overwrite my shader with the default one, which is no good. Guess I’ll surf the interwebs for answers…