October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Cheap Bloom for a Canvas 2D Game in 8 Lines (No WebGL)

A compact Canvas 2D glow pass uses a blurred redraw of selected bright objects and composites it over the scene—no WebGL required.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can approximate bloom in a Canvas 2D game without WebGL by drawing a glow pass, blurring it, and compositing it over the scene with a lightening blend mode. Canvas 2D has no dedicated bloom operation, and the blur-based version depends on browser support for CanvasRenderingContext2D.filter; use a shadow halo instead where that feature is unavailable.

Eight-line bloom pass

Draw your scene normally, then draw the bright objects again onto a separate canvas. Blur that second pass and composite it onto the main canvas. The following is eight JavaScript lines, excluding comments, and assumes ctx is the main 2D context, glow is a same-size offscreen canvas, and drawBright draws only the objects intended to glow.

As an Amazon Associate I earn from qualifying purchases.

const g = glow.getContext("2d");
g.clearRect(0, 0, glow.width, glow.height);
drawBright(g);
ctx.save();
ctx.filter = "blur(12px)";
ctx.globalCompositeOperation = "screen";
ctx.drawImage(glow, 0, 0);
ctx.restore();

Run this after drawing the regular scene each frame. Create the offscreen canvas once rather than allocating it inside the render loop. The blur value is a visual tuning choice, not a performance measurement; adjust it for your art and test in your target browsers. The canvas dimensions and coordinate scale should match the main canvas so the glow lands in the right place.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What the pass does—and what it does not

The filter property accepts blur(), which MDN describes as a Gaussian blur; a larger blur value produces more blur. The screen composite lightens the result over the scene. These pieces create a bloom-like halo, but they do not implement a thresholded, multi-pass post-processing pipeline or automatically isolate bright pixels. You choose which objects enter the glow pass through drawBright.

#1 Best Overall
Sale
Game Programming Patterns
  • Brand New in box. The product ships with all relevant accessories

Canvas 2D’s globalCompositeOperation also includes lighter, which adds color values where shapes overlap. It can make overlapping glows more intense than screen, so try both with your palette rather than treating them as interchangeable.

Check browser support before relying on blur

MDN marks CanvasRenderingContext2D.filter as “Limited availability” and says it is not Baseline because it does not work in some widely used browsers. Check support for the browsers your game targets before making the blur pass essential. If it is unavailable, skip the filter-based pass or use the simpler shadow approach below. The API reference also recommends checking browser support: MDN: CanvasRenderingContext2D.filter.

Rank #2

Fallback: add a soft shadow halo

For a simpler glow approximation, draw selected bright shapes with Canvas 2D shadows. Set shadowColor to the glow color and shadowBlur to soften it, then reset the shadow state before drawing unrelated objects so it does not leak into later draws. This creates a per-shape halo; it is not the same as blurring and compositing a separate glow pass. See MDN’s CanvasRenderingContext2D reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose the approach that fits your render loop

Approach Compatibility note Visual control Setup
Blurred glow pass with filter MDN marks filter Limited availability; verify support for target browsers. Blur a separately drawn set of glow objects, then lighten the scene with screen or lighter. Requires a glow pass, typically on an offscreen canvas, followed by compositing.
Shadow halo Uses Canvas 2D shadow properties listed in the context reference. Produces a simpler halo around shapes as they are drawn. Set and reset shadow state around selected draws.

Neither the cited Canvas API references nor the code example establish a frame-rate cost. Measure in your own game, on its target devices and browsers, rather than assuming either method is free or too expensive. If you are considering a library instead, note that the PixiJS 7.x guide describes container filters such as blur as advanced WebGL-only features and warns that frequent filters can slow performance and increase memory use; that route does not satisfy a no-WebGL requirement, and the note is specific to the cited 7.x guide: PixiJS 7.x Containers guide.

Quick Recap

SaleBestseller No. 1
Game Programming Patterns
Game Programming Patterns
Brand New in box. The product ships with all relevant accessories
$24.95
SaleBestseller No. 2
Designing Games: A Guide to Engineering Experiences
Designing Games: A Guide to Engineering Experiences
Used Book in Good Condition
$34.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.