Custom widget light bloom?

Hello! When drawing custom widgets using nvgRect, nvgFillColor, etc, is it up to the developer to draw the light bloom, or is that done automatically somehow? Thanks!

Up to you as it is only being rendered for LightWidgets by the drawHalo function which simply draws a gradient with transparency, so it isn’t a post processing effect that works in screenspace like bloom in games and such (this would be neat though).

1 Like

LightWidget::drawHalo works well for light sources that are solid circles, but it needs to be adapted for other shapes.

For anyone interested in some examples, on my v2 branch I’ve implemented halos on ring lights, line lights, and my display backlight. The latter two are rounded rectangles (box gradients) while the ring lights are composed of two radial gradients: an outer one and an inverse inner gradient.

Once I had ring halos and line halos, I got knob-light halos for free.

Something to be aware of with box gradients in nanovg is that the specified boundary corresponds to the center of the gradient, not its outer edge.

7 Likes

There’s an issue in nanovg related to antialiasing, and it manifests in Rack if a path with a hole is drawn on layer 1.

I’m currently working around this by adding the following line to my ring halo draw functions: nvgShapeAntiAliasing(args.vg, false);

Related: