About missing of DisplacementMapFilter


#1

Hi all. I trying set a custom displacementMapFilter , because it is missing. But is no effect

import openfl.display.BitmapData;
import openfl.filters.BitmapFilter;
import openfl.geom.Point;

class DisplacementMapFilter extends BitmapFilter 
{
	
	public var alpha:Float;
	public var color:Int;
	public var componentX:Int;
	public var componentY:Int;
	public var mapBitmap:BitmapData;
	public var mapPoint:Point;
	public var mode:String;
	public var scaleX:Float;
	public var scaleY:Float;
	
	public function new(mapBitmap:BitmapData = null, mapPoint:Point = null, componentX:Int = 0, componentY:Int = 0, scaleX:Float = 0, scaleY:Float = 0, mode:String = null, color:Int = 0, alpha:Float = 0) 
	{
		super();
		
		this.mapBitmap = mapBitmap;
		this.mapPoint = mapPoint;
		this.componentY = componentY;
		this.scaleX = scaleX;
		this.scaleY = scaleY;
		this.mode = mode;
		this.color = color;
		this.alpha = alpha;
		
	}
	
}


public static function getDisplacement():DisplacementMapFilter
	{
		var mapBitmap:BitmapData = Assets.getBitmapData("img/lines.jpg"); 
		var mapPoint:Point       = new Point(0, 0); 
		var channels:Int        = BitmapDataChannel.RED;
		var componentX:Int      = channels;
		var componentY:Int      = channels;
		var scaleX:Float        = 5; 
		var scaleY:Float        = 1; 
		var mode:String          = "color";
		var color:Int           = 0;
		var alpha:Float         = 0;
 
		return new DisplacementMapFilter(
                    mapBitmap,
                    mapPoint,
                    componentX,
                    componentY,
                    scaleX,
                    scaleY,
                    mode,
                    color,
                    alpha   );
	}

var filter:DisplacementMapFilter = getDisplacement();
		
obj.filters = [filter];

#2

We have a private method called __applyFilter

Would love if you’d like to help :smile:


#3

I see, that i must override applyFilter, but what inner function code?! That is question for me


#4

I would need to try and read up on what DisplacementMapFilter does, I wonder if this would be simpler as a GL shader than working with pixels directly


#5

There are many effect, for example glitch effect