Can't add extensions to shaders

I’m trying to add the OES_standard_derivatives extension to my shader but no matter what I try I keep getting the error: WARNING: 0:18: extension directive should occur before any non-preprocessor tokens because somewhere precision mediump float; is being prefixed to the shader.

package vfx;

import openfl.Lib;

class AAPixelShader extends flixel.system.FlxAssets.FlxShader
{
	@:glVersion(300)
	@:glFragmentSource('
#extension OES_standard_derivatives : require
#pragma header

vec4 texture2DAA(sampler2D tex, vec2 uv) {
	vec2 texsize = openfl_TextureSize;
	vec2 uv_texspace = uv*texsize;
	vec2 seam = floor(uv_texspace+.5);
	uv_texspace = (uv_texspace-seam)/fwidth(uv_texspace)+seam;
	uv_texspace = clamp(uv_texspace, seam-.5, seam+.5);
	return texture2D(tex, uv_texspace/texsize);
}

void main()
{
	
	vec2 uv = openfl_TextureCoordv;
	vec2 fragCoord = uv * openfl_TextureSize;
	
	gl_FragColor = texture2DAA(bitmap, uv);
}')
	
	public function new()
	{
		super();
		
		var exts = Lib.application.window.context.webgl.getSupportedExtensions();
		lime.utils.Log.info('exts = $exts');
	}
}

It seems to happen here:

1 Like