some notes about volumetric glow

Started by RemiD, December 23, 2018, 10:07:04

Previous topic - Next topic

RemiD

Hi,

some notes about volumetric glow (with pushed out layers with variable alpha), what i have found after many experiments :
->the base shape (the glowing shape) must be fullbright with a "base color"
->each glowinglayer is made by copying the base shape (welded) and using each vertex normal to push out the vertex of the layer. (you can't simply scale up the shape, it will not work with complex shape)
->each glow layer must have a variable alpha ( the inner layer has the more alpha / more opacity, the outer layer has the less alpha / more transparency, my formula is LA = 1.0-(1.0/(Layers+1)*L )
->each glow layer must have a variation (percentage) of the base color, because since each outer layer will blend with each other inner layer, there will be an increase / saturation of the final color and if you still want to distinguish the base shape, you don't want too much high "blending" ( my formula is LR = Float(R*2)/Layers : LG = Float(G*2)/Layers : LB = Float(B*2)/Layers )
->to optimize rendering, i use one surface one material for the base shape (the glowing shape), and one surface one material for the glowing layers
->the alpha and color of each layer are set using vertices colors ( so that there is only one surface one material for all layers )
->material blendmode of the base shape is "alpha"
->material blendmode of the glowinglayers is "add"
->you don't need to add many glowinglayers, here i use only 6, instead of adding more glowinglayers, you can simply add more space between each layer...

here are 2 examples :

here the glowing layers go up to 255, so there is too much "saturation" and the base shape is difficult to see :
http://rd-stuff.fr/blitz3d/glow-with-pushed-out-layers-with-variable-alpha-255.png

here the glowing layers go up to 128, so there is moderate "saturation" and the base shape can be seen :
http://rd-stuff.fr/blitz3d/glow-with-pushed-out-layers-with-variable-alpha-128.png

you can add a flickering effect simply by varying randomly the color the base shape and of the glowing layers ( my formula is : Coef# = rnd(0.9/1.1) : newR = initialR*Coef : newG = initialG*Coef : newB = initialB*Coef )

woaw, nice ! 8)

MagosDomina

Finally found this thread.  8)

I think this will work great for static objects but I see your note about complex shapes, are we talking high triangle count here or actually hard angled vertexes?

RemiD

#2
when i say "static shapes", i mean not rigged not skinned not animated shapes.

let me clarify :
not rigged not skinned not animated : the position of the vertices of the initial shape never change (examples : a light bulb, a neon, the lights of a vehicle, a sword, a gun, a backpack, a screen, lava, ...)

rigged skinned animated : the position of the vertices of the initial shape change depending on the rotation position of the joints ("bones") or depending on a procedure which "animates" the shape. (examples : animated humanoids / animals with a skin and clothes, a ball which changes its shape when it rebounds)

but you can also use this glow effect on rigged skinned animated shapes, with a workaround (already coded, it works well and is fast enough as long as your rigged skinned animated shapes are not too high tris and never altered (never add/remove vertices), because the idea is to use the index of each vertex of a rigged skinned animated mesh, to re-shape (re-position the vertices) of a never changing shape)


volumetric glow is usable for complex shapes (=the shape does not need to be symetrical) but preferably low details shapes, because you need at least 1 fullbright shape + 6 glow layers, for each glowing shape, so in total it is the same shape (verticescount + trianglescount) * 6 (but of course the effect needs only 1mesh and 2surfaces or 2 meshes and 2surfaces)

to decrease render time, a simple approach would be to only display the glowing layers of the shapes which are in near enough and in the camera fov, and for far way shapes, only display the fullbright shape (not the glowing layers).


anyway i will probably post these procedures in the code archives soon, because i don't plan to earn money by making games, i just want to finish a demo...