Inverting texture color with AGAL

85 views Asked by At

I've been using the Genome2D library and wanted to create a filter that inverts all color. After reading Adobe documentation, I can't seem to figure out what's going on with the alpha channel since .rgba doesn't even seem to work.

This Genome2D code desaturates all color:

fragmentCode = "dp3 ft0.xyz, ft0.xyz, fc1.xyz";
fragmentConstants = Vector.<Number>([0.299,0.587,0.114,0]);

Following that example, I wrote this code for inverting color:

fragmentCode = "sub ft0.xyz, fc1.xyz, ft0.xyz"
fragmentConstants = Vector.<Number>([1,1,1,0]);

All of the color inverts, but the alpha channel is fully opaque in places it should be completely transparent. I'm having trouble figuring out how to copy the old alpha values from the original texture.

0

There are 0 answers