Open davjhan opened 9 months ago
I believe we might have like a boolean in the RenderContext providing a smoothing, and then make the one from the view also nullable Boolean.
Then at each view we can do something like view.smoothing ?: context.smoothing
to determine how to render it.
In any case, if you are making a pixel art game, have you considered having a PixelatedScene with a lower resolution, so it is pixel perfect, and then let the engine scale it? If you are doing pixel perfect, smoothing might work for you?
BTW: That circle looks like blurred when smoothed, but that's a separate issue, probably related to SDFs and retina. Probably this https://github.com/korlibs/korge/issues/2116
RE: PixelatedScene
I didn't know this was a thing! I just tried it, and here's what it looks like to render on a virtualSize 1/4 the windowSize:
suspend fun main() = Korge(
virtualSize = Size(128, 128),
windowSize = Size(512, 512),
backgroundColor = Colors["#ffffff"]
) {
val sceneContainer = sceneContainer()
sceneContainer.changeTo({ MyScene() })
}
class MyScene : PixelatedScene(
sceneWidth = 128,
sceneHeight = 128,
) {
override suspend fun SContainer.sceneMain() {
circle(30, fill = Colors.BLUE)
}
}
As you can see, there still is anti-aliasing applied near the curves of the circle. Some devs may like this look, but if one wants to turn it off, they'll have to do set the antialiased = false
on each view, much like with smothing
. Ideally, this is also a a configurable setting on PixelScene.
circle(30, fill = Colors.BLUE){
antialiased = false
}
Regardless, I think this feature request still stands, as some developers may prefer the visual style where all sprites are pixel graphics, but positions can be floats, and pixels can be rotated (e.g. Terraria or Vampire Survivors)
About
Korge's image and shape rendering output is outstanding, and so is the API interface for graphics. However, I find myself always setting
smoothing = false
on all my Views. Especially on a game with pixel art.Ask: Can we add, at the Container, Stage, Scene, or App level, a configuration to disable all anti-aliasing by default?.
According to the docs,
Setup:
quality = GameWindowQuality.QUALITY
With
smoothing = true
(default)With
smoothing = false
As you can see, "false" is more desirable. However, it requires that I explicitly set this boolean to
false
on every call with the the graphics API at the View level.