class RuntimePostEffectShader
package funkin.graphics.shaders
extends FlxRuntimeShader › FlxGraphicsShader › GraphicsShader › Shader
extended by RuntimeCustomBlendShader, RuntimeRainShader
@:build(openfl.utils._internal.ShaderMacro.build())@:autoBuild(openfl.utils._internal.ShaderMacro.build())Available on all platforms
Constructor
@:value({ glVersion : null, fragmentSource : null })@:glVertexHeader("\n\t\t// normalized screen coord\n\t\t// (0, 0) is the top left of the window\n\t\t// (1, 1) is the bottom right of the window\n\t\tvarying vec2 screenCoord;\n\t",true)@:glVertexBody("\n\t\tscreenCoord = vec2(\n\t\t\topenfl_TextureCoord.x > 0.0 ? 1.0 : 0.0,\n\t\t\topenfl_TextureCoord.y > 0.0 ? 1.0 : 0.0\n\t\t);\n\t")@:glFragmentHeader("\n\t\t// normalized screen coord\n\t\t// (0, 0) is the top left of the window\n\t\t// (1, 1) is the bottom right of the window\n\t\tvarying vec2 screenCoord;\n\n\t\t// equals (FlxG.width, FlxG.height)\n\t\tuniform vec2 uScreenResolution;\n\n\t\t// equals (camera.viewLeft, camera.viewTop, camera.viewRight, camera.viewBottom)\n\t\tuniform vec4 uCameraBounds;\n\n\t\t// equals (frame.left, frame.top, frame.right, frame.bottom)\n\t\tuniform vec4 uFrameBounds;\n\n\t\t// screen coord -> world coord conversion\n\t\t// returns world coord in px\n\t\tvec2 screenToWorld(vec2 screenCoord) {\n\t\t\tfloat left = uCameraBounds.x;\n\t\t\tfloat top = uCameraBounds.y;\n\t\t\tfloat right = uCameraBounds.z;\n\t\t\tfloat bottom = uCameraBounds.w;\n\t\t\tvec2 scale = vec2(right - left, bottom - top);\n\t\t\tvec2 offset = vec2(left, top);\n\t\t\treturn screenCoord * scale + offset;\n\t\t}\n\n\t\t// world coord -> screen coord conversion\n\t\t// returns normalized screen coord\n\t\tvec2 worldToScreen(vec2 worldCoord) {\n\t\t\tfloat left = uCameraBounds.x;\n\t\t\tfloat top = uCameraBounds.y;\n\t\t\tfloat right = uCameraBounds.z;\n\t\t\tfloat bottom = uCameraBounds.w;\n\t\t\tvec2 scale = vec2(right - left, bottom - top);\n\t\t\tvec2 offset = vec2(left, top);\n\t\t\treturn (worldCoord - offset) / scale;\n\t\t}\n\n\t\t// screen coord -> frame coord conversion\n\t\t// returns normalized frame coord\n\t\tvec2 screenToFrame(vec2 screenCoord) {\n\t\t\tfloat left = uFrameBounds.x;\n\t\t\tfloat top = uFrameBounds.y;\n\t\t\tfloat right = uFrameBounds.z;\n\t\t\tfloat bottom = uFrameBounds.w;\n\t\t\tfloat width = right - left;\n\t\t\tfloat height = bottom - top;\n\n\t\t\tfloat clampedX = clamp(screenCoord.x, left, right);\n\t\t\tfloat clampedY = clamp(screenCoord.y, top, bottom);\n\n\t\t\treturn vec2(\n\t\t\t\t(clampedX - left) / (width),\n\t\t\t\t(clampedY - top) / (height)\n\t\t\t);\n\t\t}\n\n\t\t// internally used to get the maximum `openfl_TextureCoordv`\n\t\tvec2 bitmapCoordScale() {\n\t\t\treturn openfl_TextureCoordv / screenCoord;\n\t\t}\n\n\t\t// internally used to compute bitmap coord\n\t\tvec2 screenToBitmap(vec2 screenCoord) {\n\t\t\treturn screenCoord * bitmapCoordScale();\n\t\t}\n\n\t\t// samples the frame buffer using a screen coord\n\t\tvec4 sampleBitmapScreen(vec2 screenCoord) {\n\t\t\treturn texture2D(bitmap, screenToBitmap(screenCoord));\n\t\t}\n\n\t\t// samples the frame buffer using a world coord\n\t\tvec4 sampleBitmapWorld(vec2 worldCoord) {\n\t\t\treturn sampleBitmapScreen(worldToScreen(worldCoord));\n\t\t}\n\t",true)new(?fragmentSource:String, ?glVersion:String)
Variables
Methods
Inherited Variables
Defined by FlxGraphicsShader
Defined by GraphicsShader
Defined by Shader
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.
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.
120is required for initialization (i.e. providing a default value for)uniformvariables
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)
Inherited Methods
Defined by FlxRuntimeShader
getBitmapData(name:String):Null<BitmapData>
Retrieve a bitmap data parameter of the shader.
Parameters:
name | The name of the parameter to retrieve. |
|---|
Returns:
The value of the parameter.
getBool(name:String):Null<Bool>
Retrieve a boolean parameter of the shader.
Parameters:
name | The name of the parameter to retrieve. |
|---|
Returns:
The value of the parameter.
getBoolArray(name:String):Null<Array<Bool>>
Retrieve a boolean array parameter of the shader.
Parameters:
name | The name of the parameter to retrieve. |
|---|
Returns:
The value of the parameter.
getFloat(name:String):Null<Float>
Retrieve a float parameter of the shader.
Parameters:
name | The name of the parameter to retrieve. |
|---|
Returns:
The value of the parameter.
getFloatArray(name:String):Null<Array<Float>>
Retrieve a float array parameter of the shader.
Parameters:
name | The name of the parameter to retrieve. |
|---|
Returns:
The value of the parameter.
getInt(name:String):Null<Int>
Retrieve an integer parameter of the shader.
Parameters:
name | The name of the parameter to retrieve. |
|---|
Returns:
The value of the parameter.
getIntArray(name:String):Null<Array<Int>>
Retrieve an integer array parameter of the shader.
Parameters:
name | The name of the parameter to retrieve. |
|---|
Returns:
The value of the parameter.
setBitmapData(name:String, value:BitmapData):Void
Modify a bitmap data parameter of the shader.
Parameters:
name | The name of the parameter to modify. |
|---|---|
value | The new value to use. |
setBool(name:String, value:Bool):Void
Modify a boolean parameter of the shader.
Parameters:
name | The name of the parameter to modify. |
|---|---|
value | The new value to use. |
setBoolArray(name:String, value:Array<Bool>):Void
Modify a boolean array parameter of the shader.
Parameters:
name | The name of the parameter to modify. |
|---|---|
value | The new value to use. |
setFloat(name:String, value:Float):Void
Modify a float parameter of the shader.
Parameters:
name | The name of the parameter to modify. |
|---|---|
value | The new value to use. |
setFloatArray(name:String, value:Array<Float>):Void
Modify a float array parameter of the shader.
Parameters:
name | The name of the parameter to modify. |
|---|---|
value | The new value to use. |
setInt(name:String, value:Int):Void
Modify an integer parameter of the shader.
Parameters:
name | The name of the parameter to modify. |
|---|---|
value | The new value to use. |
setIntArray(name:String, value:Array<Int>):Void
Modify an integer array parameter of the shader.
Parameters:
name | The name of the parameter to modify. |
|---|---|
value | The new value to use. |