|
|
|
@@ -215,8 +215,8 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
|
|
|
|
|
if(value == null)
|
|
|
|
|
value = ShaderTemplates.defaultFragmentSource;
|
|
|
|
|
glRawFragmentSource = value;
|
|
|
|
|
value = value.replace("#pragma header", ShaderTemplates.fragHeader).replace("#pragma body", ShaderTemplates.fragBody);
|
|
|
|
|
value = processImports(value, FRAGMENT_SHADER);
|
|
|
|
|
value = value.replace("#pragma header", ShaderTemplates.fragHeader).replace("#pragma body", ShaderTemplates.fragBody);
|
|
|
|
|
if (value != __glFragmentSource)
|
|
|
|
|
{
|
|
|
|
|
__glSourceDirty = true;
|
|
|
|
@@ -230,8 +230,19 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
|
|
|
|
|
if(value == null)
|
|
|
|
|
value = ShaderTemplates.defaultVertexSource;
|
|
|
|
|
glRawVertexSource = value;
|
|
|
|
|
value = value.replace("#pragma header", ShaderTemplates.vertHeader).replace("#pragma body", ShaderTemplates.vertBody);
|
|
|
|
|
value = processImports(value, VERTEX_SHADER);
|
|
|
|
|
|
|
|
|
|
var useBackCompat:Bool = true;
|
|
|
|
|
for (regex in ShaderTemplates.vertBackCompatVarList) if (!regex.match(value)) {
|
|
|
|
|
useBackCompat = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var header = useBackCompat ? ShaderTemplates.vertHeaderBackCompat : ShaderTemplates.vertHeader;
|
|
|
|
|
var body = useBackCompat ? ShaderTemplates.vertBodyBackCompat : ShaderTemplates.vertBody;
|
|
|
|
|
|
|
|
|
|
value = value.replace("#pragma header", header).replace("#pragma body", body);
|
|
|
|
|
|
|
|
|
|
if (value != __glVertexSource)
|
|
|
|
|
{
|
|
|
|
|
__glSourceDirty = true;
|
|
|
|
@@ -521,7 +532,7 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
|
|
|
|
|
|
|
|
|
|
// cant do "field is ShaderInput" because ShaderInput has the @:generic metadata
|
|
|
|
|
// aka instead of ShaderInput<Float> it gets built as ShaderInput_Float
|
|
|
|
|
// this should be fine tho because we check the class, and the fields dont vary based on the type
|
|
|
|
|
// this should be fine tho because we check the class, and the fields don't vary based on the type
|
|
|
|
|
|
|
|
|
|
// thanks for looking in the code cne fans :D!! -lunar
|
|
|
|
|
|
|
|
|
@@ -673,6 +684,38 @@ if(hasColorTransform) {
|
|
|
|
|
|
|
|
|
|
gl_Position = openfl_Matrix * openfl_Position;";
|
|
|
|
|
|
|
|
|
|
// TODO: make this ignore comments
|
|
|
|
|
public static final vertBackCompatVarList:Array<EReg> = [
|
|
|
|
|
~/attribute float alpha/,
|
|
|
|
|
~/attribute vec4 colorMultiplier/,
|
|
|
|
|
~/attribute vec4 colorOffset/,
|
|
|
|
|
~/uniform bool hasColorTransform/
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public static final vertHeaderBackCompat:String = "attribute float openfl_Alpha;
|
|
|
|
|
attribute vec4 openfl_ColorMultiplier;
|
|
|
|
|
attribute vec4 openfl_ColorOffset;
|
|
|
|
|
attribute vec4 openfl_Position;
|
|
|
|
|
attribute vec2 openfl_TextureCoord;
|
|
|
|
|
|
|
|
|
|
varying float openfl_Alphav;
|
|
|
|
|
varying vec4 openfl_ColorMultiplierv;
|
|
|
|
|
varying vec4 openfl_ColorOffsetv;
|
|
|
|
|
varying vec2 openfl_TextureCoordv;
|
|
|
|
|
|
|
|
|
|
uniform mat4 openfl_Matrix;
|
|
|
|
|
uniform bool openfl_HasColorTransform;
|
|
|
|
|
uniform vec2 openfl_TextureSize;";
|
|
|
|
|
|
|
|
|
|
public static final vertBodyBackCompat:String = "openfl_Alphav = openfl_Alpha;
|
|
|
|
|
openfl_TextureCoordv = openfl_TextureCoord;
|
|
|
|
|
|
|
|
|
|
if(openfl_HasColorTransform) {
|
|
|
|
|
openfl_ColorMultiplierv = openfl_ColorMultiplier;
|
|
|
|
|
openfl_ColorOffsetv = openfl_ColorOffset / 255.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gl_Position = openfl_Matrix * openfl_Position;";
|
|
|
|
|
|
|
|
|
|
public static final defaultVertexSource:String = "#pragma header
|
|
|
|
|
|
|
|
|
|