Ls,
Yes its me again 😅
So I dropped AGAL1 and am going for AGAL2, The filter I want doesn't fit into AGAL1 for its size. I wanted to convert to Starling v2.5+ to be able to stack filters but that's off.
Sorry about that.
So I wrote a simple AGAL2 fragment shader that looks at pixels in the RGB to decide when it encounters a gradient and add a looping constant to that so it will "flow".
It does what I would expect on PC but when testing on mobile it appears to diverge from the programming.
(I have included a small video on YouTube and a static image of the gradients that it works on)
Image: http://imgur.com/a/xZFz5oT
YouTube: https://youtu.be/GFOXmjxdw2E
I did test it on all my devices and in AIR 19 -> 32 same thing.
In short: I use some constant registers for testing against values like -1, 0 and 1 and use 1 constant to transfer the looping Number value to a constant register to be able to subtract from the sampled vexel(texel?)
I use some AGAL2 conditionals to determine which sort of gradient it is seeing and then subtract the looping constant from the appropriate R,G, & | B registers.
I'm dropping the entire fragment filter below.
It uses the BASEFILTER.as from V1.8 filters package (see sticky notes)
I have been thinking perhaps that it is a linear texture sample failure (or something) which distorts the base value of the atlas) but somehow I'm afraid its a bug in V1.8
If you have read this far... 😗 and perhaps you can determine from the YouTube clip and/or the code what is wrong.
/**
* Copyright (c) 2012 Devon O. Wolfgang
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package starling.filters
{
import flash.display3D.Context3D;
import flash.display3D.Context3DProgramType;
import starling.textures.Texture;
/**
* Pixelates images (square 'pixels')
* @author Devon O.
*/
public class RGBGradientLoopFilter extends BaseFilter
{
public var vars:Vector.<Number> = new <Number>[1, 1, 1, 0.003];
public var vars2:Vector.<Number> = new <Number>[1, 9, -1, 0];
public var t:Number = 0
public var t2:Number = 1/32;
/**
* Creates a new PixelateFilter
* @param size size of pixel effect
*/
public function RGBGradientLoopFilter()
{
}
/** Set AGAL */
protected override function setAgal():void
{
FRAGMENT_SHADER =
<![CDATA[
mov ft0, v0
tex ft1, ft0, fs0<2d, clamp, nearest, mipnone>
mov ft3, ft1
mov ft4, ft1
ife ft1.x, fc1.w
ife ft1.y, fc1.w
ifg ft1.z, fc1.w
mov ft2.z, ft1.z
sub ft1.z, ft1.z, fc1.y
ifl ft1.z, fc1.w
add ft1.z, ft1.z, fc1.x
eif
eif
eif
eif
ife ft1.x, fc1.w
ifg ft1.y, fc1.w
ifg ft1.z, fc1.w
mov ft2.yz, ft1.yz
sub ft1.yz, ft1.yz, fc1.yy
ifl ft1.z, fc1.w
add ft1.z, ft1.z, fc1.x
eif
ifl ft1.y, fc1.w
add ft1.y, ft1.y, fc1.x
eif
eif
eif
eif
ife ft1.z, fc1.w
ife ft1.y, fc1.w
ifg ft1.x, fc1.w
mov ft2.x, ft1.x
sub ft1.x, ft1.x, fc1.y
ifl ft1.x, fc1.w
add ft1.x, ft1.x, fc1.x
eif
eif
eif
eif
ife ft1.z, fc1.w
ifg ft1.y, fc1.w
ifg ft1.x, fc1.w
mov ft2.xy, ft1.xy
sub ft1.xy, ft1.xy, fc1.yy
ifl ft1.x, fc1.w
add ft1.x, ft1.x, fc1.x
eif
ifl ft1.y, fc1.w
add ft1.y, ft1.y, fc1.x
eif
eif
eif
eif
ife ft1.z, fc1.w
ife ft1.x, fc1.w
ifg ft1.y, fc1.w
mov ft2.y, ft1.y
sub ft1.y, ft1.y, fc1.y
ifl ft1.y, fc1.w
add ft1.y, ft1.y, fc1.x
eif
eif
eif
eif
ife ft1.y, fc1.w
ifg ft1.x, fc1.w
ifg ft1.z, fc1.w
mov ft2.xz, ft1.xz
sub ft1.xz, ft1.xz, fc1.yy
ifl ft1.x, fc1.w
add ft1.x, ft1.x, fc1.x
eif
ifl ft1.z, fc1.w
add ft1.z, ft1.z, fc1.x
eif
eif
eif
eif
mov oc, ft1
]]>
}
/* sortof works,
public var vars:Vector.<Number> = new <Number>[1, 1, 1, 0.0001];
public var vars2:Vector.<Number> = new <Number>[1, 9, -1, 0];
public var vars3:Vector.<Number> = new <Number>[.5, 0, 0, 0];
private var _size:int;
public var t:Number = 0
public var t2:Number = 1/32;
div ft0, v0, fc0.xy
frc ft1, ft0.xy
sub ft0, ft0, ft1.xy
mul ft0, ft0, fc0.xy
tex ft1, ft0, fs0<2d, clamp, linear, mipnone>
ifl ft1.x, fc0.w
ifl ft1.y, fc0.w
ifg ft1.z, fc1.w
mov ft2.z, ft1.z
sub ft1.z, ft1.z, fc1.y
ifl ft1.z, fc1.w
sub ft1.z, fc1.x, ft2.z
eif
sub ft1.z, ft1.z, fc0.z
ifl ft1.z, fc1.w
mul ft1.z, ft1.z, fc1.z
eif
ifg ft1.z, fc1.x
sub ft1.z,ft1.z, fc1.x
eif
eif
eif
eif
mov oc, ft1
*/
/** Activate
*
*
* */
protected override function activate(pass:int, context:Context3D, texture:Texture):void
{
this.vars[2] = t
//trace(Math.cos(t))
context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, this.vars, 1);
this.vars2[1] = t2;
//trace(this.vars2.toString(), this.vars[2])
context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT,1 , this.vars2, 1);
super.activate(pass, context, texture);
}
/** Pixel Size */
}
}