Problems with openfl_TextureCoordv in shader

  • Hey everyone,
    I'm having a problem with the openfl_TextureCoordv call on a Shader in HaxeFlixel 4.5.1 (OpenFL 8.5.0 and Lime 7.1.1). I know I had this same problem in 4.4.1 also. I'm not sure if it is a bug or if I'm just not understanding something. This happens in HTML5 and CPP targets.

    I have a simple shader that I'm trying to get to work:
    import flixel.system.FlxAssets.FlxShader;

    class TestShader extends FlxShader
    		#pragma header
    		void main()
    			if (openfl_TextureCoordv.y > 0.5)
    				gl_FragColor = vec4(1.0,0.0,0.0,1.0);
    				gl_FragColor =vec4(0.0,0.0,1.0,1.0);
    	public function new() 

    Here's my simple PlayState:

    import flixel.FlxG;
    import flixel.FlxSprite;
    import flixel.FlxState;
    import openfl.filters.ShaderFilter;
    class PlayState extends FlxState
    	override public function create():Void
    		var filter = new ShaderFilter(new TestShader());[filter]);
    	override public function update(elapsed:Float):Void

    I set the window size in the Project.xml to 128 x 128 to get the screenshots.
    I would expect the shader to color the bottom of my game screen red (after flipping the Y) and the top half blue. Instead, I get this: Weird, right?

    Then I wait about 7 seconds, and it suddenly turns to this all by itself:
    Now it is slightly less than half the screen.

    If I use the same shader on a sprite it works correctly.

    Am I just missing something about how the ShaderFilters work? If this is an actual problem I'm happy to raise an issue on GitHub but I wanted to make sure I'm not just being dense before I did that.

  • Did you figure it out?

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.