Visual artifacts while transitioning
Closed this issue · 3 comments
I noticed that if a screen contains any semi transparent sprite (i.e. having a color applied with alpha < 1) then visual artifacts will be produced while transitioning.
To reproduce this issue, you can slightly modify your TestCase, adding a line:
actor.setColor(new Color(1f, 1f, 1f, 0.5f));
somewhere inside SimpleScreen's constructor and changing another line to this:
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
inside the draw method of said actor.
I noticed that you cleverly avoided to use color.a when setting the color to the batch, but this is not a solution because it disables semi transparency for a single sprite. Moreover, Image and many other standard classes extending Actor do use color.a in their draw methods, so using any of these classes would make you prone to get the artifacts.
Hi thanks for your feedback.
You are welcome to provide a merge request, if you have a solution.
i found a way to solve the problem but is not clean enough to be merged as is, i will give you the general idea so you can consider to follow this approach for a patch:
-change ScreenTransition.render() to accept Screens instead of Textures
-remove both screenFBOs form FadingGame
-in FadingGame.render(), pass screen and nextScreen to screenTransition.render()
-now comes the ugly part: get the stage from each screen and call getRoot() on them
-in each transition modify the root as needed (e.g. root.setPosition(x, y) for a sliding transition)
-use root.draw(batch, alpha) instead of batch.draw(...)
-reset roots to original state when the transition ends
the downside of this approach is that it assumes that you use a stage, probably a better idea would be to use a FadingScreen class that exposes a custom getRootView() method and use those in FadingGame...
HI cxvii,
your solution is the default way to make sliding transitions in libgdx, and maybe some other geometrical transformations. If you want these kind of transitions, it would be an overkill to use the libgdx-transitions library, with frame buffers. They core idea of framebuffer based transitions, is that you can do more fancy effects, like slices.
Anyway, i will look into the Alpha problem, if i got time. I think it should be possible to deal with alpha and even with illumination (box2dlights) in the next release.