frame_effect¶
- class janim.items.effect.frame_effect.AppliedGroup(*items: Item, root_only: bool = False, **kwargs)¶
Bases:
ItemThe base class for classes such as
FrameEffectProvides
apply()anddiscard()methods to mark applying or removing the effect for specified items- add(*objs, prepend=False, insert=None) Self¶
- remove(*objs) Self¶
- class janim.items.effect.frame_effect.FrameEffect(*items: Item, fragment_shader: str, cache_key: str | None = None, root_only: bool = False, **kwargs)¶
Bases:
AppliedGroupApplies the passed shader
fragment_shadertoitemsBasic shader format:
#version 330 core in vec2 v_texcoord; // Input texture coordinates out vec4 f_color; // Output color #[JA_FINISH_UP_UNIFORMS] void main() { // Perform processing, for example f_color = frame_texture(v_texcoord); // Note: use frame_texture to read texture color (i.e. the rendering result of items) f_color.rgb = 1.0 - f_color.rgb; // Invert colors #[JA_FINISH_UP] }
#[JA_FINISH_UP]is a placeholder where JAnim performs additional operations, and the preceding#[JA_FINISH_UP_UNIFORMS]corresponds to itThe core of the above code is the “processing” part in
main, the rest of the code can be copied as fixed patternsIf you don’t want to copy, you can use
SimpleFrameEffect, which only requires writing the “processing” part, as it encapsulates the rest of the codeFor complete examples, refer to the corresponding code in Basic Examples
- renderer_cls¶
alias of
FrameEffectRenderer
- apply_uniforms(*, optional: bool = False, **kwargs) None¶
- dynamic_uniforms() dict¶
- class janim.items.effect.frame_effect.SimpleFrameEffect(*items: Item, shader: str, uniforms: Iterable[str] = [], cache_key: str | None = None, root_only: bool = False, **kwargs)¶
Bases:
FrameEffectSimplified wrapper for
FrameEffect, for details refer to the description inFrameEffectNote
If an error occurs in the shader code, it will be displayed as occurring in
JA_SIMPLE_FRAMEEFFECT_SHADER.