HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
2k stars 444 forks source link

lack of pixel perfect rendering #3074

Open poisonHornGames opened 8 months ago

poisonHornGames commented 8 months ago

the github gist hasn't worked for a while now, neither is there an official or easy way to do it

Geokureli commented 8 months ago

I don't know of any, off-hand, We'd have to work with openfl/lime to make a new one

poisonHornGames commented 8 months ago

pixel perfect graphics work on the flash target

https://github.com/HaxeFlixel/flixel/assets/155884736/1842a50f-cddd-4fbe-bede-b1dde8a88657

poisonHornGames commented 8 months ago

i managed to make it work by changing with the hashlink target by changing line 702 in FlxG.hx "#if air" to "#if (air || desktop)" not sure if it's the correct solution but it works :)

Geokureli commented 8 months ago

i managed to make it work by changing with the hashlink target by changing line 702 in FlxG.hx "#if air" to "#if (air || desktop)" not sure if it's the correct solution but it works :)

blitting is likely gonna have much worse performance, I do think there's a better solution but I don't know when I'll have time to try it out

UncertainProd commented 8 months ago

I tried re-creating the effect using shaders (in a fork I made) This is the shader I used:

private class PixelPerfectShader extends FlxShader
{
    @:glFragmentSource('
    #pragma header

    uniform vec2 screenSize;
    void main()
    {
        gl_FragColor = flixel_texture2D(bitmap, floor(openfl_TextureCoordv * screenSize)/screenSize);
    }
    ')
    public function new()
    {
        super();
        screenSize.value = [ FlxG.width*2, FlxG.height*2 ];
    }
}
UncertainProd commented 8 months ago

Testing on Windows:

https://github.com/HaxeFlixel/flixel/assets/83609901/fc9314f6-5e36-4922-bf90-3d9fe8959be5

Adding the ShaderFilter to an FlxCamera's filters array should probably prevent the mouse pointer from getting pixelated too