class SserafimShader
package funkin.graphics.shaders
extends FlxGraphicsShader › GraphicsShader › Shader
@:build(openfl.utils._internal.ShaderMacro.build())@:autoBuild(openfl.utils._internal.ShaderMacro.build())Available on all platforms
Constructor
@:value({ char : false })@:glFragmentSource("\n #pragma header\n\n // this shader includes a recreation of the Animate/Flash \"Adjust Color\" filter,\n // which was kindly provided and written by Rozebud https://github.com/ThatRozebudDude ( thank u rozebud :) )\n // Adapted from Andrey-Postelzhuks shader found here: https://forum.unity.com/threads/hue-saturation-brightness-contrast-shader.260649/\n // Hue rotation stuff is from here: https://www.w3.org/TR/filter-effects/#feColorMatrixElement\n\n uniform float hue;\n uniform float saturation;\n uniform float brightness;\n uniform float contrast;\n\n uniform float darkAmt;\n uniform vec3 lightColor;\n uniform float pulseStrength;\n uniform float truckStrength;\n uniform bool isChar;\n\n const vec3 grayscaleValues = vec3(0.3098039215686275, 0.607843137254902, 0.0823529411764706);\n\t\t const float e = 2.718281828459045;\n\n\t\t vec3 applyHueRotate(vec3 aColor, float aHue){\n\t\t\t float angle = radians(aHue);\n\n\t\t\t mat3 m1 = mat3(0.213, 0.213, 0.213, 0.715, 0.715, 0.715, 0.072, 0.072, 0.072);\n\t\t\t mat3 m2 = mat3(0.787, -0.213, -0.213, -0.715, 0.285, -0.715, -0.072, -0.072, 0.928);\n\t\t\t mat3 m3 = mat3(-0.213, 0.143, -0.787, -0.715, 0.140, 0.715, 0.928, -0.283, 0.072);\n\t\t\t mat3 m = m1 + cos(angle) * m2 + sin(angle) * m3;\n\n\t\t\t return m * aColor;\n\t\t }\n\n\t\t vec3 applySaturation(vec3 aColor, float value){\n\t\t\t if(value > 0.0){ value = value * 3.0; }\n\t\t\t value = (1.0 + (value / 100.0));\n\t\t\t vec3 grayscale = vec3(dot(aColor, grayscaleValues));\n return clamp(mix(grayscale, aColor, value), 0.0, 1.0);\n\t\t }\n\n\t\t vec3 applyContrast(vec3 aColor, float value){\n\t\t\t value = (1.0 + (value / 100.0));\n\t\t\t if(value > 1.0){\n\t\t\t\t value = (((0.00852259 * pow(e, 4.76454 * (value - 1.0))) * 1.01) - 0.0086078159) * 10.0; //Just roll with it...\n\t\t\t\t value += 1.0;\n\t\t\t }\n return clamp((aColor - 0.25) * value + 0.25, 0.0, 1.0);\n\t\t }\n\n vec3 applyHSBCEffect(vec3 color){\n\n\t\t\t //Brightness\n\t\t\t color = color + ((brightness) / 255.0);\n\n\t\t\t //Hue\n\t\t\t color = applyHueRotate(color, hue);\n\n\t\t\t //Contrast\n\t\t\t color = applyContrast(color, contrast);\n\n\t\t\t //Saturation\n color = applySaturation(color, saturation);\n\n return color;\n }\n\n #define saturate(v) clamp(v,0.,1.)\n\n vec3 hue2rgb(float hue){\n\t hue=fract(hue);\n\t return saturate(vec3(\n\t\t abs(hue*6.-3.)-1.,\n\t\t 2.-abs(hue*6.-2.),\n\t\t 2.-abs(hue*6.-4.)\n\t ));\n }\n\n vec3 rgb2hsl(vec3 c){\n\t float cMin=min(min(c.r,c.g),c.b),\n\t cMax=max(max(c.r,c.g),c.b),\n\t delta=cMax-cMin;\n\t vec3 hsl=vec3(0.,0.,(cMax+cMin)/2.);\n\t if(delta!=0.0){ //If it has chroma and isnt gray.\n\t\t if(hsl.z<.5){\n\t\t\t hsl.y=delta/(cMax+cMin); //Saturation.\n\t\t }else{\n\t\t\t hsl.y=delta/(2.-cMax-cMin); //Saturation.\n\t\t }\n\t\t float deltaR=(((cMax-c.r)/6.)+(delta/2.))/delta,\n\t\t deltaG=(((cMax-c.g)/6.)+(delta/2.))/delta,\n\t\t deltaB=(((cMax-c.b)/6.)+(delta/2.))/delta;\n\t\t //Hue.\n\t\t if(c.r==cMax){\n\t\t\t hsl.x=deltaB-deltaG;\n\t\t }else if(c.g==cMax){\n\t\t\t hsl.x=(1./3.)+deltaR-deltaB;\n\t\t }else{ //if(c.b==cMax){\n\t\t\t hsl.x=(2./3.)+deltaG-deltaR;\n\t\t }\n\t\t hsl.x=fract(hsl.x);\n\t }\n\t return hsl;\n }\n\n vec3 hsl2rgb(vec3 hsl){\n\t if(hsl.y==0.){\n\t\t return vec3(hsl.z); //Luminance.\n\t }else{\n\t\t float b;\n\t\t if(hsl.z<.5){\n\t\t\t b=hsl.z*(1.+hsl.y);\n\t\t }else{\n\t\t\t b=hsl.z+hsl.y-hsl.y*hsl.z;\n\t\t }\n\t\t float a=2.*hsl.z-b;\n\t\t return a+hue2rgb(hsl.x)*(b-a);\n\t }\n }\n\n // controls how much to brighten/darken depending on combinedAlpha.\n const float lightMultiplier = 0.07;\n\n void main()\n {\n vec4 col = texture2D(bitmap, openfl_TextureCoordv);\n\n vec3 unpremultipliedColor = col.a > 0.0 ? col.rgb / col.a : col.rgb;\n\n vec3 outColor = applyHSBCEffect(unpremultipliedColor);\n\n // truckLight1.alpha + backLightColor.alpha\n float combinedAlpha = truckStrength + pulseStrength;\n\n float darkFactor = (combinedAlpha*lightMultiplier) + darkAmt;\n if(darkAmt > 0.65) darkFactor = (combinedAlpha*(-1.0 * lightMultiplier)) + darkAmt;\n\n // interpolate between white and black depending on darkness\n vec3 multiplyColor;\n\n vec3 bruhColor = lightColor;\n bruhColor = rgb2hsl(bruhColor);\n bruhColor.b = bruhColor.b * pulseStrength;\n bruhColor = hsl2rgb(bruhColor);\n\n if(isChar == true){\n multiplyColor = mix(vec3(1.0, 1.0, 1.0), vec3(0.0, 0.0, 0.0), darkFactor/5.0);\n\n //multiplyColor = mix(multiplyColor, lightColor * vec3(pulseStrength), darkFactor/3.0);\n\n multiplyColor = mix(multiplyColor, bruhColor, darkFactor/3.0);\n }else{\n multiplyColor = mix(vec3(1.0, 1.0, 1.0), vec3(0.0, 0.0, 0.0), darkFactor);\n\n //multiplyColor = mix(multiplyColor, lightColor * vec3(pulseStrength), darkFactor/2.0);\n\n multiplyColor = mix(multiplyColor, bruhColor, darkFactor/2.0);\n }\n\n outColor *= multiplyColor;\n\n gl_FragColor = vec4(outColor.rgb * col.a, col.a);\n }\n\n\n ")new(char:Bool = false)
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)