CommonFilters - some new filters, and the future

Screenshot from upcoming lens flare basic tutorial:


With the changes to CommonFilters, the minimal code needed to enable a lens flare is now:

self.filters = CommonFilters(base.win, base.cam)
self.filters.setLensFlare()

Optionally, it is possible to set parameters:

self.filters.setLensFlare(numsamples=self.numsamples, dispersal=self.dispersal,
                                  halo_width=self.halo_width,
                                  chroma_distort=(self.chroma_distort_r,
                                                  self.chroma_distort_g,
                                                  self.chroma_distort_b),
                                  threshold=self.threshold)

This includes also those parameters that were included as compile-time constants in ninth’s original code. They can be changed at any time by another call to setLensFlare(). When a compile-time parameter (which is any parameter except threshold) changes, this invokes a shader recompile automatically.

I think ninth’s original code could be included as an “advanced” tutorial.