Return to the Change Log index.
We have decided to bundle a selection of highly flexible special effect shaders in to Phaser 3.60 and provide access to them via an easy to use set of API calls. The FX included are:
sepia
, greyscale
, lsd
and lots more.What's more, the FX can be stacked up. You could add, for example, a Barrel
followed by a Blur
and then topped-off with a Circle
effect. Just by adjusting the ordering you can achieve some incredible and unique effects, very quickly.
We've worked hard to make the API as easy to use as possible, too. No more messing with pipelines or importing plugins. You can simply do:
const player = this.add.sprite(x, y, texture);
player.preFX.addGlow(0xff0000, 32);
This will add a 32 pixel red glow around the player
Sprite.
Each effect returns a new FX Controller instance, allowing you to easily adjust the special effects in real-time via your own code, tweens and similar:
const fx = container.postFX.addWipe();
this.tweens.add({
targets: fx,
progress: 1
});
This will add a Wipe Effect to a Container instance and then tween its progress value from 0 to 1, causing the wipe to play out.
All texture-based Game Objects have access to Pre FX
(so that includes Images, Sprites, TileSprites, Text, RenderTexture and Video). However, all Game Objects have access to Post FX
, as do cameras. The difference is just when the effect is applied. For a 'pre' effect, it is applied before the Game Object is drawn. For a 'post' effect, it's applied after it has been drawn. All of the same effects are available to both.
this.cameras.main.postFX.addTiltShift();
For example, this will apply a Tilt Shift effect to everything being rendered by the Camera. Which is a much faster way of doing it than applying the same effect to every child in a Scene. You can also apply them to Containers, allowing more fine-grained control over the display.
The full list of new methods are as follows:
Available only to texture-based Game Objects:
GameObject.preFX
an instance of the FX Controller, which allows you to add and remove Pre FX from the Game Object. It features methods such as add
, remove
and clear
. Plus the following:
GameObject.preFX.addGlow
adds a Glow Pre FX effect to the Game Object.
GameObject.preFX.addShadow
adds a Shadow Pre FX effect to the Game Object.
GameObject.preFX.addPixelate
adds a Pixelate Pre FX effect to the Game Object.
GameObject.preFX.addVignette
adds a Vignette Pre FX effect to the Game Object.
GameObject.preFX.addShine
adds a Shine Pre FX effect to the Game Object.
GameObject.preFX.addBlur
adds a Blur Pre FX effect to the Game Object.
GameObject.preFX.addGradient
adds a Gradient Pre FX effect to the Game Object.
GameObject.preFX.addBloom
adds a Bloom Pre FX effect to the Game Object.
GameObject.preFX.addColorMatrix
adds a ColorMatrix Pre FX effect to the Game Object.
GameObject.preFX.addCircle
adds a Circle Pre FX effect to the Game Object.
GameObject.preFX.addBarrel
adds a Barrel Pre FX effect to the Game Object.
GameObject.preFX.addDisplacement
adds a Displacement Pre FX effect to the Game Object.
GameObject.preFX.addWipe
adds a Wipe Pre FX effect to the Game Object.
GameObject.preFX.addReveal
adds a Reveal Pre FX effect to the Game Object.
GameObject.preFX.addBokeh
adds a Bokeh Pre FX effect to the Game Object.
GameObject.preFX.addTiltShift
adds a TiltShift Pre FX effect to the Game Object.
Available to all Game Objects:
GameObject.clearFX
removes both Pre and Post FX from the Game Object.
GameObject.postFX
an instance of the FX Controller, which allows you to add and remove Post FX from the Game Object. It features methods such as add
, remove
and clear
. Plus the following:
GameObject.postFX.addGlow
adds a Glow Post FX effect to the Game Object.
GameObject.postFX.addShadow
adds a Shadow Post FX effect to the Game Object.
GameObject.postFX.addPixelate
adds a Pixelate Post FX effect to the Game Object.
GameObject.postFX.addVignette
adds a Vignette Post FX effect to the Game Object.
GameObject.postFX.addShine
adds a Shine Post FX effect to the Game Object.
GameObject.postFX.addBlur
adds a Blur Post FX effect to the Game Object.
GameObject.postFX.addGradient
adds a Gradient Post FX effect to the Game Object.
GameObject.postFX.addBloom
adds a Bloom Post FX effect to the Game Object.
GameObject.postFX.addColorMatrix
adds a ColorMatrix Post FX effect to the Game Object.
GameObject.postFX.addCircle
adds a Circle Post FX effect to the Game Object.
GameObject.postFX.addBarrel
adds a Barrel Post FX effect to the Game Object.
GameObject.postFX.addDisplacement
adds a Displacement Post FX effect to the Game Object.
GameObject.postFX.addWipe
adds a Wipe Post FX effect to the Game Object.
GameObject.postFX.addReveal
adds a Reveal Post FX effect to the Game Object.
GameObject.postFX.addBokeh
adds a Bokeh Post FX effect to the Game Object.
GameObject.postFX.addTiltShift
adds a TiltShift Post FX effect to the Game Object.
renderTargets
in a WebGL Pipeline config, you can now set optional width
and height
properties, which will create a Render Target of that exact size, ignoring the scale
value (if also given).WebGLPipeline.isPreFX
is a new boolean property that defines if the pipeline is a Sprite FX Pipeline, or not. The default is false
.GameObjects.Components.FX
is a new component that provides access to FX specific properties and methods. The Image and Sprite Game Objects have this component by default.fxPadding
and its related method setFXPadding
allow you to set extra padding to be added to the texture the Game Object renders with. This is especially useful for Pre FX shaders that modify the sprite beyond its bounds, such as glow or shadow effects.WebGLPipeline.setShader
method has a new optional parameter buffer
that allows you to set the vertex buffer to be bound before the shader is activated.WebGLPipeline.setVertexBuffer
method has a new optional parameter buffer
that allows you to set the vertex buffer to be bound if you don't want to bind the default one.WebGLRenderer.createTextureFromSource
method has a new optional boolean parameter forceClamp
that will for the clamp wrapping mode even if the texture is a power-of-two.RenderTarget
will now automatically set the wrapping mode to clamp.WebGLPipeline.flipProjectionMatrix
is a new method that allows you to flip the y and bottom projection matrix values via a parameter.PipelineManager.renderTargets
is a new property that holds an array of RenderTarget
objects that all PreFX
pipelines can share, to keep texture memory as low as possible.PipelineManager.maxDimension
is a new property that holds the largest possible target dimension.PipelineManager.frameInc
is a new property that holds the amount the RenderTarget
s will increase in size in each iteration. The default value is 32, meaning it will create targets of size 32, 64, 96, etc. You can control this via the pipeline config object.PipelineManager.targetIndex
is a new property that holds the internal target array offset index. Treat it as read-only.RenderTarget
objects during its boot
method. These are sized incrementally from 32px and up (use the frameInc
value to alter this). These targets are shared by all Sprite FX Pipelines.PipelineManager.getRenderTarget
is a new method that will return the a RenderTarget
that best fits the dimensions given. This is typically called by Pre FX Pipelines, rather than directly.PipelineManager.getSwapRenderTarget
is a new method that will return a 'swap' RenderTarget
that matches the size of the main target. This is called by Pre FX pipelines and not typically called directly.PipelineManager.getAltSwapRenderTarget
is a new method that will return a 'alternative swap' RenderTarget
that matches the size of the main target. This is called by Pre FX pipelines and not typically called directly.WebGLPipeline.setTime
method has a new optional parameter shader
, which allows you to control the shader on which the time value is set.#define SHADER_NAME
to the start of your shader then it will be picked up as the WebGLShader
name during the setShadersFromConfig
process within WebGLPipeline
.setPostPipeline
on a Game Object will now pass the pipelineData
configuration object (if provided) to the pipeline instance being created.PipelineManager.getPostPipeline
now has an optional 3rd parameter, a config
object that is passed to the pipeline instance in its constructor, which can be used by the pipeline during its set-up.Return to the Change Log index.
📖 Read the Phaser 3 API Docs 💻 Browse 2000+ Code Examples 🤝 Join the awesome Phaser Discord
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )