-
Notifications
You must be signed in to change notification settings - Fork 435
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
Fixes to FlxStrip rendering #2696
Conversation
Also in the issue linked, I had proposed using a 'repeat' field to control whether a bitmapfill or a shaderfill would be used but it turns out that ShaderInput objects already have a 'wrap' field that controls whether the texture gets repeated or not, so the old solution I proposed isn't needed and I just set |
Firstly, my schedule is insane for all of december, so I may take a bit to get to this. second, I can't merge this until I fully understand it.
I'm still considering reverting the previous PR, and then having a new pr that implements it without breaking everything. reason being is that these changes seem to be far reaching, and can effect things that cannot be unit tested. So before I release a changes like this We either need to develop a manual testing strategy that ensures nothing is broken in flixel, addons or ui, or we need to develop automated tests that notify us when things are broken. I have no idea how to automate graphical verification. So perhaps we need to list out everything that uses vertice drawing and develop a comprehensive test project that allows us to visually verify that these changes are okay? My ultimate fear is that this fix will break something else and it will just continue forever, at a time when I can't dedicate a lot of time to HF. also developing a test strategy would likely help me understand flixel's rendering system better, which is always good |
Oh, but when I tested it using this code, it worked for me (its a slightly modified version of the test link you had sent: https://github.com/Geokureli/flixel-tests/blob/main/Source/states/FlxStripShaderTestState.hx ): package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.FlxStrip;
import flixel.graphics.tile.FlxDrawTrianglesItem.DrawData;
import flixel.system.FlxAssets.FlxShader;
import flixel.util.FlxColor;
class PlayState extends FlxState
{
var sprite:FlxSprite;
var strip:FlxStrip;
override public function create()
{
super.create();
add(sprite = createSprite(0, 0));
add(sprite = createSprite(110, 0, FlxColor.BLUE));
sprite.color = 0xFF000080;
add(sprite = createSprite(220, 0));
sprite.color = 0xFFff0080;
add(sprite = createSprite(330, 0));
sprite.shader = new GreenShader();
add(sprite = createSprite(440, 0));
sprite.setColorTransform(.5, 1.0, 0.0, 0.5, 0x40, 0x40, 0x40); // testing alphaMultiplier
// strips
add(strip = createStrip(0, 110));
add(strip = createStrip(110, 110, FlxColor.BLUE));
strip.color = 0xFF000080;
add(strip = createStrip(220, 110));
strip.color = 0xFFff0080;
add(strip = createStrip(330, 110));
strip.shader = new GreenShader();
add(strip = createStrip(440, 110));
strip.setColorTransform(.5, 1.0, 0.0, 0.5, 0x40, 0x40, 0x40); // testing alphaMultiplier
}
function createSprite(x = 0.0, y = 0.0, color = 0xFFffffff)
{
return new FlxSprite(x, y).makeGraphic(100, 100, color);
}
function createStrip(x = 0.0, y = 0.0, color = 0xFFffffff)
{
var strip:FlxStrip;
strip = new FlxStrip(x, y);
strip.makeGraphic(100, 100, color);
strip.vertices = DrawData.ofArray([0.0, 0.0, 50, 0, 25, 50]);
strip.indices = DrawData.ofArray([0, 1, 2]);
strip.uvtData = DrawData.ofArray([0, 0, 0, 1, 1, 1.0]);
return strip;
}
}
class GreenShader extends FlxShader
{
@glFragmentSource('
#pragma header
void main()
{
vec4 clr = texture2D(bitmap, openfl_TextureCoordv);
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0) * clr.a;
}
')
public function new()
{
super();
}
} Did you try it with the latest commit I made? (899dae4) |
Turns out I was on haxelib version 5.1.0, when I thought I was on dev. This is working. I edited my test to include FlxTiledSprite, it seems to work in all cases @mastereric Any issues with this? |
I found that these classes from flixel-addons either use drawTriangles or extends FlxStrip, so these can also be added into the test:
Although some of these (like FlxClothSprite) need some changes to it's source code for shaders to work on it, and those changes would only work on this fork of flixel. I've made those changes on this fork of flixel-addons |
Thanks for the list, we dont need to add shaders to all of these were just need to make sure existing features aren't broken, I'll add these to my test. |
Cool 👍 |
Fyi should be able to check all these tomorrow, sorry for the delay |
This should fix #2694