gpt4 book ai didi

java - Slick2d 使用动画/图像抗锯齿

转载 作者:行者123 更新时间:2023-12-01 11:12:53 25 4
gpt4 key购买 nike

我使用 slick2d 渲染动画,但使用抗锯齿

如果没有 AA,运动就会不稳定,正如人们对没有 AA 的情况所期望的那样。我在游戏的 preRenderState 中打开 AA:

g.setAntiAlias(true);

这导致:

Image with graphical glitch

注意中心的对角线,可能是由两个三角形导致矩形不精确相交造成的。如何在仍然使用 AA 来平滑我的运动的同时删除它?我发现http://www.java-gaming.org/index.php?topic=27313.0但解决方案是“删除 AA”,但我不愿意这样做。

最佳答案

这看起来很可疑,因为GL_POLYGON_SMOOTH .

当您使用该(已弃用)功能时,您应该在启用混合和混合函数的情况下绘制所有不透明几何体:GL_SRC_ALPHA_SATURATE, GL_ONE 。如果不这样做,大多数轮廓上都会产生白色轮廓(基本上是锯齿边缘)。

Chapter 6 of the OpenGL Redbook states:

Now you need to blend overlapping edges appropriately. First, turn off the depth buffer so that you have control over how overlapping pixels are drawn. Then set the blending factors to GL_SRC_ALPHA_SATURATE (source) and GL_ONE (destination). With this specialized blending function, the final color is the sum of the destination color and the scaled source color; the scale factor is the smaller of either the incoming source alpha value or one minus the destination alpha value.

This means that for a pixel with a large alpha value, successive incoming pixels have little effect on the final color because one minus the destination alpha is almost zero. With this method, a pixel on the edge of a polygon might be blended eventually with the colors from another polygon that's drawn later. Finally, you need to sort all the polygons in your scene so that they're ordered from front to back before drawing them.

当他们尝试启用 GL_POLYGON_SMOOTH 时,几乎没有人能正确完成大量工作。 .

关于java - Slick2d 使用动画/图像抗锯齿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32151974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com