direct.filter.CommonFilters

from direct.filter.CommonFilters import CommonFilters, FilterConfig

Class CommonFilters implements certain common image postprocessing filters. See the Common Image Filters page for more information about how to use these filters.

It is not ideal that these filters are all included in a single monolithic module. Unfortunately, when you want to apply two filters at the same time, you have to compose them into a single shader, and the composition process isn’t simply a question of concatenating them: you have to somehow make them work together. I suspect that there exists some fairly simple framework that would make this automatable. However, until I write some more filters myself, I won’t know what that framework is. Until then, I’ll settle for this clunky approach. - Josh

Inheritance diagram

Inheritance diagram of direct.filter.CommonFilters

class CommonFilters(win, cam)[source]

Bases: object

Class CommonFilters implements certain common image postprocessing filters. The constructor requires a filter builder as a parameter.

__init__(self, win, cam)[source]
cleanup(self)[source]
delAmbientOcclusion(self)[source]
delBloom(self)[source]
delBlurSharpen(self)[source]
delCartoonInk(self)[source]
delExposureAdjust(self)[source]
delGammaAdjust(self)[source]
delHalfPixelShift(self)[source]
delHighDynamicRange(self)[source]
delInverted(self)[source]
delSrgbEncode(self)[source]

Reverses the effects of setSrgbEncode.

delViewGlow(self)[source]
delVolumetricLighting(self)[source]
reconfigure(self, fullrebuild, changed)[source]

Reconfigure is called whenever any configuration change is made.

setAmbientOcclusion(self, numsamples=16, radius=0.05, amount=2.0, strength=0.01, falloff=2e-06)[source]
setBloom(self, blend=(0.3, 0.4, 0.3, 0.0), mintrigger=0.6, maxtrigger=1.0, desat=0.6, intensity=1.0, size='medium')[source]
setBlurSharpen(self, amount=0.0)[source]

Enables the blur/sharpen filter. If the ‘amount’ parameter is 1.0, it will not have effect. A value of 0.0 means fully blurred, and a value higher than 1.0 sharpens the image.

setCartoonInk(self, separation=1, color=(0, 0, 0, 1))[source]
setExposureAdjust(self, stops)[source]

Sets a relative exposure adjustment to multiply with the result of rendering the scene, in stops. A value of 0 means no adjustment, a positive value will result in a brighter image. Useful in conjunction with HDR, see setHighDynamicRange.

New in version 1.10.7.

setGammaAdjust(self, gamma)[source]

Applies additional gamma correction to the image. 1.0 = no correction.

setHalfPixelShift(self)[source]
setHighDynamicRange(self)[source]

Enables HDR rendering by using a floating-point framebuffer, disabling color clamping on the main scene, and applying a tone map operator (ACES).

It may also be necessary to use setExposureAdjust to perform exposure compensation on the scene, depending on the lighting intensity.

New in version 1.10.7.

setInverted(self)[source]
setSrgbEncode(self, force=False)[source]

Applies the inverse sRGB EOTF to the output, unless the window already has an sRGB framebuffer, in which case this filter refuses to apply, to prevent accidental double-application.

Set the force argument to True to force it to be applied in all cases.

New in version 1.10.7.

setViewGlow(self)[source]
setVolumetricLighting(self, caster, numsamples=32, density=5.0, decay=0.1, exposure=0.1, source='color')[source]
update(self, task=None)[source]

Updates the shader inputs that need to be updated every frame. Normally, you shouldn’t call this, it’s being called in a task.

class FilterConfig[source]

Bases: object