Constructor

@:glFragmentSource("\n #pragma header\n\n uniform vec3 extraTint;\n\n uniform vec2 endPosition;\n vec2 hash22(vec2 p) {\n vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));\n p3 += dot(p3, p3.yzx + 33.33);\n return fract((p3.xx + p3.yz) * p3.zy);\n }\n\n\n\n // ====== GAMMA CORRECTION ====== //\n // Helps with color mixing -- good to have by default in almost any shader\n // See https://www.shadertoy.com/view/lscSzl\n vec3 gamma(in vec3 color) {\n return pow(color, vec3(1.0 / 2.2));\n }\n\n vec4 mainPass(vec2 fragCoord) {\n vec4 base = texture2D(bitmap, fragCoord);\n\n vec2 uv = fragCoord.xy;\n\n vec2 start = vec2(0.0, 0.0);\n vec2 end = vec2(endPosition.x / openfl_TextureSize.x, 1.0);\n\n float dx = end.x - start.x;\n float dy = end.y - start.y;\n\n float angle = atan(dy, dx);\n\n uv.x -= start.x;\n uv.y -= start.y;\n\n float uvA = atan(uv.y, uv.x);\n\n if (uvA < angle)\n return base;\n else\n return vec4(0.0);\n }\n\n vec4 antialias(vec2 fragCoord) {\n\n const float AA_STAGES = 2.0;\n\n const float AA_TOTAL_PASSES = AA_STAGES * AA_STAGES + 1.0;\n const float AA_JITTER = 0.5;\n\n // Run the shader multiple times with a random subpixel offset each time and average the results\n vec4 color = mainPass(fragCoord);\n for (float x = 0.0; x < AA_STAGES; x++)\n {\n for (float y = 0.0; y < AA_STAGES; y++)\n {\n vec2 offset = AA_JITTER * (2.0 * hash22(vec2(x, y)) - 1.0) / openfl_TextureSize.xy;\n color += mainPass(fragCoord + offset);\n }\n }\n return color / AA_TOTAL_PASSES;\n }\n\n void main() {\n vec4 col = antialias(openfl_TextureCoordv);\n col.xyz = col.xyz * extraTint.xyz;\n // col.xyz = gamma(col.xyz);\n gl_FragColor = col;\n }")new()

Variables

@:keependPosition:ShaderParameter_Float

@:value(0xFFFFFFFF)extraColor:FlxColor = 0xFFFFFFFF

@:keepextraTint:ShaderParameter_Float

Inherited Variables

Defined by FlxGraphicsShader

@:keepalpha:ShaderParameter_Float

@:keepcolorMultiplier:ShaderParameter_Float

@:keepcolorOffset:ShaderParameter_Float

@:keephasColorTransform:ShaderParameter_Bool

@:keephasTransform:ShaderParameter_Bool

@:keeppremultiplyAlpha:ShaderParameter_Bool

Defined by GraphicsShader

@:keepbitmap:ShaderInput_openfl_display_BitmapData

Defined by Shader

write onlybyteCode:ByteArray

The raw shader bytecode for this Shader instance.

data:ShaderData

Provides access to parameters, input images, and metadata for the Shader instance. ShaderParameter objects representing parameters for the shader, ShaderInput objects representing the input images for the shader, and other values representing the shader's metadata are dynamically added as properties of the data property object when the Shader instance is created. Those properties can be used to introspect the shader and to set parameter and input values. For information about accessing and manipulating the dynamic properties of the data object, see the ShaderData class description.

read onlyglFragmentBodyRaw:String

The default GLSL vertex body, before being applied to the vertex source.

glFragmentExtensions:Array<{name:String, behavior:String}>

read onlyglFragmentHeaderRaw:String

The default GLSL vertex header, before being applied to the vertex source.

glFragmentSource:String

Get or set the fragment source used when compiling with GLSL.

This property is not available on the Flash target.

read onlyglFragmentSourceRaw:String

The default GLSL fragment source, before #pragma values are replaced.

@SuppressWarnings("checkstyle:Dynamic")read onlyglProgram:GLProgram

The compiled GLProgram if available.

This property is not available on the Flash target.

glVersion:String

Get or set the GLSL version used in the header when compiling with GLSL.

  • 120 is required for initialization (i.e. providing a default value for) uniform variables

read onlyglVertexBodyRaw:String

The default GLSL vertex body, before being applied to the vertex source.

glVertexExtensions:Array<{name:String, behavior:String}>

Provides additional #extension directives to insert in the vertex and fragment shaders.

Example:

@:glExtensions([{name: "OES_standard_derivatives", behavior: "require"}])
@:glVertexExtensions([{name: "OES_standard_derivatives", behavior: "require"}])
@:glFragmentExtensions([{name: "OES_standard_derivatives", behavior: "require"}])

read onlyglVertexHeaderRaw:String

The default GLSL vertex header, before being applied to the vertex source.

glVertexSource:String

Get or set the vertex source used when compiling with GLSL.

This property is not available on the Flash target.

read onlyglVertexSourceRaw:String

The default GLSL vertex source, before #pragma values are replaced.

precisionHint:ShaderPrecision

The precision of math operations performed by the shader. The set of possible values for the precisionHint property is defined by the constants in the ShaderPrecision class.

The default value is ShaderPrecision.FULL. Setting the precision to ShaderPrecision.FAST can speed up math operations at the expense of precision.

Full precision mode (ShaderPrecision.FULL) computes all math operations to the full width of the IEEE 32-bit floating standard and provides consistent behavior on all platforms. In this mode, some math operations such as trigonometric and exponential functions can be slow.

Fast precision mode (ShaderPrecision.FAST) is designed for maximum performance but does not work consistently on different platforms and individual CPU configurations. In many cases, this level of precision is sufficient to create graphic effects without visible artifacts.

The precision mode selection affects the following shader operations. These operations are faster on an Intel processor with the SSE instruction set:

  • sin(x)
  • cos(x)
  • tan(x)
  • asin(x)
  • acos(x)
  • atan(x)
  • atan(x, y)
  • exp(x)
  • exp2(x)
  • log(x)
  • log2(x)
  • pow(x, y)
  • reciprocal(x)
  • sqrt(x)

program:Program3D

The compiled Program3D if available.

This property is not available on the Flash target.

Inherited Methods