Casper Beyer Casper Beyer - 6 months ago 39
HTML Question

Are CSS shaders applicable to 2d canvas?

So we have fragment shaders in the form of CSS shaders, are these applicable to 2d canvas drawing as-well?


Only to the canvas element itself, so whatever is drawn to canvas will be affected visually.

You cannot use them to process directly what you draw using the context - context is isolated to only work on the bitmap itself while CSS is limited to work on the element(s) (you could always emulate what they're doing though).

As a sidenote: there is a new filter property for the context being considered for the standard, which can take CSS filter and apply it to the context. If accepted into the standard it may be possible to use CSS shaders with context directly too - it is currently only supported in Firefox hidden behind flags. If it goes prime-time, only time will show..