diff --git a/.vscode/settings.json b/.vscode/settings.json index bc601fbda..6c6ac02a6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -37,7 +37,6 @@ "Effects/FlxTween/source", "Effects/MosaicEffect/source", "Effects/Parallax/source", - "Effects/PostProcess/source", "Effects/Transitions/source", "Features/CollisionAndGrouping/source", "Features/Colors/source", diff --git a/Editors/TexturePackerAtlas/source/MenuState.hx b/Editors/TexturePackerAtlas/source/MenuState.hx index bf2e0e266..6b373a32b 100644 --- a/Editors/TexturePackerAtlas/source/MenuState.hx +++ b/Editors/TexturePackerAtlas/source/MenuState.hx @@ -123,8 +123,5 @@ class MenuState extends FlxState x11.animation.addByPrefix("spin", "", 3); x11.animation.play("spin"); add(x11); - - // Remove atlas bitmaps from memory (useful for targets with hardware acceleration: cpp only atm). - FlxG.bitmap.dumpCache(); } } diff --git a/Effects/PostProcess/PostProcess.hxproj b/Effects/PostProcess/PostProcess.hxproj deleted file mode 100644 index d864fb9a8..000000000 --- a/Effects/PostProcess/PostProcess.hxproj +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "$(CompilerPath)/haxelib" run lime build "$(OutputFile)" $(TargetBuild) -$(BuildConfig) -Dfdb - - - - - - - - \ No newline at end of file diff --git a/Effects/PostProcess/Project.xml b/Effects/PostProcess/Project.xml deleted file mode 100644 index f965e2824..000000000 --- a/Effects/PostProcess/Project.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Effects/PostProcess/assets/images/logo.png b/Effects/PostProcess/assets/images/logo.png deleted file mode 100644 index e939189a2..000000000 Binary files a/Effects/PostProcess/assets/images/logo.png and /dev/null differ diff --git a/Effects/PostProcess/assets/shaders/blur.frag b/Effects/PostProcess/assets/shaders/blur.frag deleted file mode 100644 index d13dc3ebb..000000000 --- a/Effects/PostProcess/assets/shaders/blur.frag +++ /dev/null @@ -1,47 +0,0 @@ -//"in" attributes from our vertex shader -varying vec2 vTexCoord; - -//declare uniforms -uniform sampler2D uImage0; -uniform vec2 uResolution; - -uniform float radius; -uniform float dirx; -uniform float diry; - -void main() -{ - //this will be our RGBA sum - vec4 sum = vec4(0.0); - - //our original texcoord for this fragment - vec2 tc = vTexCoord; - - //the amount to blur, i.e. how far off center to sample from - //1.0 -> blur by one pixel - //2.0 -> blur by two pixels, etc. - float blur = radius / uResolution.x; - - //the direction of our blur - //(1.0, 0.0) -> x-axis blur - //(0.0, 1.0) -> y-axis blur - float hstep = dirx; - float vstep = diry; - - //apply blurring, using a 9-tap filter with predefined gaussian weights - - sum += texture2D(uImage0, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.0162162162; - sum += texture2D(uImage0, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.0540540541; - sum += texture2D(uImage0, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.1216216216; - sum += texture2D(uImage0, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.1945945946; - - sum += texture2D(uImage0, vec2(tc.x, tc.y)) * 0.2270270270; - - sum += texture2D(uImage0, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.1945945946; - sum += texture2D(uImage0, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.1216216216; - sum += texture2D(uImage0, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.0540540541; - sum += texture2D(uImage0, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.0162162162; - - //discard alpha for our simple demo, multiply by vertex color and return - gl_FragColor = vec4(sum.rgb, 1.0); -} diff --git a/Effects/PostProcess/assets/shaders/deuteranopia.frag b/Effects/PostProcess/assets/shaders/deuteranopia.frag deleted file mode 100644 index 3497e796e..000000000 --- a/Effects/PostProcess/assets/shaders/deuteranopia.frag +++ /dev/null @@ -1,16 +0,0 @@ -// -// Deuteranopia color blindness simulation -// Simple passthrough fragment shader -// -uniform sampler2D uImage0; -varying vec2 vTexCoord; - -const mat4 mDeuteranopia = mat4( 0.43 , 0.72 , -0.15 , 0.0 , - 0.34 , 0.57 , 0.09 , 0.0 , - -0.02 , 0.03 , 1.00 , 0.0 , - 0.0 , 0.0 , 0.0 , 1.0 ); - -void main() -{ - gl_FragColor = mDeuteranopia * texture2D(uImage0, vTexCoord); -} diff --git a/Effects/PostProcess/assets/shaders/grain.frag b/Effects/PostProcess/assets/shaders/grain.frag deleted file mode 100644 index 5f0163195..000000000 --- a/Effects/PostProcess/assets/shaders/grain.frag +++ /dev/null @@ -1,141 +0,0 @@ -/* -Film Grain post-process shader v1.1 -Martins Upitis (martinsh) devlog-martinsh.blogspot.com -2013 - --------------------------- -This work is licensed under a Creative Commons Attribution 3.0 Unported License. -So you are free to share, modify and adapt it for your needs, and even use it for commercial use. -I would also love to hear about a project you are using it. - -Have fun, -Martins --------------------------- - -Perlin noise shader by toneburst: -http://machinesdontcare.wordpress.com/2009/06/25/3d-perlin-noise-sphere-vertex-shader-sourcecode/ -*/ - -uniform sampler2D uImage0; //rendered scene sampler -uniform vec2 uResolution; //scene sampler resolution -uniform float uTime; - -varying vec2 vTexCoord; - -const float permTexUnit = 1.0/256.0; // Perm texture texel-size -const float permTexUnitHalf = 0.5/256.0; // Half perm texture texel-size - -float width = uResolution.x; -float height = uResolution.y; - -const float grainamount = 0.05; //grain amount -bool colored = false; //colored noise? -float coloramount = 0.6; -float grainsize = 1.6; //grain particle size (1.5 - 2.5) -float lumamount = 1.0; // - -//a random texture generator, but you can also use a pre-computed perturbation texture -vec4 rnm(in vec2 tc) -{ - float noise = sin(dot(tc + vec2(uTime,uTime),vec2(12.9898,78.233))) * 43758.5453; - - float noiseR = fract(noise)*2.0-1.0; - float noiseG = fract(noise*1.2154)*2.0-1.0; - float noiseB = fract(noise*1.3453)*2.0-1.0; - float noiseA = fract(noise*1.3647)*2.0-1.0; - - return vec4(noiseR,noiseG,noiseB,noiseA); -} - -float fade(in float t) { - return t*t*t*(t*(t*6.0-15.0)+10.0); -} - -float pnoise3D(in vec3 p) -{ - vec3 pi = permTexUnit*floor(p)+permTexUnitHalf; // Integer part, scaled so +1 moves permTexUnit texel - // and offset 1/2 texel to sample texel centers - vec3 pf = fract(p); // Fractional part for interpolation - - // Noise contributions from (x=0, y=0), z=0 and z=1 - float perm00 = rnm(pi.xy).a ; - vec3 grad000 = rnm(vec2(perm00, pi.z)).rgb * 4.0 - 1.0; - float n000 = dot(grad000, pf); - vec3 grad001 = rnm(vec2(perm00, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n001 = dot(grad001, pf - vec3(0.0, 0.0, 1.0)); - - // Noise contributions from (x=0, y=1), z=0 and z=1 - float perm01 = rnm(pi.xy + vec2(0.0, permTexUnit)).a ; - vec3 grad010 = rnm(vec2(perm01, pi.z)).rgb * 4.0 - 1.0; - float n010 = dot(grad010, pf - vec3(0.0, 1.0, 0.0)); - vec3 grad011 = rnm(vec2(perm01, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n011 = dot(grad011, pf - vec3(0.0, 1.0, 1.0)); - - // Noise contributions from (x=1, y=0), z=0 and z=1 - float perm10 = rnm(pi.xy + vec2(permTexUnit, 0.0)).a ; - vec3 grad100 = rnm(vec2(perm10, pi.z)).rgb * 4.0 - 1.0; - float n100 = dot(grad100, pf - vec3(1.0, 0.0, 0.0)); - vec3 grad101 = rnm(vec2(perm10, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n101 = dot(grad101, pf - vec3(1.0, 0.0, 1.0)); - - // Noise contributions from (x=1, y=1), z=0 and z=1 - float perm11 = rnm(pi.xy + vec2(permTexUnit, permTexUnit)).a ; - vec3 grad110 = rnm(vec2(perm11, pi.z)).rgb * 4.0 - 1.0; - float n110 = dot(grad110, pf - vec3(1.0, 1.0, 0.0)); - vec3 grad111 = rnm(vec2(perm11, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n111 = dot(grad111, pf - vec3(1.0, 1.0, 1.0)); - - // Blend contributions along x - vec4 n_x = mix(vec4(n000, n001, n010, n011), vec4(n100, n101, n110, n111), fade(pf.x)); - - // Blend contributions along y - vec2 n_xy = mix(n_x.xy, n_x.zw, fade(pf.y)); - - // Blend contributions along z - float n_xyz = mix(n_xy.x, n_xy.y, fade(pf.z)); - - // We're done, return the final noise value. - return n_xyz; -} - -//2d coordinate orientation thing -vec2 coordRot(in vec2 tc, in float angle) -{ - float aspect = width/height; - float rotX = ((tc.x*2.0-1.0)*aspect*cos(angle)) - ((tc.y*2.0-1.0)*sin(angle)); - float rotY = ((tc.y*2.0-1.0)*cos(angle)) + ((tc.x*2.0-1.0)*aspect*sin(angle)); - rotX = ((rotX/aspect)*0.5+0.5); - rotY = rotY*0.5+0.5; - return vec2(rotX,rotY); -} - -void main() -{ - vec2 texCoord = vTexCoord.st; - - vec3 rotOffset = vec3(1.425,3.892,5.835); //rotation offset values - vec2 rotCoordsR = coordRot(texCoord, uTime + rotOffset.x); - vec3 noise = vec3(pnoise3D(vec3(rotCoordsR*vec2(width/grainsize,height/grainsize),0.0))); - - if (colored) - { - vec2 rotCoordsG = coordRot(texCoord, uTime + rotOffset.y); - vec2 rotCoordsB = coordRot(texCoord, uTime + rotOffset.z); - noise.g = mix(noise.r,pnoise3D(vec3(rotCoordsG*vec2(width/grainsize,height/grainsize),1.0)),coloramount); - noise.b = mix(noise.r,pnoise3D(vec3(rotCoordsB*vec2(width/grainsize,height/grainsize),2.0)),coloramount); - } - - vec3 col = texture2D(uImage0, texCoord).rgb; - - //noisiness response curve based on scene luminance - vec3 lumcoeff = vec3(0.299,0.587,0.114); - float luminance = mix(0.0,dot(col, lumcoeff),lumamount); - float lum = smoothstep(0.2,0.0,luminance); - lum += luminance; - - - noise = mix(noise,vec3(0.0),pow(lum,4.0)); - col = col+noise*grainamount; - - gl_FragColor = vec4(col,1.0); -} diff --git a/Effects/PostProcess/assets/shaders/grayscale.frag b/Effects/PostProcess/assets/shaders/grayscale.frag deleted file mode 100644 index d8dffa86b..000000000 --- a/Effects/PostProcess/assets/shaders/grayscale.frag +++ /dev/null @@ -1,13 +0,0 @@ -#ifdef GL_ES - precision mediump float; -#endif - -varying vec2 vTexCoord; -uniform sampler2D uImage0; - -void main(void) -{ - vec4 color = texture2D(uImage0, vTexCoord); - float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114)); - gl_FragColor = vec4(gray, gray, gray, 1.0); -} diff --git a/Effects/PostProcess/assets/shaders/hq2x.frag b/Effects/PostProcess/assets/shaders/hq2x.frag deleted file mode 100644 index 9f4854dd7..000000000 --- a/Effects/PostProcess/assets/shaders/hq2x.frag +++ /dev/null @@ -1,25 +0,0 @@ -uniform sampler2D uImage0; -uniform vec2 uResolution; - -varying vec2 vTexCoord; - -void main() -{ - float x = 1.0 / uResolution.x; - float y = 1.0 / uResolution.y; - - vec4 color1 = texture2D(uImage0, vTexCoord.st + vec2(-x, -y)); - vec4 color2 = texture2D(uImage0, vTexCoord.st + vec2(0.0, -y)); - vec4 color3 = texture2D(uImage0, vTexCoord.st + vec2(x, -y)); - - vec4 color4 = texture2D(uImage0, vTexCoord.st + vec2(-x, 0.0)); - vec4 color5 = texture2D(uImage0, vTexCoord.st + vec2(0.0, 0.0)); - vec4 color6 = texture2D(uImage0, vTexCoord.st + vec2(x, 0.0)); - - vec4 color7 = texture2D(uImage0, vTexCoord.st + vec2(-x, y)); - vec4 color8 = texture2D(uImage0, vTexCoord.st + vec2(0.0, y)); - vec4 color9 = texture2D(uImage0, vTexCoord.st + vec2(x, y)); - vec4 avg = color1 + color2 + color3 + color4 + color5 + color6 + color7 + color8 + color9; - - gl_FragColor = avg / 9.0; -} diff --git a/Effects/PostProcess/assets/shaders/invert.frag b/Effects/PostProcess/assets/shaders/invert.frag deleted file mode 100644 index 027fcec4b..000000000 --- a/Effects/PostProcess/assets/shaders/invert.frag +++ /dev/null @@ -1,12 +0,0 @@ -#ifdef GL_ES - precision mediump float; -#endif - -varying vec2 vTexCoord; -uniform sampler2D uImage0; - -void main(void) -{ - vec4 color = texture2D(uImage0, vTexCoord); - gl_FragColor = vec4(vec3(1.0, 1.0, 1.0) - color.rgb, color.a); -} diff --git a/Effects/PostProcess/assets/shaders/protanopia.frag b/Effects/PostProcess/assets/shaders/protanopia.frag deleted file mode 100644 index 709ffe4f9..000000000 --- a/Effects/PostProcess/assets/shaders/protanopia.frag +++ /dev/null @@ -1,16 +0,0 @@ -// -// Protanopia color blindness simulation -// Simple passthrough fragment shader -// -uniform sampler2D uImage0; -varying vec2 vTexCoord; - -const mat4 mProtanopia = mat4( 0.20 , 0.99 , -0.19 , 0.0 , - 0.16 , 0.79 , 0.04 , 0.0 , - 0.01 , -0.01 , 1.00 , 0.0 , - 0.0 , 0.0 , 0.0 , 1.0 ); - -void main() -{ - gl_FragColor = mProtanopia * texture2D(uImage0, vTexCoord); -} diff --git a/Effects/PostProcess/assets/shaders/scanline.frag b/Effects/PostProcess/assets/shaders/scanline.frag deleted file mode 100644 index dbb52cfcf..000000000 --- a/Effects/PostProcess/assets/shaders/scanline.frag +++ /dev/null @@ -1,17 +0,0 @@ -#ifdef GL_ES - precision mediump float; -#endif - -varying vec2 vTexCoord; -uniform vec2 uResolution; -uniform sampler2D uImage0; - -const float scale = 1.0; - -void main() -{ - if (mod(floor(vTexCoord.y * uResolution.y / scale), 2.0) == 0.0) - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - else - gl_FragColor = texture2D(uImage0, vTexCoord); -} diff --git a/Effects/PostProcess/assets/shaders/tiltshift.frag b/Effects/PostProcess/assets/shaders/tiltshift.frag deleted file mode 100644 index 350640b0c..000000000 --- a/Effects/PostProcess/assets/shaders/tiltshift.frag +++ /dev/null @@ -1,82 +0,0 @@ -// Modified version of a tilt shift shader from Martin Jonasson (http://grapefrukt.com/) -// Read http://notes.underscorediscovery.com/ for context on shaders and this file -// License : MIT - -uniform sampler2D uImage0; -varying vec2 vTexCoord; - - /* - Take note that blurring in a single pass (the two for loops below) is more expensive than separating - the x and the y blur into different passes. This was used where bleeding edge performance - was not crucial and is to illustrate a point. - - The reason two passes is cheaper? - texture2D is a fairly high cost call, sampling a texture. - - So, in a single pass, like below, there are 3 steps, per x and y. - - That means a total of 9 "taps", it touches the texture to sample 9 times. - - Now imagine we apply this to some geometry, that is equal to 16 pixels on screen (tiny) - (16 * 16) * 9 = 2304 samples taken, for width * height number of pixels, * 9 taps - Now, if you split them up, it becomes 3 for x, and 3 for y, a total of 6 taps - (16 * 16) * 6 = 1536 samples - - That's on a *tiny* sprite, let's scale that up to 128x128 sprite... - (128 * 128) * 9 = 147,456 - (128 * 128) * 6 = 98,304 - - That's 33.33..% cheaper for splitting them up. - That's with 3 steps, with higher steps (more taps per pass...) - - A really smooth, 6 steps, 6*6 = 36 taps for one pass, 12 taps for two pass - You will notice, the curve is not linear, at 12 steps it's 144 vs 24 taps - It becomes orders of magnitude slower to do single pass! - Therefore, you split them up into two passes, one for x, one for y. - */ - - //I am hardcoding the constants like a jerk - -const float bluramount = 1.0; -const float center = 1.0; -const float stepSize = 0.004; -const float steps = 3.0; - -const float minOffs = (float(steps-1.0)) / -2.0; -const float maxOffs = (float(steps-1.0)) / +2.0; - -void main() { - - float amount; - vec4 blurred; - - //Work out how much to blur based on the mid point - amount = pow((vTexCoord.y * center) * 2.0 - 1.0, 2.0) * bluramount; - - //This is the accumulation of color from the surrounding pixels in the texture - blurred = vec4(0.0, 0.0, 0.0, 1.0); - - //From minimum offset to maximum offset - for (float offsX = minOffs; offsX <= maxOffs; ++offsX) { - for (float offsY = minOffs; offsY <= maxOffs; ++offsY) { - - //copy the coord so we can mess with it - vec2 temp_tcoord = vTexCoord.xy; - - //work out which uv we want to sample now - temp_tcoord.x += offsX * amount * stepSize; - temp_tcoord.y += offsY * amount * stepSize; - - //accumulate the sample - blurred += texture2D(uImage0, temp_tcoord); - - } //for y - } //for x - - //because we are doing an average, we divide by the amount (x AND y, hence steps * steps) - blurred /= float(steps * steps); - - //return the final blurred color - gl_FragColor = blurred; - -} //main diff --git a/Effects/PostProcess/assets/shaders/tritanopia.frag b/Effects/PostProcess/assets/shaders/tritanopia.frag deleted file mode 100644 index 6ec38e492..000000000 --- a/Effects/PostProcess/assets/shaders/tritanopia.frag +++ /dev/null @@ -1,16 +0,0 @@ -// -// Tritanopia color blindness simulation -// Simple passthrough fragment shader -// -uniform sampler2D uImage0; -varying vec2 vTexCoord; - -const mat4 mTritanopia = mat4( 0.97 , 0.11 , -0.08 , 0.0 , - 0.02 , 0.82 , 0.16 , 0.0 , - -0.06 , 0.88 , 0.18 , 0.0 , - 0.0 , 0.0 , 0.0 , 1.0 ); - -void main() -{ - gl_FragColor = mTritanopia * texture2D(uImage0, vTexCoord); -} diff --git a/Effects/PostProcess/source/Main.hx b/Effects/PostProcess/source/Main.hx deleted file mode 100644 index 9ba757312..000000000 --- a/Effects/PostProcess/source/Main.hx +++ /dev/null @@ -1,13 +0,0 @@ -package; - -import flixel.FlxGame; -import openfl.display.Sprite; - -class Main extends Sprite -{ - public function new() - { - super(); - addChild(new FlxGame(640, 480, PlayState)); - } -} diff --git a/Effects/PostProcess/source/PlayState.hx b/Effects/PostProcess/source/PlayState.hx deleted file mode 100644 index 6d13f1cb8..000000000 --- a/Effects/PostProcess/source/PlayState.hx +++ /dev/null @@ -1,54 +0,0 @@ -package; - -import flixel.addons.display.FlxBackdrop; -import flixel.addons.ui.FlxUIAssets; -import flixel.addons.ui.FlxUICheckBox; -import flixel.effects.postprocess.PostProcess; -import flixel.FlxG; -import flixel.FlxState; - -class PlayState extends FlxState -{ - var shaderNames:Array = [ - "blur", "tiltshift", "deuteranopia", "grain", "grayscale", "hq2x", "invert", "protanopia", "scanline", "tritanopia" - ]; - - var fragmentShaders:Array = []; - - override public function create():Void - { - var backdrop = new FlxBackdrop("assets/images/logo.png"); - backdrop.velocity.set(150, 150); - add(backdrop); - - var x = 10; - var y = 10; - - for (i in 0...shaderNames.length) - { - fragmentShaders.push(new PostProcess("assets/shaders/" + shaderNames[i] + ".frag")); - - createCheckbox(x, y, shaderNames[i], fragmentShaders[i]); - y += 25; - } - - // some shaders have properties that can be manipulated at runtime - var blurShader = fragmentShaders[0]; - blurShader.setUniform("diry", 1); - blurShader.setUniform("dirx", 1); - blurShader.setUniform("radius", 1); - } - - function createCheckbox(x:Float, y:Float, name:String, shader:PostProcess) - { - var checkbox = new FlxUICheckBox(x, y, FlxUIAssets.IMG_CHECK_BOX, FlxUIAssets.IMG_CHECK_MARK, name); - checkbox.callback = function() - { - if (checkbox.checked) - FlxG.addPostProcess(shader); - else - FlxG.removePostProcess(shader); - } - add(checkbox); - } -} diff --git a/flixel-demos.code-workspace b/flixel-demos.code-workspace index f169fda84..64e40146f 100644 --- a/flixel-demos.code-workspace +++ b/flixel-demos.code-workspace @@ -84,9 +84,6 @@ { "path": "Effects/Parallax" }, - { - "path": "Effects/PostProcess" - }, { "path": "Effects/Transitions" },