简体   繁体   English

Pixi.js中的渐进式过滤

[英]Progressive Filtering in Pixi.js

I have an image in Pixi.js, and I want to apply a filter to it. 我在Pixi.js中有一张图片,我想对其应用过滤器。 This is simple enough, but I want the filter to actually change the image, so that the next frame, what is rendered is a filtered filtered image, and so on. 这很简单,但是我希望过滤器实际更改图像,以便下一帧呈现的是经过过滤的过滤图像,依此类推。 How do I create a Pixi object that renders to itself every frame? 如何创建一个在每一帧都呈现给自己的Pixi对象?

I found this , which seems to be asking a similar question, but I cannot make sense of the code provided or the responses. 我发现了这个问题 ,似乎是在问类似的问题,但是我无法理解所提供的代码或响应。

Try using the PIXI.RenderTexture class to create an in-memory image and render to it what you want. 尝试使用PIXI.RenderTexture类创建内存中图像并将其渲染为所需的图像。 The render texture will preserve what you've rendered previously. 渲染纹理将保留您先前渲染的内容。

Here is an example that does that: http://pixijs.io/examples/#/demos/render-texture-demo.js 这是一个执行此操作的示例: http : //pixijs.io/examples/#/demos/render-texture-demo.js

Here are the docs: http://pixijs.download/release/docs/PIXI.RenderTexture.html 这里是文档: http : //pixijs.download/release/docs/PIXI.RenderTexture.html

Note: To preserve contents when rendering to a texture you need to tell PIXI to not to clear the texture before rendering to it. 注意:要在渲染到纹理时保留内容,您需要告诉PIXI在渲染到纹理之前不要清除纹理。 The below line is from the linked example and the false value does just that: 下面的行来自链接的示例,而false值仅用于执行此操作:

...
app.renderer.render(app.stage, renderTexture2, false);
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM