-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement pixel-perfect/subpixel rendereing toggle for FlxCamera #1060
Conversation
Glorious!!! |
@@ -348,7 +348,7 @@ class FlxObject extends FlxBasic | |||
* Only affects tilesheet rendering and rendering using BitmapData.draw() in blitting. | |||
* (copyPixels() only renders on whole pixels by nature). Causes draw() to be used if false, which is more expensive. | |||
*/ | |||
public var pixelPerfectRender(default, set):Bool = true; | |||
public var pixelPerfectRender(default, set):Null<Bool>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just return Bool, not Null<Bool>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it nullable so isPixelPerfect
could see if a value had been set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little odd, but makes sense. I have no idea why you'd want some sprites to be pixel perfect and others to not be pixel perfect, but it doesn't hurt to have that capability...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can make sense on Flash. pixelPerfect forces them to be draw()n, which is rather expensive, so you might only want the most important stuff (player char etc) to use subpixel-rendering.
Nice! I like the I thought about implementing this the other way around - have the camera's I don't like that you chose a different name for |
This doesn't really work in its current state... It would require changing public function isSimpleRenderBlit():Bool
{
return ((angle == 0) || (bakedRotationAngle > 0)) && (scale.x == 1) && (scale.y == 1) && (blend == null) && pixelPerfectRender;
} |
isSimpleRenderBlit is used in stamp, which I don't think should care about which camera the sprite is on? Null evaluates to false so this might make stamp behave strangely. Maybe it should be changed to: public function isSimpleRenderBlit():Bool
{
return ((angle == 0) || (bakedRotationAngle > 0)) && (scale.x == 1) && (scale.y == 1) && (blend == null) && (pixelPerfectRender == null || pixelPerfectRender);
} |
This change adds
pixelPerfect
toFlxCamera
, allowing you to set pixel-perfect rendering per-camera, and changes instances ofpixelPerfectRender
to use apixelPerfect
-aware check, while preserving the existing behavior.Notes:
I had spoken to Gama11 about this in IRC, and was recommended an approach similar to antialiasing (
antialiasing || camera.antialiasing
).If I had done
Camera.pixelPerfect && pixelPerfectRender
, it would exclude the case where you had setCamera.pixelPerfect = false
, but wanted to setpixelPerfectRender = true
on your object; this allowspixelPerfectRender
to take precedence regardless of what valueCamera.pixelPerfect
has been assigned.