Comments (4)
Well, I think you're just missing one small detail...
First of all, make sure you clean up the buffers (just like in the example). While it's most likely not gonna change anything, it will definitely help to figure out at which stage the rendering goes to the wrong buffer.
// Add this to the very beginning of the render() method.
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// Put this before vfxManager.beginInputCapture()
vfxManager.cleanUpBuffers();
And then the actual problem comes to the surface - when you draw using vfxManager.renderToScreen()
you draw an opaque picture to the screen (with black background). No wonder the old data get lost.
To solve this, you need to clean up the vfxManager
buffers with transparent color. But keep in mind, that most of the built-in effects are implemented to be full-screen post effects. This means they are primarily designed to work with opaque images and output another opaque image. But I've been off the library for too long and can't remember exactly which ones are transparency compatible, and which ones are not. So you better experiment or write your own effects if you're looking for a specific image processing case.
To make buffers transparent, enable blending and use the clear color:
vfxManager.setBlendingEnabled(true);
vfxManager.cleanUpBuffers(Color.CLEAR);
Please let me know if it helps.
from gdx-vfx.
Thanks for the help. I updated my code. I think i see what you mean by "transparency compatible"
vfxManager.cleanUpBuffers();
vfxManager.setBlendingEnabled(true);
vfxManager.cleanUpBuffers(Color.CLEAR);
In the second image my map tiles are rendered now, however the effect looks quite different. Is this what you mean by "transparency compatible"? Can i mess with the SpriteBatch blending to improve the result or is something i'd have to write my own effect for in gdx_vfx?
from gdx-vfx.
Yeah, I think you'll have to play a little with how the effect output gets layered on top of the existing image to get the desired result. Luckily, in this particular case, it can be done with OpenGL blending modes and is completely outside of the gdx-vfx effect itself.
To me, the circle on the second image looks like it has premultiplied alpha qualities. It's worth trying to render it with different blending. Try to switch to the premultiplied mode before and reset the OpenGL state after rendering the effect to the screen.
// Enable PMA blending.
Gdx.gl.glBlendFunc(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
vfxManager.renderToScreen();
// Reset to non-PMA blending.
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
from gdx-vfx.
I think it's still not the same as in the image above with the black background, but it looks a little better now. In the meantime i've been writing some of my own shaders and implemented them via the default libgdx ShaderProgram class. Most of what i need i can cover with this.
Since you answered my original question about the combination of gdx_vfx and SpriteBatch rendering i'll close this issue.
Thank you very much :)
from gdx-vfx.
Related Issues (20)
- Missleading method names after refactor in sources HOT 1
- New Shader (GlItch) HOT 2
- "Noise" missing HOT 2
- Bloom Effect doesnt work properly when blend is enabled
- Error when instantiating VfxManager HOT 3
- Crash on iOS HOT 8
- crashes on macos m1 when using opengl 3.2 HOT 1
- Alternative usage HOT 4
- FXAA transparency
- Performance? HOT 1
- gdx-vfx + Viewports HOT 1
- Bloom effect creates lag on android HOT 2
- duplicate entry: gdxvfx/shaders/old-tv.frag HOT 4
- v0.5.2 build on Maven Central is broken HOT 2
- Installation fails on android HOT 2
- [EFFECT REQUEST] Earthquake Screen Shake HOT 4
- [EFFECT REQUEST] Underwater Effect HOT 1
- Alpha Support For CopyFilter HOT 1
- 3D (depth buffer enabled) support HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdx-vfx.