HaxeFlixel / HaxeFlixel/flixel
FlxScaleMode w/ customizable Shader ($150 Bounty)
Nobody has claimed this yet.
- Dominant language
- Haxe
- Stars
- 2.2k
- Forks
- 522
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Description
I have a pretty specific use case that I'm having trouble implementing myself, and I'd like to put up for bounty. What I'm specifically looking for is an easy way to upscale the entire final, actually rendered set of pixels to an arbitrarily defined size, in conjuction with a user-defined shader.
Just using existing FlxCamera/FlxGame scaling is not ideal, because it doesn't actually upscale the actual, final rendered pixels, instead it increases the size of the entire drawTiles rendering area and applies scaling operations to each object during the drawing process itself. (At least, that's what it seems to be doing to me)
Example:
Say my world size is 100x100 and my scale factor is (2.0 , 2.0). Currently, flixel renders each object at object.(x , y) * 2.0 with a scale factor of (2.0 , 2.0). In a loose mathematical sense this is close to what I want, but the final rendered result is different. What I want instead is to just render those 100x100 pixels exactly as-is, and post-process them with a shader that blows them up to 200x200 pixels.
Right now my only concern is to get this working on OpenFL+Next+CPP+drawTiles, but if it can also be generalized to HTML5+WebGL target that's cool too.
Requirements:
- First render the game 1:1 at world size with no global scaling
- Take the final outputted pixels and upscale them by user-defined scale (x/y), and display transformed pixels
- Allow the user to pass in a shader of type
Shaderthat does the upscaling work- probably define a subclass or interface that enforces the right sort of shader for this (e.g. has a user-supplied scaleX/scaleY, or whatever). Maybe use enums even to guarantee functionality.
- Extra credit: expose user-definable "strength" parameter that lets you blend out the effect of the shader from 0.0-1.0
- Do proper logic under the hood to synchronize mouse position, etc to match upscaled pixels on screen
- Easy to use, something like e.g:
FlxG.scaleMode = new ShaderScaleMode(ShaderScaleEnum.BILINEAR);
FlxG.scaleMode.scale.x = scaleX;
FlxG.scaleMode.scale.y = scaleY;
Not only would this solve my personal problems, it would open up a lot of powerful features for really precise pixel-perfect upscaling operations for other developers.
(If I'm totally misunderstanding things and this is already possible / implemented, do still let me know as I'll also pay a portion of the bounty just for taking 10 minutes to show me how to achieve all this trivially with existing methods.)
The obvious starting point here is just to implement this with a dumb nearest-neighbor shader, and once that works, test that it also works with Bilinear, Bicubic, SuperSal, Scanlines, etc.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing FlxG.scaleMode, FlxCamera, and FlxGame scaling paths, including drawTiles behavior. Compare those entry points with the requested final-pixel shader flow and input-coordinate synchronization. Done means a documented, usable scale mode meets the listed rendering, shader, and mouse-position requirements on the stated target.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics, game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100