Interface ScreenEffect
- All Known Implementing Classes:
ScreenEffectImpl
public interface ScreenEffect
A full-screen post-processing effect, made with
ScreenEffects.register(net.minecraft.resources.ResourceLocation, net.minecraft.resources.ResourceLocation). Effects start disabled; any number
can be active at once, drawn within their scope in layer order.
An effect's drawn strength, from 0 to 1, is the product of:
- its fade, which eases towards 1 while enabled and towards 0 while disabled;
- its manual strength, 1 unless changed;
- its strength function, if it has one.
Strength from
#moj_import <coolcatcanvas:screen_effect.glsl>, and should scale their work by it; autoBlend(boolean) does that
for shaders that don't.
Durations are in ticks of real time (20 per second), so effects keep animating while the game is paused. Only use an effect from the render thread.
-
Method Summary
Modifier and TypeMethodDescriptionactiveWhen(@Nullable Predicate<EffectContext> condition) Enables the effect when the condition starts holding and disables it when it stops, checked every frame.animateStrength(float target, int ticks, Easing easing) Moves the manual strength totargetoverticks.autoBlend(boolean autoBlend) Blends the effect's output with the unprocessed image by its strength, so any shader fades smoothly, including vanilla-style ones that ignoreStrength.default ScreenEffectbindUniform(String name, EffectUniform.FloatBinding binding) default ScreenEffectbindUniform(String name, EffectUniform.VectorBinding binding) @Nullable net.minecraft.resources.ResourceLocationThe post chain JSON it's loaded from (shaders/post/<path>.json), or null for a definition built in code.@Nullable net.minecraft.network.chat.ComponentA line or two shown in the effects screen, or null.description(@Nullable net.minecraft.network.chat.Component description) disable()Fades out.Hides the effect right away, skipping the fade-out.net.minecraft.network.chat.ComponentThe name shown in the effects screen: by defaultscreen_effect.<namespace>.<path>, else the path.displayName(net.minecraft.network.chat.Component name) enable()Fades in, or keeps the effect on if it's already.enableFor(int ticks) Fades in, stays forticks, then fades out: a flash, a pulse, a hit.Shows the effect at full fade right away, skipping the fade-in.@Nullable Stringerror()Why it failed to load or draw, if it did.default ScreenEffectfade(int ticks) How it fades in and out.net.minecraft.resources.ResourceLocationid()booleanWhether it has anactiveWhen(java.util.function.Predicate<net.ixdarklord.coolcatcanvas.api.client.effect.EffectContext>)condition deciding when it's on.booleanWhether it's enabled; it may still be fading in.booleanisLoaded()Whether its shaders compiled and it can be drawn.booleanWhether players can turn it on and off from the effects screen, where their choice is remembered.booleanWhether it's drawn this frame: enabled or still fading out, with a strength above 0.onFrame(@Nullable Consumer<EffectContext> callback) Runs every frame before drawing, while the effect is visible: a place to drive uniforms.intpriority()priority(int priority) Where the effect starts in the layer order: lower priorities are drawn first, so later effects process their output.Resets every uniform to its definition's default.scope()scope(ScreenEffectScope scope) Where in the frame it's drawn.selectable(boolean selectable) default ScreenEffectsetEnabled(boolean enabled) setStrength(float strength) Sets the manual strength, clamped to[0, 1].default ScreenEffectsetUniform(String name, float... values) default ScreenEffectsetUniformInt(String name, int... values) floatstrength()The strength the effect is drawn with this frame.strength(@Nullable EffectContext.StrengthFunction function) Scales the strength by a function of the frame, clamped to[0, 1]; null to stop.default ScreenEffecttoggle()The uniform namednamein any of its passes' programs.
-
Method Details
-
id
net.minecraft.resources.ResourceLocation id() -
definitionId
@Nullable @Nullable net.minecraft.resources.ResourceLocation definitionId()The post chain JSON it's loaded from (shaders/post/<path>.json), or null for a definition built in code. -
displayName
net.minecraft.network.chat.Component displayName()The name shown in the effects screen: by defaultscreen_effect.<namespace>.<path>, else the path. -
displayName
-
description
@Nullable @Nullable net.minecraft.network.chat.Component description()A line or two shown in the effects screen, or null. -
description
-
isSelectable
boolean isSelectable()Whether players can turn it on and off from the effects screen, where their choice is remembered. True by default; turn it off for effects the mod drives on its own (an effect with anactiveWhen(java.util.function.Predicate<net.ixdarklord.coolcatcanvas.api.client.effect.EffectContext>)condition is listed but can't be toggled there). -
selectable
-
scope
ScreenEffectScope scope() -
scope
Where in the frame it's drawn. Defaults toScreenEffectScope.WORLD. -
priority
int priority() -
priority
Where the effect starts in the layer order: lower priorities are drawn first, so later effects process their output. Defaults to 0. Once the order is rearranged (by code or by a player), it's kept untilScreenEffectLayers.resetOrder(). -
isAutomatic
boolean isAutomatic()Whether it has anactiveWhen(java.util.function.Predicate<net.ixdarklord.coolcatcanvas.api.client.effect.EffectContext>)condition deciding when it's on. -
fade
How it fades in and out. Both default to 10 ticks withEasing.SINE_IN_OUT. -
fade
-
autoBlend
Blends the effect's output with the unprocessed image by its strength, so any shader fades smoothly, including vanilla-style ones that ignoreStrength. Costs three extra full-screen copies. Off by default. -
activeWhen
Enables the effect when the condition starts holding and disables it when it stops, checked every frame. In between, the effect can still be toggled by hand (or vetoed throughScreenEffectEvents.BEFORE_TOGGLE), and stays so until the condition changes again. Pass null to stop. -
strength
Scales the strength by a function of the frame, clamped to[0, 1]; null to stop. -
onFrame
Runs every frame before drawing, while the effect is visible: a place to drive uniforms. -
enable
ScreenEffect enable()Fades in, or keeps the effect on if it's already. Cancels a pendingenableFor(int)timeout. -
disable
ScreenEffect disable()Fades out. -
setEnabled
-
toggle
-
enableFor
Fades in, stays forticks, then fades out: a flash, a pulse, a hit. -
enableInstantly
ScreenEffect enableInstantly()Shows the effect at full fade right away, skipping the fade-in. -
disableInstantly
ScreenEffect disableInstantly()Hides the effect right away, skipping the fade-out. -
isEnabled
boolean isEnabled()Whether it's enabled; it may still be fading in. -
isVisible
boolean isVisible()Whether it's drawn this frame: enabled or still fading out, with a strength above 0. -
setStrength
Sets the manual strength, clamped to[0, 1]. -
animateStrength
Moves the manual strength totargetoverticks. -
strength
float strength()The strength the effect is drawn with this frame. -
uniform
The uniform namednamein any of its passes' programs. -
setUniform
-
setUniformInt
-
bindUniform
-
bindUniform
-
resetUniforms
ScreenEffect resetUniforms()Resets every uniform to its definition's default. -
isLoaded
boolean isLoaded()Whether its shaders compiled and it can be drawn. False until the first resource load, and after errors. -
error
Why it failed to load or draw, if it did. Fixed by a resource reload.
-